Search in sources :

Example 1 with JStopWatch

use of jodd.datetime.JStopWatch in project jodd by oblac.

the class LagartoParserTest method _testHtmls.

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);
            content = StringUtil.removeChars(content, '\r');
            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);
            }
            if (formatted != null) {
                formatted = StringUtil.removeChars(formatted, '\r');
            }
            boolean isXml = file.getName().endsWith(".xml");
            String[] results = _parse(content, isXml);
            // parsing result
            String result = results[0];
            // tag writer
            String result2 = results[1];
            expectedResult = StringUtil.removeChars(expectedResult, '\r');
            result = StringUtil.removeChars(result, '\r').trim();
            result2 = StringUtil.removeChars(result2, '\r').trim();
            assertEquals(expectedResult, result);
            if (formatted != null) {
                assertEquals(formatted, result2);
            } else {
                assertEquals(content, result2);
            }
        }
    }
    assertTrue(processed);
    System.out.println(jsw);
}
Also used : WildcardFindFile(jodd.io.findfile.WildcardFindFile) FindFile(jodd.io.findfile.FindFile) WildcardFindFile(jodd.io.findfile.WildcardFindFile) FindFile(jodd.io.findfile.FindFile) WildcardFindFile(jodd.io.findfile.WildcardFindFile) File(java.io.File) JStopWatch(jodd.datetime.JStopWatch)

Aggregations

File (java.io.File)1 JStopWatch (jodd.datetime.JStopWatch)1 FindFile (jodd.io.findfile.FindFile)1 WildcardFindFile (jodd.io.findfile.WildcardFindFile)1