public void test() throws ResourceNotFoundException, IOException, ParseException, ScriptRuntimeException {
Map<String, String> templates = collectAutoTestTemplates();
ClassLoader classLoader = ClassUtil.getDefaultClassLoader();
final ByteArrayOutputStream bytesBuffer = new ByteArrayOutputStream();
final byte[] buffer = new byte[BUFFER_SIZE];
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (Map.Entry<String, String> entry : templates.entrySet()) {
String templatePath = entry.getKey();
String outPath = entry.getValue();
if (outPath != null) {
out.reset();
mergeTemplate(templatePath, out);
//read outNotNull
InputStream in;
if ((in = classLoader.getResourceAsStream(AUTO_TEST_PATH.concat(outPath))) != null) {
int read;
bytesBuffer.reset();
while ((read = in.read(buffer, 0, BUFFER_SIZE)) >= 0) {
bytesBuffer.write(buffer, 0, read);
}
assertArrayEquals(bytesBuffer.toArray(), out.toArray());
System.out.println("\tresult match to: " + outPath);
bytesBuffer.reset();
}
out.reset();
} else {
mergeTemplate(templatePath, new DiscardOut());
}
}
}