Search in sources :

Example 31 with MessageFlow

use of org.apache.cxf.systest.ws.util.MessageFlow in project cxf by apache.

the class SequenceTest method testOnewayDeferredAnonymousAcks.

@Test
public void testOnewayDeferredAnonymousAcks() throws Exception {
    init("org/apache/cxf/systest/ws/rm/deferred.xml");
    greeter.greetMeOneWay("once");
    greeter.greetMeOneWay("twice");
    try {
        Thread.sleep(3 * 1000);
    } catch (InterruptedException ex) {
    // ignore
    }
    greeter.greetMeOneWay("thrice");
    awaitMessages(4, 2);
    MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    // three application messages plus createSequence
    mf.verifyMessages(4, true);
    String[] expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", "3" }, true);
    // createSequenceResponse message plus 3 partial responses, only the
    // last one should include a sequence acknowledgment
    mf.verifyMessages(2, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyMessageNumbers(new String[] { null, null }, false);
    mf.verifyAcknowledgements(new boolean[] { false, true }, false);
}
Also used : MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

Example 32 with MessageFlow

use of org.apache.cxf.systest.ws.util.MessageFlow in project cxf by apache.

the class SequenceTest method testServerSideMessageLoss.

@Test
public void testServerSideMessageLoss() throws Exception {
    init("org/apache/cxf/systest/ws/rm/message-loss-server.xml", true);
    // avoid client side message loss
    List<Interceptor<? extends Message>> outInterceptors = greeterBus.getOutInterceptors();
    for (Interceptor<? extends Message> i : outInterceptors) {
        if (i.getClass().equals(MessageLossSimulator.class)) {
            outInterceptors.remove(i);
            break;
        }
    }
    // avoid client side resends
    greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    greeter.greetMe("one");
    greeter.greetMe("two");
    // outbound: CreateSequence and two greetMe messages
    awaitMessages(3, 3);
    MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    mf.verifyMessages(3, true);
    String[] expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_ACTION, GREETME_ACTION, GREETME_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2" }, true);
    mf.verifyLastMessage(new boolean[] { false, false, false }, true);
    mf.verifyAcknowledgements(new boolean[] { false, false, true }, true);
    // createSequenceResponse plus 2 greetMeResponse messages plus
    // one partial response for each of the four messages
    // the first partial response should no include an acknowledgement, the other three should
    mf.verifyMessages(3, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, GREETME_RESPONSE_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyMessageNumbers(new String[] { null, "1", "2" }, false);
    mf.verifyLastMessage(new boolean[3], false);
    mf.verifyAcknowledgements(new boolean[] { false, true, true }, false);
}
Also used : RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Message(org.apache.cxf.message.Message) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

Example 33 with MessageFlow

use of org.apache.cxf.systest.ws.util.MessageFlow in project cxf by apache.

the class SequenceTest method testOnewayAnonymousAcksSequenceLength1.

@Test
public void testOnewayAnonymousAcksSequenceLength1() throws Exception {
    init("org/apache/cxf/systest/ws/rm/seqlength1.xml");
    greeter.greetMeOneWay("once");
    greeter.greetMeOneWay("twice");
    // two application messages plus two createSequence plus two
    // terminateSequence
    awaitMessages(6, 4);
    MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    mf.verifyMessages(6, true);
    String[] expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_ACTION, GREETMEONEWAY_ACTION, RM10Constants.TERMINATE_SEQUENCE_ACTION, RM10Constants.CREATE_SEQUENCE_ACTION, GREETMEONEWAY_ACTION, RM10Constants.TERMINATE_SEQUENCE_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", null, null, "1", null }, true);
    mf.verifyLastMessage(new boolean[] { false, true, false, false, true, false }, true);
    // createSequenceResponse message plus partial responses to
    // greetMeOneWay and terminateSequence ||: 2
    mf.verifyMessages(4, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyMessageNumbers(new String[] { null, null, null, null }, false);
    mf.verifyLastMessage(new boolean[] { false, false, false, false }, false);
    mf.verifyAcknowledgements(new boolean[] { false, true, false, true }, false);
}
Also used : MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

Example 34 with MessageFlow

use of org.apache.cxf.systest.ws.util.MessageFlow in project cxf by apache.

the class SequenceTest method testTwowayNonAnonymousEndpointSpecific.

// the same as above but using endpoint specific interceptor configuration
@Test
public void testTwowayNonAnonymousEndpointSpecific() throws Exception {
    init("org/apache/cxf/systest/ws/rm/twoway-endpoint-specific.xml", true);
    greeter.greetMe("one");
    greeter.greetMe("two");
    greeter.greetMe("three");
    // CreateSequence and three greetMe messages
    // TODO there should be partial responses to the decoupled responses!
    awaitMessages(4, 4);
    MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    mf.verifyMessages(4, true);
    String[] expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_ACTION, GREETME_ACTION, GREETME_ACTION, GREETME_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", "3" }, true);
    mf.verifyLastMessage(new boolean[] { false, false, false, false }, true);
    mf.verifyAcknowledgements(new boolean[] { false, false, true, true }, true);
    // createSequenceResponse plus 3 greetMeResponse messages plus
    // one partial response for each of the four messages
    // the first partial response should no include an acknowledgement, the other three should
    mf.verifyMessages(4, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, GREETME_RESPONSE_ACTION, GREETME_RESPONSE_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", "3" }, false);
    mf.verifyLastMessage(new boolean[4], false);
    mf.verifyAcknowledgements(new boolean[] { false, true, true, true }, false);
}
Also used : MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

Example 35 with MessageFlow

use of org.apache.cxf.systest.ws.util.MessageFlow in project cxf by apache.

the class SequenceTest method testOnewayMessageLoss.

private void testOnewayMessageLoss(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/message-loss.xml", false, executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
    greeter.greetMeOneWay("one");
    greeter.greetMeOneWay("two");
    greeter.greetMeOneWay("three");
    greeter.greetMeOneWay("four");
    awaitMessages(7, 5, 10000);
    MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    // Expected outbound:
    // CreateSequence
    // + 4 greetMe messages
    // + at least 2 resends (message may be resent multiple times depending
    // on the timing of the ACKs)
    String[] expectedActions = new String[7];
    expectedActions[0] = RM10Constants.CREATE_SEQUENCE_ACTION;
    for (int i = 1; i < expectedActions.length; i++) {
        expectedActions[i] = GREETMEONEWAY_ACTION;
    }
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", "3", "4", "2", "4" }, true, false);
    mf.verifyLastMessage(new boolean[7], true);
    mf.verifyAcknowledgements(new boolean[7], true);
    // Expected inbound:
    // createSequenceResponse
    // + 2 partial responses to successfully transmitted messages
    // + 2 partial responses to resent messages
    mf.verifyMessages(5, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyMessageNumbers(new String[] { null, null, null, null, null }, false);
    mf.verifyAcknowledgements(new boolean[] { false, true, true, true, true }, false);
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow)

Aggregations

MessageFlow (org.apache.cxf.systest.ws.util.MessageFlow)36 Test (org.junit.Test)23 RMManager (org.apache.cxf.ws.rm.RMManager)8 Greeter (org.apache.cxf.greeter_control.Greeter)7 Closeable (java.io.Closeable)6 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)5 PingMeFault (org.apache.cxf.greeter_control.PingMeFault)5 InMessageRecorder (org.apache.cxf.testutil.recorders.InMessageRecorder)5 OutMessageRecorder (org.apache.cxf.testutil.recorders.OutMessageRecorder)5 Endpoint (javax.xml.ws.Endpoint)4 WebServiceException (javax.xml.ws.WebServiceException)4 BasicGreeterService (org.apache.cxf.greeter_control.BasicGreeterService)3 Message (org.apache.cxf.message.Message)3 AbstractPhaseInterceptor (org.apache.cxf.phase.AbstractPhaseInterceptor)3 MessageRecorder (org.apache.cxf.testutil.recorders.MessageRecorder)3 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)3 Bus (org.apache.cxf.Bus)2 SoapFault (org.apache.cxf.binding.soap.SoapFault)2 RMProperties (org.apache.cxf.ws.rm.RMProperties)2 IOException (java.io.IOException)1