Search in sources :

Example 6 with OMCloneOptions

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

the class TestCloneBinary method runTest.

@Override
protected void runTest() throws Throwable {
    DataHandler dh = new DataHandler(new RandomDataSource(600613L, 4096));
    StringReader rootPart = new StringReader("<root><xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include' href='cid:123456@example.org'/></root>");
    DummyAttachmentAccessor attachmentAccessor = new DummyAttachmentAccessor("123456@example.org", dh);
    OMElement root = OMXMLBuilderFactory.createOMBuilder(metaFactory.getOMFactory(), new StreamSource(rootPart), attachmentAccessor).getDocumentElement();
    OMText text = (OMText) root.getFirstOMChild();
    OMCloneOptions options = new OMCloneOptions();
    options.setFetchDataHandlers(fetch);
    OMText clone = (OMText) text.clone(options);
    assertTrue(clone.isBinary());
    assertEquals(fetch, attachmentAccessor.isLoaded());
    assertSame(dh, clone.getDataHandler());
}
Also used : RandomDataSource(org.apache.axiom.testutils.activation.RandomDataSource) OMCloneOptions(org.apache.axiom.om.OMCloneOptions) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement) DataHandler(javax.activation.DataHandler)

Aggregations

OMCloneOptions (org.apache.axiom.om.OMCloneOptions)6 OMElement (org.apache.axiom.om.OMElement)4 OMDocument (org.apache.axiom.om.OMDocument)3 OMDataSource (org.apache.axiom.om.OMDataSource)2 OMFactory (org.apache.axiom.om.OMFactory)2 OMInformationItem (org.apache.axiom.om.OMInformationItem)2 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)2 SOAPMessage (org.apache.axiom.soap.SOAPMessage)2 StringReader (java.io.StringReader)1 DataHandler (javax.activation.DataHandler)1 QName (javax.xml.namespace.QName)1 StreamSource (javax.xml.transform.stream.StreamSource)1 ByteArrayDataSource (org.apache.axiom.attachments.ByteArrayDataSource)1 OMNamespace (org.apache.axiom.om.OMNamespace)1 OMText (org.apache.axiom.om.OMText)1 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)1 WrappedTextNodeOMDataSourceFromDataSource (org.apache.axiom.om.ds.WrappedTextNodeOMDataSourceFromDataSource)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 RandomDataSource (org.apache.axiom.testutils.activation.RandomDataSource)1 XMLSampleAdapter (org.apache.axiom.ts.om.XMLSampleAdapter)1