Search in sources :

Example 11 with RMManager

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

the class MessageCallbackOnewayTest method testOnewayExactlyOnceInOrder.

private void testOnewayExactlyOnceInOrder(Executor executor) throws Exception {
    init("org/apache/cxf/systest/ws/rm/exactlyonce-inorder.xml", executor);
    greeterBus.getOutInterceptors().add(new MessageLossSimulator());
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(RETRANSMISSION_INTERVAL);
    String[] callArgs = new String[] { "one", "two", "three", "four" };
    for (int i = 0; i < callArgs.length; i++) {
        greeter.greetMeOneWay(callArgs[i]);
    }
    callback.waitDone(8, 3000, 60000);
    verifyCallbacks();
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Example 12 with RMManager

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

the class ProtocolVariationsTest method testTerminateSequenceRM11.

@Test
public void testTerminateSequenceRM11() throws Exception {
    init("org/apache/cxf/systest/ws/rm/rminterceptors.xml", false);
    RMManager manager = greeterBus.getExtension(RMManager.class);
    manager.getSourcePolicy().getSequenceTerminationPolicy().setMaxLength(1);
    // WS-RM 1.1 and WS-A 1.0
    Client client = ClientProxy.getClient(greeter);
    client.getRequestContext().put(RMManager.WSRM_VERSION_PROPERTY, RM11Constants.NAMESPACE_URI);
    client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY, Names.WSA_NAMESPACE_NAME);
    greeter.greetMeOneWay("one");
    verifyTerminateSequence(Names.WSA_NAMESPACE_NAME, RM11Constants.INSTANCE);
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 13 with RMManager

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

the class RedeliveryTest method testAutomaticRedeliveryAfterError.

@Test
public void testAutomaticRedeliveryAfterError() throws Exception {
    LOG.fine("Creating greeter client");
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("/org/apache/cxf/systest/ws/rm/rminterceptors.xml");
    // set the client retry interval much shorter than the slow processing delay
    RMManager manager = bus.getExtension(RMManager.class);
    RMConfiguration cfg = manager.getConfiguration();
    cfg.setBaseRetransmissionInterval(3000L);
    BusFactory.setDefaultBus(bus);
    GreeterService gs = new GreeterService();
    greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    assertNull("last greeted by none", serverGreeter.getValue());
    LOG.fine("Invoking greeter for one");
    greeter.greetMeOneWay("one");
    LOG.fine("Wait for 4 secs ...");
    Thread.sleep(4000);
    assertEquals("last greeted by one", "one", serverGreeter.getValue());
    assertTrue("retransmission running", manager.getRetransmissionQueue().isEmpty());
    LOG.fine("Activating the error trigger and invoking greeter for two");
    serverGreeter.setThrowAlways(true);
    greeter.greetMeOneWay("two");
    LOG.fine("Wait for 4 secs ...");
    Thread.sleep(4000);
    RMManager serverManager = serverBus.getExtension(RMManager.class);
    assertEquals("last greeted by one", "one", serverGreeter.getValue());
    assertTrue("retransmission running", manager.getRetransmissionQueue().isEmpty());
    assertFalse("redelivery not running", serverManager.getRedeliveryQueue().isEmpty());
    LOG.fine("Deactivating the error trigger and wait for 9 secs ...");
    serverGreeter.setThrowAlways(false);
    Thread.sleep(9000);
    assertEquals("last greeted by two", "two", serverGreeter.getValue());
    assertTrue("redelivery running", serverManager.getRedeliveryQueue().isEmpty());
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) GreeterService(org.apache.cxf.greeter_control.GreeterService) RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration) Test(org.junit.Test)

Example 14 with RMManager

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

the class RetransmissionQueueTest method testDecoupleFaultHandling.

@Test
public void testDecoupleFaultHandling() 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);
    bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(4000));
    // an interceptor to simulate a transmission error
    MessageLossSimulator loser = new MessageLossSimulator();
    bus.getOutInterceptors().add(loser);
    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);
    loser.setMode(-1);
    loser.setThrowsException(true);
    try {
        greeter.greetMeOneWay("oneway");
    } catch (Exception e) {
        fail("fault thrown after queued for retransmission");
    }
    Thread.sleep(2000);
    RMManager manager = bus.getExtension(RMManager.class);
    boolean empty = manager.getRetransmissionQueue().isEmpty();
    assertFalse("RetransmissionQueue is empty", empty);
    loser.setMode(1);
    Thread.sleep(6000);
    empty = manager.getRetransmissionQueue().isEmpty();
    assertTrue("RetransmissionQueue not cleared", 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 15 with RMManager

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

the class RobustServiceWithFaultTest method testRobustWithSomeFaults.

@Test
public void testRobustWithSomeFaults() throws Exception {
    LOG.fine("Creating greeter client");
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("/org/apache/cxf/systest/ws/rm/seqlength1.xml");
    // set the client retry interval much shorter than the slow processing delay
    RMManager manager = bus.getExtension(RMManager.class);
    manager.getConfiguration().setBaseRetransmissionInterval(new Long(5000));
    BusFactory.setDefaultBus(bus);
    GreeterService gs = new GreeterService();
    greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Invoking greeter");
    greeter.greetMeOneWay("one");
    Thread.sleep(3000);
    // invoked once
    assertEquals("not invoked once", 1, serverGreeter.getCount());
    assertTrue("still in retransmission", manager.getRetransmissionQueue().isEmpty());
    LOG.fine("Invoking greeter and raising a fault");
    serverGreeter.setThrowAlways(true);
    greeter.greetMeOneWay("two");
    Thread.sleep(3000);
    // still invoked once
    assertEquals("not invoked once", 1, serverGreeter.getCount());
    assertTrue("still in retransmission", manager.getRetransmissionQueue().isEmpty());
    LOG.fine("Invoking robust greeter and raising a fault");
    robustSetter.setRobust(true);
    greeter.greetMeOneWay("three");
    Thread.sleep(3000);
    // still invoked once
    assertEquals("not invoked once", 1, serverGreeter.getCount());
    assertFalse("no message in retransmission", manager.getRetransmissionQueue().isEmpty());
    LOG.fine("Stop raising a fault and let the retransmission succeeds");
    serverGreeter.setThrowAlways(false);
    Thread.sleep(8000);
    // invoked twice
    assertEquals("not invoked twice", 2, serverGreeter.getCount());
    assertTrue("still in retransmission", manager.getRetransmissionQueue().isEmpty());
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) GreeterService(org.apache.cxf.greeter_control.GreeterService) Test(org.junit.Test)

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