Search in sources :

Example 41 with Template

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

the class FunctionTest method testCore.

@Test
public void testCore() throws Exception {
    Map map = new HashMap();
    map.put("a", "hi");
    map.put("b", 1);
    Template t = gt.getTemplate("/function/function_template.html");
    t.binding(map);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/function_expected.html"), str);
    t = gt.getTemplate("/function/function_template.html");
    t.binding(map);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/function_expected.html"), str);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 42 with Template

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

the class FunctionTest method testPackage.

public void testPackage() throws Exception {
    gt.registerFunctionPackage("test", new SampleFunctionPackage());
    Template t = gt.getTemplate("/function/function_package_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/function_package_expected.html"), str);
    t = gt.getTemplate("/function/function_package_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/function_package_expected.html"), str);
}
Also used : Template(org.beetl.core.Template)

Example 43 with Template

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

the class FunctionTest method testMutilContext.

public void testMutilContext() throws Exception {
    gt.registerFunctionPackage("test", new SampleFunctionPackage());
    Template t = gt.getTemplate("/function/context_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/context_expected.html"), str);
    t = gt.getTemplate("/function/context_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/context_expected.html"), str);
}
Also used : Template(org.beetl.core.Template)

Example 44 with Template

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

the class GoTest method testContinue.

@Test
public void testContinue() throws Exception {
    Template t = gt.getTemplate("/control/go/continue_template.html");
    this.bind(t, "dataList", data);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/control/go/continue_expected.html"), str);
    t = gt.getTemplate("/control/go/continue_template.html");
    this.bind(t, "dataList", data);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/control/go/continue_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 45 with Template

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

the class GoTest method testBreak3.

@Test
public void testBreak3() throws Exception {
    Template t = gt.getTemplate("/control/go/break3_template.html");
    this.bind(t, "dataList", data);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/control/go/break3_expected.html"), str);
    t = gt.getTemplate("/control/go/break3_template.html");
    this.bind(t, "dataList", data);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/control/go/break3_expected.html"), str);
}
Also used : 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