}
}
public void testComplex() throws MustacheException, IOException {
StringWriter json = new StringWriter();
MappingJsonFactory jf = new MappingJsonFactory();
final JsonGenerator jg = jf.createJsonGenerator(json);
jg.writeStartObject();
final JsonCapturer captured = new JsonCapturer(jg);
MustacheFactory c = new DefaultMustacheFactory(root) {
@Override
public MustacheVisitor createMustacheVisitor() {
return new CapturingMustacheVisitor(this, captured);
}
};
Mustache m = c.compile("complex.html");
StringWriter sw = new StringWriter();
m.execute(sw, new ComplexObject());
jg.writeEndObject();
jg.flush();
assertEquals(getContents(root, "complex.txt"), sw.toString());
JsonNode jsonNode = jf.createJsonParser(json.toString()).readValueAsTree();
Object o = JsonInterpreterTest.toObject(jsonNode);
sw = new StringWriter();
m = init().compile("complex.html");
m.execute(sw, o);
assertEquals(getContents(root, "complex.txt"), sw.toString());