@Test
void getXMLStreamWriterWithSAXREsult() throws TransformerConfigurationException, XMLStreamException
{

    TransformerFactory tf = TransformerFactory.newInstance();
    if (!tf.getFeature(SAXTransformerFactory.FEATURE)) {
        throw new RuntimeException("Did not find a SAX-compatible TransformerFactory.");
    }
    StringWriter output = new StringWriter();
    SAXTransformerFactory stf = (SAXTransformerFactory) tf;
    TransformerHandler th = stf.newTransformerHandler();
    th.setResult(new StreamResult(output));
    XMLStreamWriter writer = StAXUtils.getXMLStreamWriter(new SAXResult(th));
    writer.writeStartDocument();
    writer.writeStartElement("element");
    writer.writeAttribute("attribute", "value");
    writer.writeCharacters("characters");
    writer.writeCData("cdata");
    writer.writeEndElement();
    writer.writeEndDocument();
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<element attribute=\"value\">"
        + "characters" + "<![CDATA[cdata]]>" + "</element>", output.getBuffer().toString());
}