Search in sources :

Example 21 with Template

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

the class SafeOutputTest method testSimple.

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

Example 22 with Template

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

the class SafeOutputTest method testSafeExp.

@Test
public void testSafeExp() throws Exception {
    Template t = gt.getTemplate("/safe/safe_exp_template.html");
    t.binding("test", new User("joel"));
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/safe/safe_exp_expected.html"), str);
    t = gt.getTemplate("/safe/safe_exp_template.html");
    t.binding("test", new User("joel"));
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/safe/safe_exp_expected.html"), str);
}
Also used : User(org.beetl.core.User) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 23 with Template

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

the class DeleteTagTest method testDeleteTag.

@Test
public void testDeleteTag() throws Exception {
    User user = User.getTestUser();
    Template t = gt.getTemplate("/tag/delete_template.html");
    this.bind(t, "user", user);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/delete_expected.html"), str);
    t = gt.getTemplate("/tag/delete_template.html");
    this.bind(t, "user", user);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/delete_expected.html"), str);
}
Also used : User(org.beetl.core.User) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 24 with Template

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

the class HtmlTagTest method testHtmlTag.

@Test
public void testHtmlTag() throws Exception {
    Template t = gt.getTemplate("/tag/html_template.html");
    this.bind(t, "list", User.getTestUsers());
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html_expected.html"), str);
    t = gt.getTemplate("/tag/html_template.html");
    this.bind(t, "list", User.getTestUsers());
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 25 with Template

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

the class HtmlTagTest method testEmptyTag.

@Test
public void testEmptyTag() throws Exception {
    Template t = gt.getTemplate("/tag/html4_template.html");
    this.bind(t, "list", User.getTestUsers());
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html4_expected.html"), str);
    t = gt.getTemplate("/tag/html4_template.html");
    this.bind(t, "list", User.getTestUsers());
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html4_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