public void testSimpleAttribute() throws Exception
{
XmlFactory f = new XmlFactory();
StringWriter out = new StringWriter();
ToXmlGenerator gen = f.createGenerator(out);
// root name is special, need to be fed first:
gen.setNextName(new QName("root"));
gen.writeStartObject();
// and also need to force attribute
gen.setNextIsAttribute(true);
gen.writeFieldName("attr");
gen.writeString("value");
gen.writeEndObject();
gen.close();
String xml = out.toString();
// one more thing: remove that annoying 'xmlns' decl, if it's there:
xml = removeSjsxpNamespace(xml);
assertEquals("<root attr=\"value\"/>", xml);
}