Search in sources :

Example 96 with Template

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

the class SetTest method testArrayMap.

@Test
public void testArrayMap() throws Exception {
    Template t = gt.getTemplate("/exp/set_template.html");
    int[] c = new int[] { 1, 2 };
    int[][] d = new int[][] { { 1, 2 }, { 3, 4 } };
    t.binding("c", c);
    t.binding("d", d);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/exp/set_expected.html"), str);
    t = gt.getTemplate("/exp/set_template.html");
    t.binding("c", c);
    t.binding("d", d);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/exp/set_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 97 with Template

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

the class SetTest method testPojo.

@Test
public void testPojo() throws Exception {
    Template t = gt.getTemplate("/exp/set_pojo_template.html");
    User user = new User("joelli");
    User lover = new User("lucymiao");
    t.binding("user", user);
    t.binding("lover", lover);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/exp/set_pojo_expected.html"), str);
    t = gt.getTemplate("/exp/set_pojo_template.html");
    t.binding("user", user);
    t.binding("lover", lover);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/exp/set_pojo_expected.html"), str);
}
Also used : User(org.beetl.core.User) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 98 with Template

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

the class TernaryTest method testId.

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

Example 99 with Template

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

the class FileFunctionTest method testFileFunctionRetrun.

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

Example 100 with Template

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

the class FileFunctionTest method testRecurFileFunctionRetrun.

@Test
public void testRecurFileFunctionRetrun() throws Exception {
    Template t = gt.getTemplate("/function/file_recur_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/file_recur_expected.html"), str);
    t = gt.getTemplate("/function/file_recur_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/file_recur_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