Search in sources :

Example 1 with MessageFlow

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

the class AbstractClientPersistenceTest method populateStoreAfterRestart.

void populateStoreAfterRestart() throws Exception {
    bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    greeter.greetMeOneWay("five");
    // force at least two outbound messages, since can't always count on three
    awaitMessages(1, 2);
    MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    // sent 1 app message and no create seq messag this time
    mf.verifyMessages(1, true);
    String[] expectedActions = new String[] { GREETMEONEWAY_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { "5" }, true);
    mf.verifyAcknowledgements(new boolean[1], true);
    // need in-exact as it COULD be 3 acks on a slow machine
    // normally it will ack 1,3,5 and then 1-5, but on a slow machine,
    // I've seen 1,3,5, then 1-3,5, and then 1-5
    mf.verifyMessages(2, false, false);
    // verify the final ack range to be complete
    try {
        mf.verifyAcknowledgementRange(1, 5);
    } catch (AssertionError er) {
        // possibly only got the first 2 ranges when split in 3, lets
        // wait for the third and then recheck
        awaitMessages(1, 3);
        mf.reset(out.getOutboundMessages(), in.getInboundMessages());
        mf.verifyAcknowledgementRange(1, 5);
    }
}
Also used : MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow)

Example 2 with MessageFlow

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

the class AbstractClientPersistenceTest method populateStore.

void populateStore() throws Exception {
    bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    bus.getOutInterceptors().add(new MessageLossSimulator());
    greeter.greetMeOneWay("one");
    greeter.greetMeOneWay("two");
    greeter.greetMeOneWay("three");
    greeter.greetMeOneWay("four");
    awaitMessages(5, 3);
    MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
    // sent create seq + 4 app messages and losing 2 app messages
    mf.verifyMessages(5, true);
    String[] expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", "3", "4" }, true);
    mf.verifyAcknowledgements(new boolean[5], true);
    // as 2 messages being lost, received seq ack and 2 ack messages
    mf.verifyMessages(3, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyAcknowledgements(new boolean[] { false, true, true }, false);
}
Also used : MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow)

Example 3 with MessageFlow

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

the class SequenceTest method testMultiClientOneway.

@Test
public void testMultiClientOneway() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    String cfgResource = "org/apache/cxf/systest/ws/rm/rminterceptors.xml";
    initControl(bf, cfgResource);
    class ClientThread extends Thread {

        Greeter greeter;

        Bus greeterBus;

        InMessageRecorder inRecorder;

        OutMessageRecorder outRecorder;

        String id;

        ClientThread(SpringBusFactory bf, String cfgResource, int n) {
            SequenceTest.this.initGreeter(bf, cfgResource, false, null);
            greeter = SequenceTest.this.greeter;
            greeterBus = SequenceTest.this.greeterBus;
            inRecorder = SequenceTest.this.inRecorder;
            outRecorder = SequenceTest.this.outRecorder;
            id = "client " + n;
        }

        public void run() {
            greeter.greetMeOneWay(id + ": once");
            greeter.greetMeOneWay(id + ": twice");
            greeter.greetMeOneWay(id + ": thrice");
            // three application messages plus createSequence
            awaitMessages(4, 4);
        }
    }
    ClientThread[] clients = new ClientThread[2];
    try {
        for (int i = 0; i < clients.length; i++) {
            clients[i] = new ClientThread(bf, cfgResource, i);
        }
        for (int i = 0; i < clients.length; i++) {
            clients[i].start();
        }
        for (int i = 0; i < clients.length; i++) {
            clients[i].join();
            MessageFlow mf = new MessageFlow(clients[i].outRecorder.getOutboundMessages(), clients[i].inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
            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 plus 3 partial responses
            mf.verifyMessages(4, false);
            expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_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 }, false);
            mf.verifyAcknowledgements(new boolean[] { false, true, true, true }, false);
        }
    } finally {
        for (int i = 0; i < clients.length; i++) {
            greeter = clients[i].greeter;
            greeterBus = clients[i].greeterBus;
            stopClient();
        }
        greeter = null;
    }
}
Also used : Bus(org.apache.cxf.Bus) InMessageRecorder(org.apache.cxf.testutil.recorders.InMessageRecorder) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) OutMessageRecorder(org.apache.cxf.testutil.recorders.OutMessageRecorder) Greeter(org.apache.cxf.greeter_control.Greeter) MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

Example 4 with MessageFlow

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

the class SequenceTest method testOnewayAnonymousAcksClientSequenceDemarcation.

@Test
public void testOnewayAnonymousAcksClientSequenceDemarcation() throws Exception {
    init("org/apache/cxf/systest/ws/rm/rminterceptors.xml");
    greeter.greetMeOneWay("once");
    ((BindingProvider) greeter).getRequestContext().put(RMManager.WSRM_LAST_MESSAGE_PROPERTY, Boolean.TRUE);
    greeter.greetMeOneWay("twice");
    ((BindingProvider) greeter).getRequestContext().remove(RMManager.WSRM_LAST_MESSAGE_PROPERTY);
    greeter.greetMeOneWay("thrice");
    // three application messages plus two createSequence plus one
    // terminateSequence
    awaitMessages(6, 5);
    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, GREETMEONEWAY_ACTION, RM10Constants.TERMINATE_SEQUENCE_ACTION, RM10Constants.CREATE_SEQUENCE_ACTION, GREETMEONEWAY_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", null, null, "1" }, true);
    mf.verifyLastMessage(new boolean[] { false, false, true, false, false, false }, true);
    // createSequenceResponse message plus partial responses to
    // greetMeOneWay and terminateSequence ||: 2
    mf.verifyMessages(5, false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_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, null }, false);
    mf.verifyLastMessage(new boolean[] { false, false, false, false, false }, false);
    mf.verifyAcknowledgements(new boolean[] { false, true, true, false, true }, false);
}
Also used : MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

Example 5 with MessageFlow

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

the class SequenceTest method testTerminateOnShutdown.

@Test
public void testTerminateOnShutdown() throws Exception {
    init("org/apache/cxf/systest/ws/rm/terminate-on-shutdown.xml", true);
    RMManager manager = greeterBus.getExtension(RMManager.class);
    // this test also verify the DB is correctly being updated during the shutdown
    RMMemoryStore store = new RMMemoryStore();
    manager.setStore(store);
    greeter.greetMeOneWay("neutrophil");
    greeter.greetMeOneWay("basophil");
    greeter.greetMeOneWay("eosinophil");
    stopGreeterButNotCloseConduit();
    awaitMessages(6, 2);
    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, GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION, RM10Constants.CLOSE_SEQUENCE_ACTION, RM10Constants.TERMINATE_SEQUENCE_ACTION };
    mf.verifyActions(expectedActions, true);
    mf.verifyMessageNumbers(new String[] { null, "1", "2", "3", "4", null }, true);
    // inbound: CreateSequenceResponse, out-of-band SequenceAcknowledgement
    // plus 6 partial responses
    mf.verifyMessages(2, false);
    mf.verifyMessageNumbers(new String[2], false);
    expectedActions = new String[] { RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION, RM10Constants.SEQUENCE_ACKNOWLEDGMENT_ACTION };
    mf.verifyActions(expectedActions, false);
    mf.verifyAcknowledgements(new boolean[] { false, true }, false);
    // additional check to verify the operations performed on DB
    assertEquals("sequences not released from DB", 0, store.ssmap.size());
    assertEquals("messages not released from DB", 0, store.ommap.size());
    assertEquals("sequence not closed in DB", 1, store.ssclosed.size());
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) MessageFlow(org.apache.cxf.systest.ws.util.MessageFlow) Test(org.junit.Test)

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