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, PORT);
assertTrue("Failed to start greeter", control.startGreeter(SERVER_LOSS_CFG));
LOG.fine("Started greeter server.");
greeterBus = new SpringBusFactory().createBus(CFG);
LOG.fine("Created bus " + greeterBus + " with cfg : " + CFG);
BusFactory.setDefaultBus(greeterBus);
// avoid early client resends
greeterBus.getExtension(RMManager.class).getRMAssertion().getBaseRetransmissionInterval()
.setMilliseconds(new Long(60000));
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
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:" + DECOUPLE_PORT + "/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);
}