01: package org.andromda.templateengines.freemarker;
02:
03: import java.io.StringReader;
04: import java.io.StringWriter;
05:
06: import java.util.HashMap;
07:
08: import freemarker.template.Configuration;
09: import freemarker.template.Template;
10:
11: import junit.framework.TestCase;
12:
13: /**
14: * Tests the direct interpretation of a string by FreeMarkerTemplateEngine.
15: */
16: public class FreeMarkerTemplateEngineTest extends TestCase {
17: public FreeMarkerTemplateEngineTest(String name) {
18: super (name);
19: }
20:
21: public void testDirectFreeMarker() throws Exception {
22: StringWriter writer = new StringWriter();
23:
24: // - create the template
25: Template template = new Template("strTemplate",
26: new StringReader("${test1}${test2}"),
27: new Configuration());
28:
29: HashMap templateObjects = new HashMap();
30:
31: templateObjects.put("test1", "@test1@");
32: templateObjects.put("test2", "@test2@");
33:
34: template.process(templateObjects, writer);
35: assertEquals("@test1@@test2@", writer.getBuffer().toString());
36: }
37: }
|