src/test/java/org/owasp/url/FuzzUrlValue.java
public static void main(String... testFilePaths) throws IOException {
    int testCount = 0;
    for (String testFilePath : testFilePaths) {
      File testFile = new File(testFilePath);
      ByteSource bytes = Files.asByteSource(testFile);
      // Just read bytes as chars since the URL grammar is an octet-based grammar.
      CharSource chars = bytes.asCharSource(Charsets.ISO_8859_1);

      String input = chars.read();
      boolean ok = false;
      try {
        UrlValue url = UrlValue.from(input);
        url.getAuthority(Diagnostic.Receiver.NULL);
        url.getContentMediaType();
        url.getContentMetadata();
        url.getDecodedContent();
        url.getFragment();
        url.getQuery();
        url.getRawAuthority();
        url.getRawContent();
        url.getRawPath();
        ok = true;
      } finally {
        if (!ok) {
          System.err.println("Failed on `" + input + "` from " + testFilePath);
        }
      }
      testCount += 1;
    }
    System.out.println("Ran " + testCount + " tests");
    if (testCount == 0) {
      throw new Error("No tests read");
    }
  }
/**
   * @param testFilePaths paths to files containing testcases.
   */
@param testFilePaths paths to files containing testcases.
@param testFilePaths paths to files containing testcases .
public static void main(String... testFilePaths) throws IOException {
    int testCount = 0;
    for (String testFilePath : testFilePaths) {
      File testFile = new File(testFilePath);
      ByteSource bytes = Files.asByteSource(testFile);
      CharSource chars = bytes.asCharSource(Charsets.ISO_8859_1);
      String input = chars.read();
      boolean ok = false;
      try {
        UrlValue url = UrlValue.from(input);
        url.getAuthority(Diagnostic.Receiver.NULL);
        url.getContentMediaType();
        url.getContentMetadata();
        url.getDecodedContent();
        url.getFragment();
        url.getQuery();
        url.getRawAuthority();
        url.getRawContent();
        url.getRawPath();
        ok = true;
      } finally {
        if (!ok) {
          System.err.println("Failed on `" + input + "` from " + testFilePath);
        }
      }
      testCount += 1;
    }
    System.out.println("Ran " + testCount + " tests");
    if (testCount == 0) {
      throw new Error("No tests read");
    }
  }
public static void main ( String ... testFilePaths ) throws IOException { int testCount = 0 ; for ( String testFilePath : testFilePaths ) { File testFile = new File ( testFilePath ) ; ByteSource bytes = Files . asByteSource ( testFile ) ; CharSource chars = bytes . asCharSource ( Charsets . ISO_8859_1 ) ; String input = chars . read ( ) ; boolean ok = false ; try { UrlValue url = UrlValue . from ( input ) ; url . getAuthority ( Diagnostic . Receiver . NULL ) ; url . getContentMediaType ( ) ; url . getContentMetadata ( ) ; url . getDecodedContent ( ) ; url . getFragment ( ) ; url . getQuery ( ) ; url . getRawAuthority ( ) ; url . getRawContent ( ) ; url . getRawPath ( ) ; ok = true ; } finally { if ( ! ok ) { System . err . println ( "Failed on `" + input + "` from " + testFilePath ) ; } } testCount += 1 ; } System . out . println ( "Ran " + testCount + " tests" ) ; if ( testCount == 0 ) { throw new Error ( "No tests read" ) ; } }
@param testFilePaths paths to files containing testcases.
@param testFilePaths paths to files containing testcases .
// Just read bytes as chars since the URL grammar is an octet-based grammar.