public void testStreamWriter() throws Exception
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(stream);
writer.writeStartDocument();
writer.writeComment("hello");
writer.writeStartElement("root");
writer.writeAttribute("some-attribute", "10");
writer.close();
assertEquals("<?xml version='1.0' encoding='UTF-8'?><!--hello--><root some-attribute=\"10\"></root>", stream.toString());
}