Ejemplo n.º 1
0
  private void _testHtmls(String root) throws IOException {
    FindFile ff = new WildcardFindFile().include("**/*.*ml");
    long reps = 1;
    JStopWatch jsw = new JStopWatch();
    boolean processed = false;
    while (reps-- > 0) {
      ff.searchPath(root);
      File file;
      while ((file = ff.nextFile()) != null) {
        processed = true;
        System.out.println('+' + file.getName());

        String content = FileUtil.readString(file);
        String expectedResult = FileUtil.readString(new File(file.getAbsolutePath() + ".txt"));

        String formatted = null;
        File formattedFile = new File(file.getAbsolutePath() + "-fmt.htm");
        if (formattedFile.exists()) {
          formatted = FileUtil.readString(formattedFile);
        }

        boolean isXml = file.getName().endsWith(".xml");

        String[] results = _parse(content, isXml);
        String result = results[0]; // parsing result
        String result2 = results[1]; // tag writer

        expectedResult = StringUtil.removeChars(expectedResult, '\r');
        result = StringUtil.removeChars(result, '\r').trim();

        assertEquals(expectedResult, result);

        if (formatted != null) {
          assertEquals(formatted, result2);
        } else {
          assertEquals(content, result2);
        }
      }
    }
    assertTrue(processed);
    System.out.println(jsw);
  }
Ejemplo n.º 2
0
 /** 13s */
 @Test
 public void testLiveHtmls() throws IOException {
   FindFile ff = new WildcardFindFile().include("**/*.html");
   ff.searchPath(testLiveRoot);
   File file;
   boolean processed = false;
   while ((file = ff.nextFile()) != null) {
     processed = true;
     String name = file.getName();
     System.out.println('+' + name);
     String content = FileUtil.readString(file);
     try {
       _parseEmpty(content);
     } catch (Exception ex) {
       ex.printStackTrace();
       fail(ex.toString());
     }
   }
   assertTrue(processed);
 }