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);
}
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);
}
Aggregations