protected void renderResponse() throws Exception {
DocumentHome docHome = (DocumentHome)getInstance(DocumentHome.class);
assert docHome.getInstance().getId().equals(6l); // Init!
WikiDocument doc = docHome.getInstance();
// Header
doc.setHeader("[<=testMacro1[param1=value1]]\n[<=testMacro2]\nfoo");
docHome.syncMacros(doc);
assert doc.getHeaderMacros().size() == 2;
assert doc.getHeaderMacrosString().contains("testMacro1");
assert doc.getHeaderMacrosString().contains("testMacro2");
assert doc.getHeader().contains("[<=testMacro1[param1=value1]]\n");
assert doc.getHeader().contains("[<=testMacro2]\n");
assert doc.getHeader().indexOf("foo") == doc.getHeader().length()-3;
doc.removeHeaderMacros("testMacro1");
WikiTextMacro replacement = new WikiTextMacro("testMacro3");
replacement.getParams().put("p1", "value1");
replacement.getParams().put("p2", "value2");
doc.addHeaderMacro(replacement);
assert doc.getHeaderMacros().size() == 2;
assert doc.getHeaderMacrosString().contains("testMacro3");
assert doc.getHeaderMacrosString().contains("testMacro2");
assert doc.getHeader().contains("[<=testMacro3[p1=value1][p2=value2]]\n");
assert doc.getHeader().contains("[<=testMacro2]\n");
assert doc.getHeader().indexOf("foo") == doc.getHeader().length()-3;
}
}.run();