Search in sources :

Example 86 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class ConfigTest method testSimple.

@Test
public void testSimple() throws Exception {
    Template t = gt.getTemplate("/lang/config_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/lang/config_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 87 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class Pojo2 method testSimple.

@Test
public void testSimple() throws Exception {
    Pojo p = new Pojo();
    Template t = gt.getTemplate("/lang/pojo_template.html");
    t.binding("p", p);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/lang/pojo_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 88 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class NativeTest method testSecurity.

@Test
public void testSecurity() throws Exception {
    StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
    Configuration cfg = Configuration.defaultConfiguration();
    GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
    Template t = gt.getTemplate("hello,${@java.lang.System.currentTimeMillis()}");
    String str = t.render();
    AssertJUnit.assertEquals("hello,", str);
}
Also used : Configuration(org.beetl.core.Configuration) StringTemplateResourceLoader(org.beetl.core.resource.StringTemplateResourceLoader) GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 89 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class NativeTest method testMethod.

@Test
public void testMethod() throws Exception {
    NativeTest test = new NativeTest();
    Template t = gt.getTemplate("/nat/nat_method_template.html");
    this.bind(t, "test", test);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/nat/nat_method_expected.html"), str);
    t = gt.getTemplate("/nat/nat_method_template.html");
    this.bind(t, "test", test);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/nat/nat_method_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 90 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class NativeTest method testAll.

@Test
public void testAll() throws Exception {
    NativeTest test = new NativeTest();
    Template t = gt.getTemplate("/nat/all_template.html");
    this.bind(t, "test", test);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/nat/all_expected.html"), str);
    t = gt.getTemplate("/nat/all_template.html");
    this.bind(t, "test", test);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/nat/all_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Aggregations

Template (org.beetl.core.Template)122 Test (org.testng.annotations.Test)96 GroupTemplate (org.beetl.core.GroupTemplate)41 Map (java.util.Map)15 User (org.beetl.core.User)14 HashMap (java.util.HashMap)13 Configuration (org.beetl.core.Configuration)13 FileResourceLoader (org.beetl.core.resource.FileResourceLoader)6 StringTemplateResourceLoader (org.beetl.core.resource.StringTemplateResourceLoader)6 Context (org.beetl.core.Context)5 JSONObject (com.alibaba.fastjson.JSONObject)4 List (java.util.List)4 ClasspathResourceLoader (org.beetl.core.resource.ClasspathResourceLoader)4 VirtualAttributeEval (org.beetl.core.VirtualAttributeEval)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 BodyContent (org.beetl.core.BodyContent)2 BeetlException (org.beetl.core.exception.BeetlException)2 WebRender (org.beetl.ext.web.WebRender)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1