Search in sources :

Example 71 with Template

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

the class PairDLTest method testSimple.

@Test
public void testSimple() throws Exception {
    GroupTemplate newGt = getGt();
    Template t = newGt.getTemplate("/text/simple_pair_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/text/simple_pair_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 72 with Template

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

the class SingleDLTest method testSimple.

@Test
public void testSimple() throws Exception {
    GroupTemplate newGt = getGt();
    Template t = newGt.getTemplate("/text/single_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/text/single_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 73 with Template

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

the class DynamicTest method testDynamicUser2.

@Test
public void testDynamicUser2() throws Exception {
    /*语法兼容1.x*/
    Map map = new HashMap();
    map.put("name", "joelli");
    map.put("age", 36);
    Template t = gt.getTemplate("/type/dynamic_user2_template.html");
    this.bind(t, "user", map);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_user2_expected.html"), str);
    User user = User.getTestUser();
    t = gt.getTemplate("/type/dynamic_user2_template.html");
    this.bind(t, "user", user);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_user2_expected.html"), str);
}
Also used : User(org.beetl.core.User) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 74 with Template

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

the class DynamicTest method testDynamicAll.

@Test
public void testDynamicAll() throws Exception {
    Map map = new HashMap();
    map.put("name", "joelli");
    map.put("age", 36);
    Template t = gt.getTemplate("/type/dynamic_all_template.html");
    this.bind(t, "user", map);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_all_expected.html"), str);
    User user = User.getTestUser();
    t = gt.getTemplate("/type/dynamic_all_template.html");
    this.bind(t, "user", user);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_all_expected.html"), str);
}
Also used : User(org.beetl.core.User) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 75 with Template

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

the class SimpleVATest method testUserAttribute.

@Test
public void testUserAttribute() throws Exception {
    User user = User.getTestUser();
    Template t = gt.getTemplate("/va/va_simple_template.html");
    this.bind(t, "user", user);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/va/va_simple_expected.html"), str);
    t = gt.getTemplate("/va/va_simple_template.html");
    this.bind(t, "user", user);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/va/va_simple_expected.html"), str);
}
Also used : User(org.beetl.core.User) 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