Search in sources :

Example 1 with OMDataSourceExt

use of org.apache.axiom.om.OMDataSourceExt in project webservices-axiom by apache.

the class TestSerializeModifiedOMSEWithNonDestructiveDataSource method runTest.

@Override
protected void runTest() throws Throwable {
    OMDataSourceExt ds = new StringOMDataSource("<element><child/></element>");
    assertFalse(ds.isDestructiveWrite());
    OMFactory f = metaFactory.getOMFactory();
    OMElement element = f.createOMElement(ds, "element", null);
    element.getFirstElement().setText("TEST");
    StringWriter sw = new StringWriter();
    element.serialize(sw);
    assertTrue(sw.toString().indexOf("TEST") != -1);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    element.serialize(baos);
    assertTrue(new String(baos.toByteArray(), "UTF-8").indexOf("TEST") != -1);
    assertTrue(element.toString().indexOf("TEST") != -1);
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringWriter(java.io.StringWriter) StringOMDataSource(org.apache.axiom.om.ds.StringOMDataSource) OMElement(org.apache.axiom.om.OMElement) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OMDataSourceExt(org.apache.axiom.om.OMDataSourceExt)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 StringWriter (java.io.StringWriter)1 OMDataSourceExt (org.apache.axiom.om.OMDataSourceExt)1 OMElement (org.apache.axiom.om.OMElement)1 OMFactory (org.apache.axiom.om.OMFactory)1 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)1