names.addName(new NameBean("Charles Hawtrey"));
StringWriter out = new StringWriter();
out.write("<?xml version='1.0'?>");
BeanWriter writer = new BeanWriter(out);
writer.setWriteEmptyElements(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(true);
writer.setWriteIDs(false);
writer.write("CarryOn", names);
String xml = "<?xml version='1.0'?><CarryOn><names>"
+ "<name><name>Sid James</name></name>"
+ "<name><name>Kenneth Williams</name></name>"
+ "<name><name>Joan Simms</name></name>"
+ "<name><name>Charles Hawtrey</name></name>"
+ "</names>"
+"</CarryOn>";
xmlAssertIsomorphicContent(
parseString(out.getBuffer().toString()),
parseString(xml),
true);
out = new StringWriter();
out.write("<?xml version='1.0'?>");
writer = new BeanWriter(out);
writer.setWriteEmptyElements(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(true);
writer.setWriteIDs(false);
writer.getXMLIntrospector().setElementNameMapper(new CapitalizeNameMapper());
writer.write("CarryOn", names);
xml = "<?xml version='1.0'?><CarryOn><Names>"
+ "<Name><Name>Sid James</Name></Name>"
+ "<Name><Name>Kenneth Williams</Name></Name>"
+ "<Name><Name>Joan Simms</Name></Name>"
+ "<Name><Name>Charles Hawtrey</Name></Name>"
+ "</Names>"
+"</CarryOn>";
xmlAssertIsomorphicContent(
parseString(out.getBuffer().toString()),
parseString(xml),
true);
ArrayList things = new ArrayList();
things.add(new NameBean("Sugar"));
things.add(new NameBean("Spice"));
things.add(new NameBean("All Things Nice"));
NoAdderBean bean = new NoAdderBean();
bean.setThings(things);
out = new StringWriter();
out.write("<?xml version='1.0'?>");
writer = new BeanWriter(out);
writer.setWriteEmptyElements(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(true);
writer.setWriteIDs(false);
writer.write(bean);
xml = "<?xml version='1.0'?><NoAdderBean><things>"
+ "<NameBean><name>Sugar</name></NameBean>"
+ "<NameBean><name>Spice</name></NameBean>"
+ "<NameBean><name>All Things Nice</name></NameBean>"
+ "</things>"
+"</NoAdderBean>";
xmlAssertIsomorphicContent(
parseString(out.getBuffer().toString()),
parseString(xml),
true);
out = new StringWriter();
out.write("<?xml version='1.0'?>");
writer = new BeanWriter(out);
writer.setWriteEmptyElements(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(true);
writer.setWriteIDs(false);
writer.getXMLIntrospector().setElementNameMapper(new CapitalizeNameMapper());
writer.write(bean);
xml = "<?xml version='1.0'?><NoAdderBean><Things>"
+ "<NameBean><Name>Sugar</Name></NameBean>"
+ "<NameBean><Name>Spice</Name></NameBean>"
+ "<NameBean><Name>All Things Nice</Name></NameBean>"
+ "</Things>"
+"</NoAdderBean>";
xmlAssertIsomorphicContent(
parseString(out.getBuffer().toString()),
parseString(xml),
true);
out = new StringWriter();
out.write("<?xml version='1.0'?>");
writer = new BeanWriter(out);
writer.setWriteEmptyElements(true);
writer.getXMLIntrospector().setWrapCollectionsInElement(true);
writer.setWriteIDs(false);
writer.getXMLIntrospector().setElementNameMapper(new HyphenatedNameMapper(false));
writer.write(bean);
xml = "<?xml version='1.0'?><no-adder-bean><things>"
+ "<name-bean><name>Sugar</name></name-bean>"
+ "<name-bean><name>Spice</name></name-bean>"
+ "<name-bean><name>All Things Nice</name></name-bean>"