use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestGetSOAPBodyFirstElementLocalNameAndNSWithParser method runTest.
@Override
protected void runTest() throws Throwable {
// Prepare the message. Note that we do this programmatically to make sure that the message
// doesn't contain any unwanted whitespace.
SOAPEnvelope orgEnvelope = soapFactory.createDefaultSOAPMessage().getSOAPEnvelope();
orgEnvelope.getBody().addChild(soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix()));
String message = orgEnvelope.toString();
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(message)).getSOAPEnvelope();
assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
if (qname.getNamespaceURI().length() == 0) {
assertNull(ns);
} else {
assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
assertEquals(qname.getPrefix(), ns.getPrefix());
}
// Also request an XMLStreamReader. The LLOM implementation triggers some special processing
// in this case (because the getSOAPBodyFirstElementXXX calls put the builder in lookahead
// mode). This is a regression test for r631687 (AXIOM-282).
XMLStreamReader reader = envelope.getXMLStreamReader(false);
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals("Envelope", reader.getLocalName());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals("Body", reader.getLocalName());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals(qname.getLocalPart(), reader.getLocalName());
if (qname.getNamespaceURI().length() == 0) {
assertNull(reader.getNamespaceURI());
} else {
assertEquals(qname.getNamespaceURI(), reader.getNamespaceURI());
}
String readerPrefix = reader.getPrefix();
if (qname.getPrefix().length() == 0) {
assertTrue(readerPrefix == null || readerPrefix.isEmpty());
} else {
assertEquals(qname.getPrefix(), readerPrefix);
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestHasFault method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
assertFalse(envelope.hasFault());
SOAPBody body = soapFactory.createSOAPBody(envelope);
assertFalse(envelope.hasFault());
body.addFault(new Exception("This an exception for testing"));
assertTrue(envelope.hasFault());
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestGetDefaultFaultEnvelope method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.getDefaultFaultEnvelope();
assertNotNull("Default FaultEnvelope must have a SOAPFault in it", envelope.getBody().getFault());
assertNotNull("Default FaultEnvelope must have a SOAPFaultCode in it", envelope.getBody().getFault().getCode());
if (spec == SOAPSpec.SOAP12) {
assertNotNull("Default FaultEnvelope must have a SOAPFaultCodeValue in it", envelope.getBody().getFault().getCode().getValue());
}
assertNotNull("Default FaultEnvelope must have a SOAPFaultReason in it", envelope.getBody().getFault().getReason());
if (spec == SOAPSpec.SOAP12) {
assertNotNull("Default FaultEnvelope must have a SOAPFaultText in it", envelope.getBody().getFault().getReason().getFirstSOAPText());
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestAddHeaderBlockWithoutNamespace1 method runTest.
@Override
protected void runTest() throws Throwable {
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader(envelope);
try {
header.addHeaderBlock("test", null);
fail("Expected OMException");
} catch (OMException ex) {
// Expected
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class CloneTestCase method copyAndCheck.
/**
* Make a copy of the source envelope and validate the target tree
* @param sourceEnv
* @throws Exception
*/
protected void copyAndCheck(SOAPEnvelope sourceEnv) throws Exception {
SOAPCloneOptions options = new SOAPCloneOptions();
options.setFetchDataHandlers(true);
options.setPreserveModel(true);
options.setCopyOMDataSources(true);
SOAPEnvelope targetEnv = (SOAPEnvelope) sourceEnv.clone(options);
identityCheck(sourceEnv, targetEnv, "");
assertAbout(xml()).that(targetEnv.toString()).hasSameContentAs(sourceEnv.toString());
sourceEnv.close(false);
}
Aggregations