Search in sources :

Example 1 with SOAPFault

use of org.apache.axiom.soap.SOAPFault in project webservices-axiom by apache.

the class TestCreateSOAPFaultWithException method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPBody body = withParent ? soapFactory.getDefaultEnvelope().getBody() : null;
    SOAPFault fault = soapFactory.createSOAPFault(body, new Exception("Testing soap fault"));
    if (body != null) {
        assertThat(body.hasFault()).isTrue();
        assertThat(body.getFault()).isSameAs(fault);
    }
    assertThat(fault.isComplete()).isTrue();
    SOAPFaultDetail detail = fault.getDetail();
    assertThat(detail).isNotNull();
    Iterator<OMElement> it = detail.getAllDetailEntries();
    assertThat(it.hasNext()).isTrue();
    OMElement entry = it.next();
    assertThat(entry.getQName()).isEqualTo(new QName(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY));
    assertThat(entry.getText()).contains("Testing soap fault");
}
Also used : SOAPBody(org.apache.axiom.soap.SOAPBody) QName(javax.xml.namespace.QName) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) SOAPFault(org.apache.axiom.soap.SOAPFault) OMElement(org.apache.axiom.om.OMElement)

Example 2 with SOAPFault

use of org.apache.axiom.soap.SOAPFault in project webservices-axiom by apache.

the class TestWrongParent1 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFaultCode parent = soapFactory.createSOAPFaultCode();
    SOAPFault fault = soapFactory.createSOAPFault();
    try {
        parent.addChild(fault);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) SOAPFault(org.apache.axiom.soap.SOAPFault)

Example 3 with SOAPFault

use of org.apache.axiom.soap.SOAPFault in project webservices-axiom by apache.

the class TestSetException method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFault fault = soapFactory.createSOAPFault();
    Exception exception = new Exception("Test exception message");
    fault.setException(exception);
    SOAPFaultDetail detail = fault.getDetail();
    assertNotNull(detail);
    Iterator<OMElement> it = detail.getAllDetailEntries();
    assertTrue(it.hasNext());
    OMElement entry = it.next();
    assertNotNull(entry);
    assertEquals(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY, entry.getLocalName());
    assertNull(entry.getNamespace());
    String text = entry.getText();
    assertTrue(text.startsWith(Exception.class.getName() + ": Test exception message"));
    assertTrue(text.contains("at " + TestSetException.class.getName()));
    assertFalse(it.hasNext());
}
Also used : SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) SOAPFault(org.apache.axiom.soap.SOAPFault) OMElement(org.apache.axiom.om.OMElement)

Example 4 with SOAPFault

use of org.apache.axiom.soap.SOAPFault in project webservices-axiom by apache.

the class TestGetValueAsQName method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope env = soapFactory.getDefaultEnvelope();
    SOAPFault fault = soapFactory.createSOAPFault(env.getBody());
    SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
    QName value = new QName("urn:test", "myFaultCode");
    code.setValue(value);
    assertEquals(value, code.getValueAsQName());
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) QName(javax.xml.namespace.QName) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 5 with SOAPFault

use of org.apache.axiom.soap.SOAPFault in project webservices-axiom by apache.

the class TestGetCodeWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPFault soapFaultWithParser = envelope.getBody().getFault();
    assertNotNull("Fault Test with parser: - getCode method returns null", soapFaultWithParser.getCode());
    assertEquals("Fault Test with parser: - Fault code local name mismatch", spec.getFaultCodeQName(), soapFaultWithParser.getCode().getQName());
}
Also used : SOAPFault(org.apache.axiom.soap.SOAPFault)

Aggregations

SOAPFault (org.apache.axiom.soap.SOAPFault)35 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)13 OMElement (org.apache.axiom.om.OMElement)12 SOAPFaultReason (org.apache.axiom.soap.SOAPFaultReason)10 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)9 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)8 SOAPBody (org.apache.axiom.soap.SOAPBody)7 QName (javax.xml.namespace.QName)6 SOAPProcessingException (org.apache.axiom.soap.SOAPProcessingException)4 StringReader (java.io.StringReader)3 OMNamespace (org.apache.axiom.om.OMNamespace)3 OMNode (org.apache.axiom.om.OMNode)3 SOAPFaultRole (org.apache.axiom.soap.SOAPFaultRole)3 SOAPFaultSubCode (org.apache.axiom.soap.SOAPFaultSubCode)3 SOAPFaultValue (org.apache.axiom.soap.SOAPFaultValue)3 SOAPHeader (org.apache.axiom.soap.SOAPHeader)3 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)3 OMAttribute (org.apache.axiom.om.OMAttribute)2 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)2 SOAPFaultNode (org.apache.axiom.soap.SOAPFaultNode)2