Search in sources :

Example 1 with SequenceFault

use of org.apache.cxf.ws.rm.SequenceFault in project cxf by apache.

the class RMSoapOutInterceptorTest method testEncodeFault.

@Test
public void testEncodeFault() throws Exception {
    RMSoapOutInterceptor codec = new RMSoapOutInterceptor();
    setUpOutbound();
    SoapMessage message = setupOutboundFaultMessage();
    // no RM headers and no fault
    codec.encode(message);
    verifyHeaders(message, new String[] {});
    // fault is not a SoapFault
    message = setupOutboundFaultMessage();
    assertTrue(MessageUtils.isFault(message));
    Exception ex = new RuntimeException("");
    message.setContent(Exception.class, ex);
    codec.encode(message);
    verifyHeaders(message, new String[] {});
    // fault is a SoapFault but does not have a SequenceFault cause
    message = setupOutboundFaultMessage();
    SoapFault f = new SoapFault("REASON", RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME);
    message.setContent(Exception.class, f);
    codec.encode(message);
    verifyHeaders(message, new String[] {});
    // fault is a SoapFault and has a SequenceFault cause
    message = setupOutboundFaultMessage();
    SequenceFault sf = new SequenceFault("REASON");
    sf.setFaultCode(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME);
    Identifier sid = new Identifier();
    sid.setValue("SID");
    sf.setSender(true);
    f.initCause(sf);
    message.setContent(Exception.class, f);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_FAULT_NAME });
}
Also used : SequenceFault(org.apache.cxf.ws.rm.SequenceFault) SoapFault(org.apache.cxf.binding.soap.SoapFault) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 2 with SequenceFault

use of org.apache.cxf.ws.rm.SequenceFault in project cxf by apache.

the class SoapFaultFactoryTest method setupSequenceFault.

SequenceFault setupSequenceFault(boolean isSender, QName code, Object detail) {
    sf = control.createMock(SequenceFault.class);
    EasyMock.expect(sf.getReason()).andReturn("reason");
    EasyMock.expect(sf.isSender()).andReturn(isSender);
    EasyMock.expect(sf.getFaultCode()).andReturn(code).anyTimes();
    if (null != detail) {
        EasyMock.expect(sf.getDetail()).andReturn(detail);
        SequenceFaultType sft = new SequenceFaultType();
        sft.setFaultCode(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME);
    }
    return sf;
}
Also used : SequenceFault(org.apache.cxf.ws.rm.SequenceFault) SequenceFaultType(org.apache.cxf.ws.rm.v200702.SequenceFaultType)

Example 3 with SequenceFault

use of org.apache.cxf.ws.rm.SequenceFault in project cxf by apache.

the class SoapFaultFactory method createFault.

public Fault createFault(SequenceFault sf, Message msg) {
    Fault f = null;
    if (version == Soap11.getInstance()) {
        f = createSoap11Fault(sf);
        // so we can encode the SequenceFault as header
        f.initCause(sf);
    } else {
        f = createSoap12Fault(sf, msg);
    }
    return f;
}
Also used : SequenceFault(org.apache.cxf.ws.rm.SequenceFault) Fault(org.apache.cxf.interceptor.Fault) SoapFault(org.apache.cxf.binding.soap.SoapFault)

Aggregations

SequenceFault (org.apache.cxf.ws.rm.SequenceFault)3 SoapFault (org.apache.cxf.binding.soap.SoapFault)2 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)1 Fault (org.apache.cxf.interceptor.Fault)1 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)1 SequenceFaultType (org.apache.cxf.ws.rm.v200702.SequenceFaultType)1 Test (org.junit.Test)1