Search in sources :

Example 1 with FaultLocation

use of org.apache.cxf.greeter_control.types.FaultLocation in project cxf by apache.

the class InterceptorFaultTest method testWithAddressingAnonymousReplies.

private void testWithAddressingAnonymousReplies(boolean robust) throws Exception {
    setupGreeter("org/apache/cxf/systest/interceptor/addr.xml", false);
    control.setRobustInOnlyMode(robust);
    // all interceptors pass
    testInterceptorsPass(robust);
    // test failure in phases <= Phase.UNMARSHALL
    FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory().createFaultLocation();
    location.setAfter(MAPAggregator.class.getName());
    // test failure occuring before and after logical addressing interceptor
    // won't get a fault in case of oneways non-robust for the latter (partial response already sent)
    testInterceptorFail(inPhases, location, robust);
}
Also used : FaultLocation(org.apache.cxf.greeter_control.types.FaultLocation) MAPAggregator(org.apache.cxf.ws.addressing.MAPAggregator)

Example 2 with FaultLocation

use of org.apache.cxf.greeter_control.types.FaultLocation in project cxf by apache.

the class InterceptorFaultTest method testRobustFailWithoutAddressingInUserLogicalPhase.

@Test
public void testRobustFailWithoutAddressingInUserLogicalPhase() throws Exception {
    setupGreeter("org/apache/cxf/systest/interceptor/no-addr.xml", false);
    control.setRobustInOnlyMode(true);
    // behaviour is identicial for all phases
    FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory().createFaultLocation();
    location.setPhase("user-logical");
    control.setFaultLocation(location);
    try {
        // writer to grab the content of soap fault.
        // robust is not yet used at client's side, but I think it should
        StringWriter writer = new StringWriter();
        ((Client) greeter).getInInterceptors().add(new LoggingInInterceptor(new PrintWriterEventSender(new PrintWriter(writer))));
        // it should tell CXF to convert one-way robust out faults into real SoapFaultException
        ((Client) greeter).getEndpoint().put(Message.ROBUST_ONEWAY, true);
        greeter.greetMeOneWay("oneway");
        fail("Oneway operation unexpectedly succeded for phase " + location.getPhase());
    } catch (SOAPFaultException ex) {
    // expected
    }
}
Also used : StringWriter(java.io.StringWriter) PrintWriterEventSender(org.apache.cxf.ext.logging.event.PrintWriterEventSender) FaultLocation(org.apache.cxf.greeter_control.types.FaultLocation) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 3 with FaultLocation

use of org.apache.cxf.greeter_control.types.FaultLocation in project cxf by apache.

the class InterceptorFaultTest method testWithoutAddressing.

private void testWithoutAddressing(boolean robust) throws Exception {
    setupGreeter("org/apache/cxf/systest/interceptor/no-addr.xml", false);
    control.setRobustInOnlyMode(robust);
    // all interceptors pass
    testInterceptorsPass(robust);
    // behaviour is identicial for all phases
    FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory().createFaultLocation();
    // test failure occuring before and after logical addressing interceptor
    // won't get a fault in case of oneways non-robust for the latter (partial response already sent)
    testInterceptorFail(inPhases, location, robust);
}
Also used : FaultLocation(org.apache.cxf.greeter_control.types.FaultLocation)

Example 4 with FaultLocation

use of org.apache.cxf.greeter_control.types.FaultLocation in project cxf by apache.

the class ServiceInvocationAckBase method testRobustInvocationHandling.

@Test
public void testRobustInvocationHandling() throws Exception {
    setupGreeter();
    control.setRobustInOnlyMode(true);
    FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory().createFaultLocation();
    location.setPhase(Phase.INVOKE);
    location.setBefore(ServiceInvokerInterceptor.class.getName());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    // the message is acked and the invocation takes place
    greeter.greetMeOneWay("one");
    waitForEmpty(manager.getRetransmissionQueue());
    control.setFaultLocation(location);
    // the invocation fails but the message is acked because the delivery succeeds
    greeter.greetMeOneWay("two");
    waitForNotEmpty(manager.getRetransmissionQueue());
    location.setPhase(null);
    control.setFaultLocation(location);
    // the retransmission succeeds and the invocation succeeds, the message is acked
    waitForEmpty(manager.getRetransmissionQueue());
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) FaultLocation(org.apache.cxf.greeter_control.types.FaultLocation) ServiceInvokerInterceptor(org.apache.cxf.interceptor.ServiceInvokerInterceptor) Test(org.junit.Test)

Example 5 with FaultLocation

use of org.apache.cxf.greeter_control.types.FaultLocation in project cxf by apache.

the class ServiceInvocationAckBase method testDefaultInvocationHandling.

@Test
public void testDefaultInvocationHandling() throws Exception {
    setupGreeter();
    control.setRobustInOnlyMode(false);
    FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory().createFaultLocation();
    location.setPhase(Phase.INVOKE);
    location.setBefore(ServiceInvokerInterceptor.class.getName());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    // the message is acked and the invocation takes place
    greeter.greetMeOneWay("one");
    waitForEmpty(manager.getRetransmissionQueue());
    control.setFaultLocation(location);
    // the invocation fails but the message is acked because the delivery succeeds
    greeter.greetMeOneWay("two");
    waitForEmpty(manager.getRetransmissionQueue());
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) FaultLocation(org.apache.cxf.greeter_control.types.FaultLocation) ServiceInvokerInterceptor(org.apache.cxf.interceptor.ServiceInvokerInterceptor) Test(org.junit.Test)

Aggregations

FaultLocation (org.apache.cxf.greeter_control.types.FaultLocation)5 Test (org.junit.Test)3 ServiceInvokerInterceptor (org.apache.cxf.interceptor.ServiceInvokerInterceptor)2 RMManager (org.apache.cxf.ws.rm.RMManager)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 PrintWriterEventSender (org.apache.cxf.ext.logging.event.PrintWriterEventSender)1 MAPAggregator (org.apache.cxf.ws.addressing.MAPAggregator)1