test/org/ohmage/test/ParameterSets.java
private static void initUrnValues() {
    // This will build a URN of the minimum length and ending with a colon.
    StringBuilder urnBuilder = new StringBuilder("urn:");
    invalidUrns.add(urnBuilder.toString());

    // This will build a URN of the minimum length but without any values.
    StringBuilder urnWithoutValuesBuilder = new StringBuilder(urnBuilder);

    // Compose both URN builders.
    for (int i = 1; i < StringUtils.NUM_URN_SEGMENTS; i++) {
      // Add the dummy character.
      urnBuilder.append('a');

      // If this is the final segment, add it to the collection of good
      // URNs.
      if (i == (StringUtils.NUM_URN_SEGMENTS - 1)) {
        validUrns.add(urnBuilder.toString());
      } // Otherwise, add it to the collection of bad URNs as it is still 
      // not long enough.
      else {
        invalidUrns.add(urnBuilder.toString());
      }

      // Add the dividor.
      urnBuilder.append(':');
      urnWithoutValuesBuilder.append(':');

      // No matter the length, no URN may end with a dividor character.
      invalidUrns.add(urnBuilder.toString());
    }
    // Now, we have a URN builder with the exact number of characters and
    // ending with a dividor character and ready to be cloned to create new
    // valid or invalid URNs.

    // For the URN builder with no values, add it to the list of invalid
    // URNs.
    invalidUrns.add(urnWithoutValuesBuilder.toString());

    // Create a URN with a space before the next character.
    StringBuilder urnWithSpaceBuilder = new StringBuilder(urnBuilder);
    urnWithSpaceBuilder.append(" c");
    invalidUrns.add(urnWithSpaceBuilder.toString());

    // Append a new segment onto the end just to be sure that it isn't only
    // checking the last segment for a space.
    urnWithSpaceBuilder.append(":d");
    invalidUrns.add(urnWithSpaceBuilder.toString());

    // Create a URN with a space within its character string.
    urnWithSpaceBuilder = new StringBuilder(urnBuilder);
    urnWithSpaceBuilder.append("c c");
    invalidUrns.add(urnWithSpaceBuilder.toString());

    // Append a new segment onto the end just to be sure that it isn't only
    // checking the last segment for a space.
    urnWithSpaceBuilder.append(":d");
    invalidUrns.add(urnWithSpaceBuilder.toString());

    // Create a URN with a '#' before the next character.
    StringBuilder urnWithInvalidCharacterBuilder = new StringBuilder(urnBuilder);
    urnWithInvalidCharacterBuilder.append("#c");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());

    // Append a new segment onto the end just to be sure that it isn't only
    // checking the last segment for invalid characters.
    urnWithInvalidCharacterBuilder.append(":d");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());

    // Create a URN with a '#' within its character string.
    urnWithInvalidCharacterBuilder = new StringBuilder(urnBuilder);
    urnWithInvalidCharacterBuilder.append("c#c");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());

    // Append a new segment onto the end just to be sure that it isn't only
    // checking the last segment for invalid characters.
    urnWithInvalidCharacterBuilder.append(":d");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());

    System.out.println("Valid URNs generated:");
    for (String validUrn : validUrns) {
      System.out.println("\t" + validUrn);
    }
    System.out.println();

    System.out.println("Invalid URNs generated:");
    for (String invalidUrn : invalidUrns) {
      System.out.println("\t" + invalidUrn);
    }
    System.out.println();

    // Now, initialize all of the URN lists.
    initUrnLists();

    // Now, initialize all of the URN-role lists.
    initUrnRoleLists();
  }
/**
   * Populates the valid and invalid URN collections with all of the valid and
   * invalid URN values that we will use for testing.
   */
Populates the valid and invalid URN collections with all of the valid and
invalid URN values that we will use for testing.
Populates the valid and invalid URN collections with all of the valid and invalid URN values that we will use for testing .
private static void initUrnValues() {
    StringBuilder urnBuilder = new StringBuilder("urn:");
    invalidUrns.add(urnBuilder.toString());
    StringBuilder urnWithoutValuesBuilder = new StringBuilder(urnBuilder);
    for (int i = 1; i < StringUtils.NUM_URN_SEGMENTS; i++) {
      urnBuilder.append('a');
      if (i == (StringUtils.NUM_URN_SEGMENTS - 1)) {
        validUrns.add(urnBuilder.toString());
      } 
      else {
        invalidUrns.add(urnBuilder.toString());
      }
      urnBuilder.append(':');
      urnWithoutValuesBuilder.append(':');
      invalidUrns.add(urnBuilder.toString());
    }
    invalidUrns.add(urnWithoutValuesBuilder.toString());
    StringBuilder urnWithSpaceBuilder = new StringBuilder(urnBuilder);
    urnWithSpaceBuilder.append(" c");
    invalidUrns.add(urnWithSpaceBuilder.toString());
    urnWithSpaceBuilder.append(":d");
    invalidUrns.add(urnWithSpaceBuilder.toString());
    urnWithSpaceBuilder = new StringBuilder(urnBuilder);
    urnWithSpaceBuilder.append("c c");
    invalidUrns.add(urnWithSpaceBuilder.toString());
    urnWithSpaceBuilder.append(":d");
    invalidUrns.add(urnWithSpaceBuilder.toString());
    StringBuilder urnWithInvalidCharacterBuilder = new StringBuilder(urnBuilder);
    urnWithInvalidCharacterBuilder.append("#c");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());
    urnWithInvalidCharacterBuilder.append(":d");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());
    urnWithInvalidCharacterBuilder = new StringBuilder(urnBuilder);
    urnWithInvalidCharacterBuilder.append("c#c");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());
    urnWithInvalidCharacterBuilder.append(":d");
    invalidUrns.add(urnWithInvalidCharacterBuilder.toString());
    System.out.println("Valid URNs generated:");
    for (String validUrn : validUrns) {
      System.out.println("\t" + validUrn);
    }
    System.out.println();
    System.out.println("Invalid URNs generated:");
    for (String invalidUrn : invalidUrns) {
      System.out.println("\t" + invalidUrn);
    }
    System.out.println();
    initUrnLists();
    initUrnRoleLists();
  }
private static void initUrnValues ( ) { StringBuilder urnBuilder = new StringBuilder ( "urn:" ) ; invalidUrns . add ( urnBuilder . toString ( ) ) ; StringBuilder urnWithoutValuesBuilder = new StringBuilder ( urnBuilder ) ; for ( int i = 1 ; i < StringUtils . NUM_URN_SEGMENTS ; i ++ ) { urnBuilder . append ( 'a' ) ; if ( i == ( StringUtils . NUM_URN_SEGMENTS - 1 ) ) { validUrns . add ( urnBuilder . toString ( ) ) ; } else { invalidUrns . add ( urnBuilder . toString ( ) ) ; } urnBuilder . append ( ':' ) ; urnWithoutValuesBuilder . append ( ':' ) ; invalidUrns . add ( urnBuilder . toString ( ) ) ; } invalidUrns . add ( urnWithoutValuesBuilder . toString ( ) ) ; StringBuilder urnWithSpaceBuilder = new StringBuilder ( urnBuilder ) ; urnWithSpaceBuilder . append ( " c" ) ; invalidUrns . add ( urnWithSpaceBuilder . toString ( ) ) ; urnWithSpaceBuilder . append ( ":d" ) ; invalidUrns . add ( urnWithSpaceBuilder . toString ( ) ) ; urnWithSpaceBuilder = new StringBuilder ( urnBuilder ) ; urnWithSpaceBuilder . append ( "c c" ) ; invalidUrns . add ( urnWithSpaceBuilder . toString ( ) ) ; urnWithSpaceBuilder . append ( ":d" ) ; invalidUrns . add ( urnWithSpaceBuilder . toString ( ) ) ; StringBuilder urnWithInvalidCharacterBuilder = new StringBuilder ( urnBuilder ) ; urnWithInvalidCharacterBuilder . append ( "#c" ) ; invalidUrns . add ( urnWithInvalidCharacterBuilder . toString ( ) ) ; urnWithInvalidCharacterBuilder . append ( ":d" ) ; invalidUrns . add ( urnWithInvalidCharacterBuilder . toString ( ) ) ; urnWithInvalidCharacterBuilder = new StringBuilder ( urnBuilder ) ; urnWithInvalidCharacterBuilder . append ( "c#c" ) ; invalidUrns . add ( urnWithInvalidCharacterBuilder . toString ( ) ) ; urnWithInvalidCharacterBuilder . append ( ":d" ) ; invalidUrns . add ( urnWithInvalidCharacterBuilder . toString ( ) ) ; System . out . println ( "Valid URNs generated:" ) ; for ( String validUrn : validUrns ) { System . out . println ( "\t" + validUrn ) ; } System . out . println ( ) ; System . out . println ( "Invalid URNs generated:" ) ; for ( String invalidUrn : invalidUrns ) { System . out . println ( "\t" + invalidUrn ) ; } System . out . println ( ) ; initUrnLists ( ) ; initUrnRoleLists ( ) ; }
Populates the valid and invalid URN collections with all of the valid and
 invalid URN values that we will use for testing.
Populates the valid and invalid URN collections with all of the valid and invalid URN values that we will use for testing .
// This will build a URN of the minimum length and ending with a colon. // This will build a URN of the minimum length but without any values. // Compose both URN builders. // Add the dummy character. // If this is the final segment, add it to the collection of good // URNs. // Otherwise, add it to the collection of bad URNs as it is still  // not long enough. // Add the dividor. // No matter the length, no URN may end with a dividor character. // Now, we have a URN builder with the exact number of characters and // ending with a dividor character and ready to be cloned to create new // valid or invalid URNs. // For the URN builder with no values, add it to the list of invalid // URNs. // Create a URN with a space before the next character. // Append a new segment onto the end just to be sure that it isn't only // checking the last segment for a space. // Create a URN with a space within its character string. // Append a new segment onto the end just to be sure that it isn't only // checking the last segment for a space. // Create a URN with a '#' before the next character. // Append a new segment onto the end just to be sure that it isn't only // checking the last segment for invalid characters. // Create a URN with a '#' within its character string. // Append a new segment onto the end just to be sure that it isn't only // checking the last segment for invalid characters. // Now, initialize all of the URN lists. // Now, initialize all of the URN-role lists.