    1   package groovy.text;
    2
    3   import java.util.HashMap;
    4   import java.util.Map;
    5
    6   import junit.framework.TestCase;
    7
    8   public class XmlTemplateEngineTest extends TestCase {
    9
    10      public void testBinding() throws Exception {
    11          Map binding = new HashMap();
    12          binding.put("Christian", "Stein");
    13
    14          XmlTemplateEngine xmlTemplateEngine = new XmlTemplateEngine();
    15          String xmlScript = "<!-- Just a comment. -->\n" //
    16                  + "<xml xmlns:gsp=\"http://groovy.codehaus.org/2005/gsp\">" //
    17                  + "  ${Christian}" //
    18                  + "  <gsp:expression>Christian</gsp:expression>" //
    19                  + "  <gsp:scriptlet>println Christian</gsp:scriptlet>" //
    20                  + "</xml>";
    21          String xmlResult = "<xml>\n" //
    22                  + "  Stein\n" //
    23                  + xmlTemplateEngine.getIndention() + "Stein\n" //
    24                  + "Stein" + System.getProperty("line.separator") //
    25                  + "</xml>\n";
    26          Template template = xmlTemplateEngine.createTemplate(xmlScript);
    27          assertEquals(xmlResult, template.make(binding).toString());
    28      }
    29
    30  }