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 });
}
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;
}
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;
}
Aggregations