added test for defect templates

This commit is contained in:
Sebastian Sdorra
2012-08-18 13:20:41 +02:00
parent 60bfabfe4b
commit e9aa46473b
5 changed files with 109 additions and 9 deletions

View File

@@ -59,7 +59,17 @@ public abstract class TemplateTestBase
*
* @return
*/
public abstract Template getTemplate() throws IOException;
public abstract Template getFailureTemplate() throws IOException;
/**
* Method description
*
*
* @return
*
* @throws IOException
*/
public abstract Template getHelloTemplate() throws IOException;
//~--- methods --------------------------------------------------------------
@@ -72,8 +82,37 @@ public abstract class TemplateTestBase
@Test
public void testRender() throws IOException
{
Template template = getTemplate();
Template template = getHelloTemplate();
assertEquals("Hello marvin!", execute(template));
}
/**
* Method description
*
*
* @throws IOException
*/
@Test(expected = IOException.class)
public void testRenderFailure() throws IOException
{
Template template = getFailureTemplate();
execute(template);
}
/**
* Method description
*
*
* @param template
*
* @return
*
* @throws IOException
*/
private String execute(Template template) throws IOException
{
Map<String, String> env = Maps.newHashMap();
env.put("name", "marvin");
@@ -82,6 +121,6 @@ public abstract class TemplateTestBase
template.execute(writer, env);
assertEquals("Hello marvin!", writer.toString());
return writer.toString();
}
}