### Question:
GroovyTemplateProcessor implements TemplateProcessor { public Source processTemplate(Source template, Source input, Map<String, Object> parameters) { try { String templateText = serialize(template); HashMap<String, Object> binding = new HashMap<String, Object> (parameters); if (input!=null) { Document inputDocument = loadDocument(input); binding.put(inputDocument.getFirstChild().getLocalName(), new XmlSlurper().parse(new StringReader(serialize(inputDocument)))); } binding.put("IGNORE", "${IGNORE}"); return new StringSource(templateEngine.createTemplate(templateText).make(binding).toString()); } catch (Exception e) { throw new IllegalArgumentException("Can not process Groovy template.",e); } } GroovyTemplateProcessor(TemplateEngine templateEngine);  GroovyTemplateProcessor(); Source processTemplate(Source template, Source input, Map<String, Object> parameters);  }### Answer:
@Test public void testSimple() throws SAXException, IOException { GroovyTemplateProcessor processor = new GroovyTemplateProcessor(); Source template = new StringSource("<a>$value</a>"); Source result = processor.processTemplate(template, null, singletonMap("value", (Object)"test")); assertXMLEqual("<a>test</a>", serialize(result)); }
@Test public void testIgnore() throws SAXException, IOException { GroovyTemplateProcessor processor = new GroovyTemplateProcessor(); Source template = new StringSource("<a>$value<b>${IGNORE}</b></a>"); Source result = processor.processTemplate(template, null, singletonMap("value", (Object)"test")); assertXMLEqual("<a>test<b>${IGNORE}</b></a>", serialize(result)); }
@Test public void testWithRequest() throws SAXException, IOException { GroovyTemplateProcessor processor = new GroovyTemplateProcessor(); Source template = new StringSource("<a>$value $requestB.b</a>"); Source request = new StringSource("<requestB xmlns:ns=\"http: Source result = processor.processTemplate(template, request, singletonMap("value", (Object)"test")); assertXMLEqual("<a>test 2</a>", serialize(result)); }