Search in sources :

Example 26 with RMManager

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

the class AbstractClientPersistenceTest method verifyStorePopulation.

void verifyStorePopulation() {
    RMManager manager = bus.getExtension(RMManager.class);
    assertNotNull(manager);
    RMStore store = manager.getStore();
    assertNotNull(store);
    Client client = ClientProxy.getClient(greeter);
    String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
    Collection<DestinationSequence> dss = store.getDestinationSequences(id);
    assertEquals(1, dss.size());
    Collection<SourceSequence> sss = store.getSourceSequences(id);
    assertEquals(1, sss.size());
    Collection<RMMessage> msgs = store.getMessages(sss.iterator().next().getIdentifier(), true);
    assertEquals(2, msgs.size());
    msgs = store.getMessages(sss.iterator().next().getIdentifier(), false);
    assertEquals(0, msgs.size());
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) RMManager(org.apache.cxf.ws.rm.RMManager) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) Client(org.apache.cxf.endpoint.Client) SourceSequence(org.apache.cxf.ws.rm.SourceSequence)

Example 27 with RMManager

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

the class CachedOutMessageTest method testCachedOutMessage.

@Test
public void testCachedOutMessage() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml");
    BusFactory.setDefaultBus(bus);
    LoggingInInterceptor in = new LoggingInInterceptor();
    bus.getInInterceptors().add(in);
    bus.getInFaultInterceptors().add(in);
    LoggingOutInterceptor out = new LoggingOutInterceptor();
    bus.getOutInterceptors().add(out);
    // an interceptor to simulate a message loss
    MessageLossSimulator mls = new MessageLossSimulator();
    bus.getOutInterceptors().add(mls);
    RMManager manager = bus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
    bus.getOutFaultInterceptors().add(out);
    GreeterService gs = new GreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, true);
    greeter.greetMeOneWay("one");
    greeter.greetMeOneWay("two");
    greeter.greetMeOneWay("three");
    long wait = 4000;
    while (wait > 0) {
        long start = System.currentTimeMillis();
        try {
            Thread.sleep(wait);
        } catch (InterruptedException ex) {
        // ignore
        }
        wait -= System.currentTimeMillis() - start;
    }
    boolean empty = manager.getRetransmissionQueue().isEmpty();
    assertTrue("Some messages are not acknowledged", empty);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.cxf.greeter_control.Greeter) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) GreeterService(org.apache.cxf.greeter_control.GreeterService) Test(org.junit.Test)

Example 28 with RMManager

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

the class DeliveryAssuranceOnewayTest method testOnewayAtMostOnce.

private void testOnewayAtMostOnce(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/atmostonce.xml", executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
    String[] callArgs = new String[] { "one", "two", "three", "four" };
    for (int i = 0; i < callArgs.length; i++) {
        greeter.greetMeOneWay(callArgs[i]);
    }
    awaitMessages(callArgs.length, 1000, 60000);
    List<String> actualArgs = GreeterProvider.CALL_ARGS;
    assertTrue("Too many messages", callArgs.length >= actualArgs.size());
    for (int i = 0; i < actualArgs.size() - 1; i++) {
        for (int j = i + 1; j < actualArgs.size(); j++) {
            if (actualArgs.get(j).equals(actualArgs.get(i))) {
                fail("Message received more than once " + callArgs[i]);
            }
        }
    }
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Example 29 with RMManager

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

the class DeliveryAssuranceOnewayTest method testOnewayAtLeastOnce.

private void testOnewayAtLeastOnce(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/atleastonce.xml", executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(1000));
    String[] callArgs = new String[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
    for (int i = 0; i < callArgs.length; i++) {
        greeter.greetMeOneWay(callArgs[i]);
    }
    awaitMessages(callArgs.length, 1, 3000);
    List<String> actualArgs = GreeterProvider.CALL_ARGS;
    int checkCount = 0;
    for (int i = 0; i < callArgs.length; i++) {
        boolean match = false;
        for (int j = 0; j < actualArgs.size(); j++) {
            if (actualArgs.get(j).equals(callArgs[i])) {
                match = true;
                break;
            }
        }
        if (!match) {
            if (checkCount > 20) {
                fail("No match for request " + callArgs[i]);
            }
            checkCount++;
            awaitMessages(callArgs.length, 1, 250);
            i--;
        }
    }
    assertTrue("Too few messages " + actualArgs.size(), callArgs.length <= actualArgs.size());
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Example 30 with RMManager

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

the class DeliveryAssuranceOnewayTest method testOnewayInOrder.

private void testOnewayInOrder(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/inorder.xml", executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(2000));
    String[] callArgs = new String[] { "one", "two", "three", "four" };
    for (int i = 0; i < callArgs.length; i++) {
        greeter.greetMeOneWay(callArgs[i]);
    }
    awaitMessages(callArgs.length - 2, 1000, 60000);
    List<String> actualArgs = GreeterProvider.CALL_ARGS;
    int argNum = 0;
    for (String actual : actualArgs) {
        while (argNum < callArgs.length && !actual.equals(callArgs[argNum])) {
            argNum++;
        }
        assertTrue("Message out of order", argNum < callArgs.length);
    }
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Aggregations

RMManager (org.apache.cxf.ws.rm.RMManager)43 Test (org.junit.Test)26 Endpoint (javax.xml.ws.Endpoint)12 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)12 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 Greeter (org.apache.cxf.greeter_control.Greeter)9 MessageFlow (org.apache.cxf.systest.ws.util.MessageFlow)8 Bus (org.apache.cxf.Bus)7 Client (org.apache.cxf.endpoint.Client)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 MBeanServer (javax.management.MBeanServer)3 ObjectName (javax.management.ObjectName)3 WebServiceException (javax.xml.ws.WebServiceException)3 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)3 Message (org.apache.cxf.message.Message)3 RMProperties (org.apache.cxf.ws.rm.RMProperties)3 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)3 SQLException (java.sql.SQLException)2 SoapFault (org.apache.cxf.binding.soap.SoapFault)2