}
public void testNestedSerializedArrayElement() throws Exception {
StringWriter strWriter = new StringWriter();
MappedNamespaceConvention con = new MappedNamespaceConvention();
AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter);
w.serializeAsArray(con.createKey("", "", "docs"));
w.serializeAsArray(con.createKey("", "", "filters"));
w.serializeAsArray(con.createKey("", "", "hosts"));
w.writeStartDocument();
w.writeStartElement("", "docs", "");
w.writeStartElement("", "doc", "");
w.writeStartElement("", "id", "");
w.writeCharacters("24");
w.writeEndElement();
w.writeStartElement("", "filters", "");
w.writeEndElement();
w.writeStartElement("", "hosts", "");
w.writeStartElement("", "host", "");
w.writeStartElement("", "name", "");
w.writeCharacters("foobar.com");
w.writeEndElement(); //name
w.writeStartElement("", "ip", "");
w.writeCharacters("255.255.255.255");
w.writeEndElement(); //ip
w.writeEndElement(); // host
w.writeEndElement(); //hosts
w.writeEndElement(); // doc
w.writeEndElement(); // docs
w.writeEndDocument();
w.close();
strWriter.close();
assertEquals("{\"docs\":[{\"doc\":{\"id\":24,\"filters\":[\"\"],\"hosts\":[{\"host\":{\"name\":\"foobar.com\",\"ip\":\"255.255.255.255\"}}]}}]}", strWriter.toString());
}