use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.
the class FirstElementNameWithParserTestCase method runTest.
@Override
protected final void runTest() throws Throwable {
SOAPEnvelope orgEnvelope = soapFactory.getDefaultEnvelope();
orgEnvelope.getBody().addChild(soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix()));
SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(orgEnvelope.toString()));
SOAPBody body = builder.getSOAPEnvelope().getBody();
runTest(body);
if (supportsOptimization) {
// The expectation is that even after looking at the payload element name, registering
// a custom builder still transforms the element.
((CustomBuilderSupport) builder).registerCustomBuilder(CustomBuilder.Selector.PAYLOAD, new CustomBuilder() {
@Override
public OMDataSource create(OMElement element) throws OMException {
try {
element.getXMLStreamReaderWithoutCaching().close();
} catch (XMLStreamException ex) {
throw new OMException(ex);
}
return new AbstractPushOMDataSource() {
@Override
public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
xmlWriter.writeEmptyElement(qname.getPrefix(), qname.getLocalPart(), qname.getNamespaceURI());
}
@Override
public boolean isDestructiveWrite() {
return false;
}
};
}
});
assertThat(body.getFirstElement()).isInstanceOf(OMSourcedElement.class);
}
}
use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.
the class TestAddFault1 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPBody body = soapFactory.createSOAPBody(envelope);
body.addFault(new Exception("This an exception for testing"));
assertTrue("Body Test:- After calling addFault method, SOAP body has no fault", body.hasFault());
}
use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.
the class TestHasFaultWithParser method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPBody body = envelope.getBody();
assertTrue("Body Test With parser :- hasFault method returns false", body.hasFault());
}
use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.
the class TestGetFault method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPBody body = soapFactory.createSOAPBody(envelope);
assertNull("Body Test:- After creating a soap body it has a fault", body.getFault());
body.addFault(new Exception("This an exception for testing"));
assertNotNull("Body Test:- After calling addFault method, getFault method returns null", body.getFault());
}
use of org.apache.axiom.soap.SOAPBody in project webservices-axiom by apache.
the class TestCloneOMElement method runTest.
@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
SOAPBody body = envelope.getBody();
OMElement firstClonedBodyElement = body.cloneOMElement();
OMElement secondClonedBodyElement = body.cloneOMElement();
// cloneOMElement creates plain OMElements
assertFalse(firstClonedBodyElement instanceof SOAPBody);
assertFalse(secondClonedBodyElement instanceof SOAPBody);
// first check whether both have the same information
assertAbout(xml()).that(xml(OMElement.class, firstClonedBodyElement)).ignoringNamespaceDeclarations().hasSameContentAs(xml(OMElement.class, body));
assertAbout(xml()).that(xml(OMElement.class, secondClonedBodyElement)).ignoringNamespaceDeclarations().hasSameContentAs(xml(OMElement.class, body));
assertAbout(xml()).that(xml(OMElement.class, secondClonedBodyElement)).hasSameContentAs(xml(OMElement.class, firstClonedBodyElement));
// The clone is expected to be orphaned
assertNull(firstClonedBodyElement.getParent());
assertNull(secondClonedBodyElement.getParent());
envelope.close(false);
}
Aggregations