public void testIssue54() throws Exception
{
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION);
StringWriter sw = new StringWriter();
ToXmlGenerator generator = (ToXmlGenerator) xmlMapper.getFactory().createGenerator(sw);
generator.initGenerator();
generator.setNextName(new QName("items"));
generator.writeStartObject();
ArrayList<Value> values = new ArrayList<Value>();
values.add(new Value(13));
values.add(new Value(456));
for (Value value : values) {
generator.writeFieldName("foo");
generator.setNextName(new QName("item"));
generator.writeObject(value);
}
generator.writeEndObject();
generator.close();
String xml = sw.toString();
// Remove XML declaration
assertTrue(xml.startsWith("<?xml version"));