use of org.apache.axiom.ext.stax.CharacterDataReader in project webservices-axiom by apache.
the class TestCharacterDataReaderFromParser method runTest.
@Override
protected void runTest() throws Throwable {
String text = "This is a test for the CharacterDataReader extension";
OMDocument doc = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StringReader("<root>" + text + "</root>")).getDocument();
XMLStreamReader reader = doc.getXMLStreamReader(cache);
CharacterDataReader cdataReader = (CharacterDataReader) reader.getProperty(CharacterDataReader.PROPERTY);
assertNotNull(cdataReader);
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
StringWriter sw = new StringWriter();
while (reader.next() == XMLStreamReader.CHARACTERS) {
cdataReader.writeTextTo(sw);
}
assertEquals(text, sw.toString());
}
Aggregations