use of beast.util.JSONParser in project beast2 by CompEvol.
the class ExampleJSONParsingTest method test_ThatJSONExamplesParse.
public void test_ThatJSONExamplesParse(String dir) {
try {
Randomizer.setSeed(127);
Logger.FILE_MODE = Logger.LogFileMode.overwrite;
System.out.println("Test JSON Examples in " + dir);
File exampleDir = new File(dir);
String[] exampleFiles = exampleDir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".json");
}
});
List<String> failedFiles = new ArrayList<String>();
for (String fileName : exampleFiles) {
System.out.println("Processing " + fileName);
JSONParser parser = new JSONParser();
try {
parser.parseFile(new File(dir + "/" + fileName));
} catch (Exception e) {
System.out.println("ExampleJSONParsing::Failed for " + fileName + ": " + e.getMessage());
failedFiles.add(fileName);
}
System.out.println("Done " + fileName);
}
if (failedFiles.size() > 0) {
System.out.println("\ntest_ThatJSONExamplesParse::Failed for : " + failedFiles.toString());
} else {
System.out.println("\ntest_ThatJSONExamplesParse::Success");
}
assertTrue(failedFiles.toString(), failedFiles.size() == 0);
} catch (Exception e) {
System.out.println("exception thrown ");
System.out.println(e.getMessage());
}
}
Aggregations