fix mustache render failure test

This commit is contained in:
Sebastian Sdorra
2012-08-18 13:40:21 +02:00
parent d619bd73da
commit 65dde22676
4 changed files with 63 additions and 4 deletions

View File

@@ -36,10 +36,14 @@ package sonia.scm.template;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.google.common.base.Function;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
@@ -73,6 +77,31 @@ public class MustacheTemplateTest extends TemplateTestBase
return getTemplate("sonia/scm/template/001.mustache");
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param env
*/
@Override
protected void prepareEnv(Map<String, Object> env)
{
env.put("test", new Function<String, String>()
{
@Override
public String apply(String input)
{
throw new UnsupportedOperationException("Not supported yet.");
}
});
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*

View File

@@ -58,6 +58,8 @@ public abstract class TemplateTestBase
*
*
* @return
*
* @throws IOException
*/
public abstract Template getFailureTemplate() throws IOException;
@@ -101,6 +103,14 @@ public abstract class TemplateTestBase
execute(template);
}
/**
* Method description
*
*
* @param env
*/
protected void prepareEnv(Map<String, Object> env) {}
/**
* Method description
*
@@ -113,10 +123,12 @@ public abstract class TemplateTestBase
*/
private String execute(Template template) throws IOException
{
Map<String, String> env = Maps.newHashMap();
Map<String, Object> env = Maps.newHashMap();
env.put("name", "marvin");
prepareEnv(env);
StringWriter writer = new StringWriter();
template.execute(writer, env);