use of org.beetl.core.User in project beetl2.0 by javamonkey.
the class CommentTypeTest method testTypel.
@Test
public void testTypel() throws Exception {
User user = User.getTestUser();
List list = User.getTestUsers();
Template t = gt.getTemplate("/type/commenttype_template.html");
this.bind(t, "me", user, "list", list);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/commenttype_expected.html"), str);
t = gt.getTemplate("/type/commenttype_template.html");
this.bind(t, "me", user, "list", list);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/commenttype_expected.html"), str);
}
use of org.beetl.core.User in project beetl2.0 by javamonkey.
the class DynamicTest method testDynamicUser.
@Test
public void testDynamicUser() throws Exception {
Map map = new HashMap();
map.put("name", "joelli");
map.put("age", 36);
Template t = gt.getTemplate("/type/dynamic_user_template.html");
this.bind(t, "user", map);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_user_expected.html"), str);
User user = User.getTestUser();
t = gt.getTemplate("/type/dynamic_user_template.html");
this.bind(t, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_user_expected.html"), str);
}
use of org.beetl.core.User in project beetl2.0 by javamonkey.
the class SimpleVATest method testMapAttribute.
@Test
public void testMapAttribute() throws Exception {
User user = User.getTestUser();
Map map = new HashMap();
map.put("name", "joelli");
map.put("salary", 10000.01);
Template t = gt.getTemplate("/va/va_map_template.html");
this.bind(t, "user", user, "map", map);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_map_expected.html"), str);
t = gt.getTemplate("/va/va_map_template.html");
this.bind(t, "user", user, "map", map);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_map_expected.html"), str);
}
use of org.beetl.core.User in project beetl2.0 by javamonkey.
the class VirtualAttributeTest method testVirtualClasAttribute.
@Test
public void testVirtualClasAttribute() throws Exception {
gt.registerVirtualAttributeClass(User.class, new VirtualClassAttribute() {
@Override
public String eval(Object o, String attributeName, Context ctx) {
User user = (User) o;
if (user.getAge() < 10) {
return "young";
} else {
return "old";
}
}
});
List list = User.getTestUsers();
User user = User.getTestUser();
Template t = gt.getTemplate("/va/class_virtual_template.html");
this.bind(t, "list", list, "user", user);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/class_virtual_expected.html"), str);
t = gt.getTemplate("/va/class_virtual_template.html");
this.bind(t, "list", list, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/class_virtual_expected.html"), str);
}
use of org.beetl.core.User 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);
}
Aggregations