}
@SuppressWarnings("unchecked")
@Test
public void testTemplate() throws Exception {
Engine engine = Engine.getEngine(config);
Loader loader = engine.getProperty("loader", Loader.class);
assertEquals(MultiLoader.class, loader.getClass());
Loader[] loaders = engine.getProperty("loaders", Loader[].class);
assertEquals(ClasspathLoader.class, loaders[0].getClass());
loader = engine.getProperty("loaders", ClasspathLoader.class);
assertEquals(ClasspathLoader.class, loader.getClass());
String[] suffixes = engine.getProperty("template.suffix", new String[] { ".httl" });
List<String> list = loader.list(suffixes[0]);
assertTrue(list.size() > 0);
String dir = engine.getProperty("template.directory", "");
if (dir.length() > 0 && dir.startsWith("/")) {
dir = dir.substring(1);
}
if (dir.length() > 0 && ! dir.endsWith("/")) {
dir += "/";
}
System.out.println(config + ": " + (data == null ? "null" : data.getClass().getSimpleName()) + " => " + templateName);
String encoding = "UTF-8";
if ("gbk.httl".equals(templateName)) {
encoding = "GBK";
}
Engine _engine = engine;
if ("extends_default.httl".equals(templateName)) {
_engine = Engine.getEngine("httl-comment-extends.properties");
}
Template template = _engine.getTemplate("/templates/" + templateName, Locale.CHINA, encoding, data);
UnsafeByteArrayOutputStream actualStream = new UnsafeByteArrayOutputStream();
StringWriter actualWriter = new StringWriter();
if ("extends_var.httl".equals(templateName)) {
if (data instanceof Map) {
((Map<String, Object>) data).put("extends", "default.httl");