Search in sources :

Example 16 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService 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 17 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService 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 18 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService 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)

Example 19 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class SequenceTimeoutTest method initDispatch.

private Dispatch<DOMSource> initDispatch() {
    GreeterService gs = new GreeterService();
    Dispatch<DOMSource> dispatch = gs.createDispatch(GreeterService.GreeterPort, DOMSource.class, Service.Mode.MESSAGE);
    try {
        updateAddressPort(dispatch, PORT);
    } catch (Exception e) {
    // ignore
    }
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.FALSE);
    dispatch.getRequestContext().put(MessageContext.WSDL_OPERATION, GREETME_NAME);
    return dispatch;
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) GreeterService(org.apache.cxf.greeter_control.GreeterService)

Example 20 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class SequenceTimeoutTest method initProxy.

private void initProxy(boolean useDecoupledEndpoint, Executor executor) {
    GreeterService gs = new GreeterService();
    if (null != executor) {
        gs.setExecutor(executor);
    }
    greeter = gs.getGreeterPort();
    try {
        updateAddressPort(greeter, PORT);
    } catch (Exception e) {
    // ignore
    }
    ConnectionHelper.setKeepAliveConnection(greeter, true);
}
Also used : GreeterService(org.apache.cxf.greeter_control.GreeterService)

Aggregations

GreeterService (org.apache.cxf.greeter_control.GreeterService)42 Greeter (org.apache.cxf.greeter_control.Greeter)28 Test (org.junit.Test)28 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)15 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)10 BindingProvider (javax.xml.ws.BindingProvider)10 RMManager (org.apache.cxf.ws.rm.RMManager)10 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)7 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)7 ControlService (org.apache.cxf.greeter_control.ControlService)4 MBeanServer (javax.management.MBeanServer)3 ObjectName (javax.management.ObjectName)3 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)3 IOException (java.io.IOException)2 List (java.util.List)2 TransformerException (javax.xml.transform.TransformerException)2 DOMSource (javax.xml.transform.dom.DOMSource)2 WebServiceException (javax.xml.ws.WebServiceException)2 Bus (org.apache.cxf.Bus)2 Client (org.apache.cxf.endpoint.Client)2