use of org.apache.axiom.om.OMCloneOptions in project webservices-axiom by apache.
the class TestClone method runTest.
@Override
protected void runTest() throws Throwable {
OMDocument original = file.getAdapter(XMLSampleAdapter.class).getDocument(metaFactory);
OMDocument clone = (OMDocument) original.clone(new OMCloneOptions());
assertAbout(xml()).that(xml(OMDocument.class, clone)).hasSameContentAs(xml(OMDocument.class, original));
}
use of org.apache.axiom.om.OMCloneOptions in project webservices-axiom by apache.
the class TestCloneUnknownName method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDataSource ds = new StringOMDataSource("<p:element xmlns:p='urn:ns'>test</p:element>");
OMSourcedElement element = factory.createOMElement(ds);
OMCloneOptions options = new OMCloneOptions();
options.setCopyOMDataSources(true);
OMElement clone = (OMElement) element.clone(options);
assertTrue(clone instanceof OMSourcedElement);
assertFalse(element.isExpanded());
OMNamespace expectedNS = factory.createOMNamespace("urn:ns", "p");
assertEquals("element", element.getLocalName());
assertEquals("element", clone.getLocalName());
assertEquals(expectedNS, element.getNamespace());
assertEquals(expectedNS, clone.getNamespace());
}
use of org.apache.axiom.om.OMCloneOptions in project webservices-axiom by apache.
the class TestClone method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = soapFactory.createSOAPMessage();
message.addChild(soapFactory.getDefaultEnvelope());
OMCloneOptions options = new OMCloneOptions();
options.setPreserveModel(preserveModel);
OMInformationItem clone = message.clone(options);
if (preserveModel) {
assertTrue(clone instanceof SOAPMessage);
} else {
assertTrue(clone instanceof OMDocument);
assertFalse(clone instanceof SOAPMessage);
}
OMElement envelope = ((OMDocument) clone).getOMDocumentElement();
if (preserveModel) {
assertTrue(envelope instanceof SOAPEnvelope);
} else {
assertFalse(envelope instanceof SOAPEnvelope);
}
assertEquals("Envelope", envelope.getLocalName());
assertEquals(spec.getEnvelopeNamespaceURI(), envelope.getNamespaceURI());
}
use of org.apache.axiom.om.OMCloneOptions in project webservices-axiom by apache.
the class TestCloneIncomplete method runTest.
@Override
protected void runTest() throws Throwable {
SOAPMessage message = SOAPSampleSet.WSA.getMessage(spec).getAdapter(SOAPSampleAdapter.class).getSOAPMessage(metaFactory);
OMCloneOptions options = new OMCloneOptions();
options.setPreserveModel(preserveModel);
OMInformationItem clone = message.clone(options);
if (preserveModel) {
assertTrue(clone instanceof SOAPMessage);
assertSame(soapFactory, clone.getOMFactory());
} else {
assertTrue(clone instanceof OMDocument);
assertFalse(clone instanceof SOAPMessage);
}
}
use of org.apache.axiom.om.OMCloneOptions in project webservices-axiom by apache.
the class TestCloneNonDestructive method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMDataSource ds = new WrappedTextNodeOMDataSourceFromDataSource(new QName("wrapper"), new ByteArrayDataSource("test".getBytes("utf-8")), Charset.forName("utf-8"));
OMSourcedElement element = factory.createOMElement(ds);
OMCloneOptions options = new OMCloneOptions();
options.setCopyOMDataSources(copyOMDataSources);
OMElement clone = (OMElement) element.clone(options);
if (copyOMDataSources) {
assertTrue(clone instanceof OMSourcedElement);
assertFalse(element.isExpanded());
} else {
assertFalse(clone instanceof OMSourcedElement);
assertTrue(clone.isComplete());
}
assertEquals("test", clone.getText());
assertEquals("wrapper", clone.getLocalName());
}
Aggregations