XMLEventFactory factory = XMLEventFactory.newInstance();
Attribute att = factory.createAttribute("some-attribute", "10");
ArrayList list = new ArrayList();
list.add(att);
writer.add(factory.createStartDocument());
writer.add(factory.createComment("hello"));
writer.add(factory.createStartElement(new QName("root"), list.iterator(), null));
writer.close();
assertEquals("<?xml version='1.0' encoding='UTF-8'?><!--hello--><root some-attribute=\"10\"></root>", stream.toString());
}
}