Search in sources :

Example 1 with Control

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

the class AbstractServerPersistenceTest method testRecovery.

@Test
public void testRecovery() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    LOG.fine("Created bus " + bus + " with default cfg");
    ControlService cs = new ControlService();
    Control control = cs.getControlPort();
    ConnectionHelper.setKeepAliveConnection(control, false, true);
    updateAddressPort(control, getPort());
    assertTrue("Failed to start greeter", control.startGreeter(SERVER_LOSS_CFG));
    LOG.fine("Started greeter server.");
    System.setProperty("db.name", getPrefix() + "-recovery");
    greeterBus = new SpringBusFactory().createBus(CFG);
    System.clearProperty("db.name");
    LOG.fine("Created bus " + greeterBus + " with cfg : " + CFG);
    BusFactory.setDefaultBus(greeterBus);
    // avoid early client resends
    greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, getPort());
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, false, true);
    Client c = ClientProxy.getClient(greeter);
    HTTPConduit hc = (HTTPConduit) (c.getConduit());
    HTTPClientPolicy cp = hc.getClient();
    cp.setDecoupledEndpoint("http://localhost:" + getDecoupledPort() + "/decoupled_endpoint");
    out = new OutMessageRecorder();
    in = new InMessageRecorder();
    greeterBus.getOutInterceptors().add(out);
    greeterBus.getInInterceptors().add(in);
    LOG.fine("Configured greeter client.");
    Response<GreetMeResponse>[] responses = cast(new Response[4]);
    responses[0] = greeter.greetMeAsync("one");
    responses[1] = greeter.greetMeAsync("two");
    responses[2] = greeter.greetMeAsync("three");
    verifyMissingResponse(responses);
    control.stopGreeter(SERVER_LOSS_CFG);
    LOG.fine("Stopped greeter server");
    out.getOutboundMessages().clear();
    in.getInboundMessages().clear();
    control.startGreeter(CFG);
    String nl = System.getProperty("line.separator");
    LOG.fine("Restarted greeter server" + nl + nl);
    verifyServerRecovery(responses);
    responses[3] = greeter.greetMeAsync("four");
    verifyRetransmissionQueue();
    verifyAcknowledgementRange(1, 4);
    out.getOutboundMessages().clear();
    in.getInboundMessages().clear();
    greeterBus.shutdown(true);
    control.stopGreeter(CFG);
    bus.shutdown(true);
}
Also used : OutMessageRecorder(org.apache.cxf.testutil.recorders.OutMessageRecorder) GreeterService(org.apache.cxf.greeter_control.GreeterService) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) GreetMeResponse(org.apache.cxf.greeter_control.types.GreetMeResponse) Response(javax.xml.ws.Response) InMessageRecorder(org.apache.cxf.testutil.recorders.InMessageRecorder) Control(org.apache.cxf.greeter_control.Control) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ControlService(org.apache.cxf.greeter_control.ControlService) Greeter(org.apache.cxf.greeter_control.Greeter) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 2 with Control

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

the class WSRM12ServerCycleTest method runTest.

public void runTest(String cfg, boolean faultOnRestart) throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    ControlService cs = new ControlService();
    Control control = cs.getControlPort();
    ConnectionHelper.setKeepAliveConnection(control, false, true);
    updateAddressPort(control, PORT);
    Assert.assertTrue("Failed to start greeter", control.startGreeter(cfg));
    System.setProperty("db.name", getPrefix() + "-recovery");
    Bus greeterBus = new SpringBusFactory().createBus();
    System.clearProperty("db.name");
    BusFactory.setDefaultBus(greeterBus);
    // avoid early client resends
    greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterPort(new LoggingFeature(), new AddressingFeature(), wsrm());
    updateAddressPort(greeter, PORT);
    greeter.greetMe("one");
    greeter.greetMe("two");
    greeter.greetMe("three");
    control.stopGreeter(cfg);
    // make sure greeter is down
    Thread.sleep(1000);
    control.startGreeter(cfg);
    // CXF-7392
    if (faultOnRestart) {
        try {
            greeter.greetMe("four");
        } catch (SOAPFaultException ex) {
            assertTrue(ex.getMessage().contains("wsrm:Identifier"));
        // expected, sequence identifier doesn't exist on other side
        }
    } else {
        // this should work as the sequence should be recovered on the server side
        greeter.greetMe("four");
    }
    ((Closeable) greeter).close();
    greeterBus.shutdown(true);
    control.stopGreeter(cfg);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) Control(org.apache.cxf.greeter_control.Control) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) AddressingFeature(javax.xml.ws.soap.AddressingFeature) ControlService(org.apache.cxf.greeter_control.ControlService) Greeter(org.apache.cxf.greeter_control.Greeter) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Closeable(java.io.Closeable) GreeterService(org.apache.cxf.greeter_control.GreeterService) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Aggregations

SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 Control (org.apache.cxf.greeter_control.Control)2 ControlService (org.apache.cxf.greeter_control.ControlService)2 Greeter (org.apache.cxf.greeter_control.Greeter)2 GreeterService (org.apache.cxf.greeter_control.GreeterService)2 Closeable (java.io.Closeable)1 Response (javax.xml.ws.Response)1 AddressingFeature (javax.xml.ws.soap.AddressingFeature)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 Bus (org.apache.cxf.Bus)1 Client (org.apache.cxf.endpoint.Client)1 LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature)1 GreetMeResponse (org.apache.cxf.greeter_control.types.GreetMeResponse)1 InMessageRecorder (org.apache.cxf.testutil.recorders.InMessageRecorder)1 OutMessageRecorder (org.apache.cxf.testutil.recorders.OutMessageRecorder)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 Test (org.junit.Test)1