use of org.apache.struts2.components.template.TemplateEngineManager in project struts by apache.
the class TemplateEngineManagerTest method setUp.
public void setUp() throws Exception {
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("ftl")), new FreemarkerTemplateEngine());
mockContainer.matchAndReturn("getInstanceNames", C.args(C.eq(TemplateEngine.class)), new HashSet<String>() {
{
add("jsp");
add("vm");
add("ftl");
}
});
mgr.setContainer((Container) mockContainer.proxy());
mgr.setDefaultTemplateType("jsp");
}
use of org.apache.struts2.components.template.TemplateEngineManager in project struts by apache.
the class VelocityTemplateEngineTest method setUp.
public void setUp() throws Exception {
super.setUp();
mgr = new TemplateEngineManager();
Mock 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<String>() {
{
add("jsp");
add("vm");
add("ftl");
}
});
mgr.setContainer((Container) mockContainer.proxy());
mgr.setDefaultTemplateType("jsp");
}
use of org.apache.struts2.components.template.TemplateEngineManager in project struts by apache.
the class UIBeanTest method testMergeTemplateNullEngineException.
public void testMergeTemplateNullEngineException() {
ValueStack stack = ActionContext.getContext().getValueStack();
MockHttpServletRequest req = new MockHttpServletRequest();
MockHttpServletResponse res = new MockHttpServletResponse();
// templateEngineManager that returns null as TemplateEngine
TemplateEngineManager templateEngineManager = new TemplateEngineManager() {
public TemplateEngine getTemplateEngine(Template template, String templateTypeOverride) {
return null;
}
};
TextField txtFld = new TextField(stack, req, res);
txtFld.setTemplateEngineManager(templateEngineManager);
try {
txtFld.mergeTemplate(null, new Template(null, null, null));
fail("Exception not thrown");
} catch (final Exception e) {
assertTrue(e instanceof ConfigurationException);
}
}
Aggregations