use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class NativeTest method testObjectReturn.
@Test
public void testObjectReturn() throws Exception {
NativeTest test = new NativeTest();
Template t = gt.getTemplate("/nat/object_template.html");
this.bind(t, "test", test);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/object_expected.html"), str);
t = gt.getTemplate("/nat/object_template.html");
this.bind(t, "test", test);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/object_expected.html"), str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class NativeTest method testPrivateMethodCall.
@Test
public void testPrivateMethodCall() throws Exception {
Template t = gt.getTemplate("/nat/nat_private_method_template.html");
this.bind(t, "test", Request.getRequest());
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/nat_private_method_expected.html"), str);
t = gt.getTemplate("/nat/nat_private_method_template.html");
this.bind(t, "test", Request.getRequest());
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/nat_private_method_expected.html"), str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class CompositeResourceLoaderTest method testSimple.
@Test
public void testSimple() throws Exception {
Configuration conf = Configuration.defaultConfiguration();
CompositeResourceLoader loader = new CompositeResourceLoader();
String home = System.getProperty("user.dir");
String path1 = home + "/src/test/resources/template/resourceloader/var1";
String path2 = home + "/src/test/resources/template/resourceloader/var2";
FileResourceLoader fileLoader1 = new FileResourceLoader(path1);
FileResourceLoader fileLoader2 = new FileResourceLoader(path2);
Map data = getData();
// 根据id加载
MapResourceLoader mapLoader = new MapResourceLoader(data);
loader.addResourceLoader(new StartsWithMatcher("http:").withoutPrefix(), fileLoader2);
loader.addResourceLoader(new StartsWithMatcher("db:").withoutPrefix(), mapLoader);
loader.addResourceLoader(new AllowAllMatcher(), fileLoader1);
GroupTemplate gt = new GroupTemplate(loader, conf);
Template t = gt.getTemplate("/xxx.html");
t.binding("a", "hello");
String result = t.render();
;
AssertJUnit.assertEquals("hellohello--file2:hello--db=hello", result);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class JsonTest method testSimple.
@Test
public void testSimple() throws Exception {
Template t = gt.getTemplate("/exp/json/json_template.html");
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/exp/json/json_expected.html"), str);
t = gt.getTemplate("/exp/json/json_template.html");
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/exp/json/json_expected.html"), str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class PriorityTest method testAll.
@Test
public void testAll() throws Exception {
Template t = gt.getTemplate("/exp/priority_all_template.html");
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/exp/priority_all_expected.html"), str);
t = gt.getTemplate("/exp/priority_all_template.html");
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/exp/priority_all_expected.html"), str);
}
Aggregations