org.jamon
Class JUnitTemplateManager
java.lang.Object
org.jamon.JUnitTemplateManager
- All Implemented Interfaces:
- InvocationHandler, TemplateManager
public class JUnitTemplateManager
- extends Object
- implements TemplateManager, InvocationHandler
A TemplateManager implementation suitable for use in
constructing unit tests via JUnit.
A JUnitTemplateManager instance is not reusable, but
instead allows the "rendering" of the one template specified at
construction. For example, suppose the /com/bar/FooTemplate
is declared as follows:
<%args>
int x;
String s => "hello";
</%args>
To test that the method showPage() attempts to render
the FooTemplate with arguements 7 and
"bye", use something like the following code:
Map optArgs = new HashMap();
optArgs.put("s", "bye");
JUnitTemplateManager jtm =
new JUnitTemplateManager("/com/bar/FooTemplate",
optArgs,
new Object[] { new Integer(7) });
TemplateManagerSource.setTemplateManager(jtm);
someObj.showPage();
assertTrue(jtm.getWasRendered());
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JUnitTemplateManager
public JUnitTemplateManager(String p_path,
Map<String,Object> p_optionalArgs,
Object[] p_requiredArgs)
- Construct a
JUnitTemplateManager.
- Parameters:
p_path - the template pathp_optionalArgs - the expect optional argumentsp_requiredArgs - the expected required argument values
JUnitTemplateManager
public JUnitTemplateManager(Class<? extends AbstractTemplateProxy> p_class,
Map<String,Object> p_optionalArgs,
Object[] p_requiredArgs)
- Construct a
JUnitTemplateManager.
- Parameters:
p_class - the template classp_optionalArgs - the expect optional argumentsp_requiredArgs - the expected required argument values
getWasRendered
public boolean getWasRendered()
- Determine if the template was successfully "rendered".
- Returns:
- whether the specified template was rendered with the
specified arguments
constructImpl
public AbstractTemplateProxy.Intf constructImpl(AbstractTemplateProxy p_proxy)
- Description copied from interface:
TemplateManager
- Given a proxy, return an instance of the executable code for
that proxy's template.
- Specified by:
constructImpl in interface TemplateManager
- Parameters:
p_proxy - a proxy for the template
- Returns:
- a
Template instance
constructProxy
public AbstractTemplateProxy constructProxy(String p_path)
- Description copied from interface:
TemplateManager
- Given a template path, return a proxy for that template.
- Specified by:
constructProxy in interface TemplateManager
- Parameters:
p_path - the path to the template
- Returns:
- a
Template instance
invoke
public Object invoke(Object p_proxy,
Method p_method,
Object[] p_args)
throws Throwable
- Specified by:
invoke in interface InvocationHandler
- Throws:
Throwable