added unit test for freemarker template

This commit is contained in:
Sebastian Sdorra
2012-08-18 12:24:47 +02:00
parent 1a479c4a98
commit 60bfabfe4b
3 changed files with 160 additions and 28 deletions

View File

@@ -36,47 +36,25 @@ package sonia.scm.template;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.google.common.collect.Maps;
import org.junit.Test;
import static org.junit.Assert.*;
//~--- JDK imports ------------------------------------------------------------
import java.io.StringWriter;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
*/
public class MustacheTemplateTest
public class MustacheTemplateTest extends TemplateTestBase
{
/**
* Method description
*
*
* @return
*/
@Test
public void testRender()
@Override
public Template getTemplate()
{
DefaultMustacheFactory factory = new DefaultMustacheFactory();
Mustache mustache = factory.compile("sonia/scm/template/001.mustache");
MustacheTemplate template =
new MustacheTemplate("/sonia/scm/template/001.mustache", mustache);
Map<String, String> env = Maps.newHashMap();
env.put("name", "marvin");
StringWriter writer = new StringWriter();
template.execute(writer, env);
assertEquals("Hello marvin!", writer.toString());
return new MustacheTemplate("sonia/scm/template/001.mustache", mustache);
}
}