@Test
public void escape_directive_macros() throws Exception {
getEngine("with_escape", factory);
TemplateContext ctx = new MappedTemplateContext();
ctx.put("count", new Counter());
ctx.put("object", new MyRenderable("<world name=\"'中国'\" />"));
String content = templateService.getText("escape/test_escape_macros.vm", ctx);
// noescape
assertThat(content, containsString("1. <world name=\"'中国'\" />"));
// java
assertThat(content, containsString("2. <world name=\\\"'中国'\\\" />"));
// javascript/js
assertThat(content, containsString("3. <world name=\\\"\\'中国\\'\\\" \\/>"));
assertThat(content, containsString("4. <world name=\\\"\\'中国\\'\\\" \\/>"));
// html
assertThat(content, containsString("5. <world name="'中国'" />"));
// xml
assertThat(content, containsString("6. <world name="'中国'" />"));
// url
assertThat(content, containsString("7. %3Cworld+name%3D%22'%D6%D0%B9%FA'%22+%2F%3E"));
// sql
assertThat(content, containsString("8. <world name=\"''中国''\" />"));
assertFalse(ctx.containsKey("_ESCAPE_SUPPORT_TYPE_"));
}