TemplateEngineManagerTestpublic class TemplateEngineManagerTest extends TestCase TemplateEngineManagerTest |
Fields Summary |
---|
org.apache.struts2.components.template.TemplateEngineManager | mgr | com.mockobjects.dynamic.Mock | mockContainer |
Methods Summary |
---|
public void | setUp()
mgr = new TemplateEngineManager();
mockContainer = new Mock(Container.class);
mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("jsp")), new JspTemplateEngine());
mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("vm")), new VelocityTemplateEngine());
mockContainer.matchAndReturn("getInstance", C.args(C.eq(TemplateEngine.class), C.eq("ftl")), new FreemarkerTemplateEngine());
mockContainer.matchAndReturn("getInstanceNames", C.args(C.eq(TemplateEngine.class)), new HashSet() {{
add("jsp");
add("vm");
add("ftl");
}});
mgr.setContainer((Container)mockContainer.proxy());
mgr.setDefaultTemplateType("jsp");
| protected void | tearDown()
super.tearDown();
| public void | testTemplateTypeFromTemplateNameAndDefaults()
TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
assertTrue(engine instanceof JspTemplateEngine);
engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), null);
assertTrue(engine instanceof VelocityTemplateEngine);
| public void | testTemplateTypeOverrides()
TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), "ftl");
assertTrue(engine instanceof FreemarkerTemplateEngine);
engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.vm"), "ftl");
assertTrue(engine instanceof VelocityTemplateEngine);
engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo.ftl"), "");
assertTrue(engine instanceof FreemarkerTemplateEngine);
| public void | testTemplateTypeUsesDefaultWhenNotSetInConfiguration()
mgr.setDefaultTemplateType(null);
TemplateEngine engine = mgr.getTemplateEngine(new Template("/template", "simple", "foo"), null);
Template template = new Template("/template", "simple", "foo." + TemplateEngineManager.DEFAULT_TEMPLATE_TYPE);
TemplateEngine defaultTemplateEngine = mgr.getTemplateEngine(template, null);
assertTrue(engine.getClass().equals(defaultTemplateEngine.getClass()));
|
|