Package org.andromda.templateengines.freemarker

Source Code of org.andromda.templateengines.freemarker.FreeMarkerTemplateEngineTest

package org.andromda.templateengines.freemarker;

import java.io.StringReader;
import java.io.StringWriter;

import java.util.HashMap;

import freemarker.template.Configuration;
import freemarker.template.Template;

import junit.framework.TestCase;


/**
* Tests the direct interpretation of a string by FreeMarkerTemplateEngine.
*/
public class FreeMarkerTemplateEngineTest
    extends TestCase
{
    public FreeMarkerTemplateEngineTest(String name)
    {
        super(name);
    }

    public void testDirectFreeMarker()
        throws Exception
    {
        StringWriter writer = new StringWriter();

        // - create the template
        Template template = new Template("strTemplate", new StringReader("${test1}${test2}"), new Configuration());

        HashMap templateObjects = new HashMap();

        templateObjects.put(
            "test1",
            "@test1@");
        templateObjects.put(
            "test2",
            "@test2@");

        template.process(
            templateObjects,
            writer);
        assertEquals(
            "@test1@@test2@",
            writer.getBuffer().toString());
    }
}
TOP

Related Classes of org.andromda.templateengines.freemarker.FreeMarkerTemplateEngineTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.