use of org.apache.cxf.greeter_control.types.GreetMeResponse in project cxf by apache.
the class JaxwsAsyncFailOverTest method testUseFailOverOnClient.
@Test
public void testUseFailOverOnClient() throws Exception {
List<String> serviceList = new ArrayList<>();
serviceList.add("http://localhost:" + PORT + "/SoapContext/GreeterPort");
RandomStrategy strategy = new RandomStrategy();
strategy.setAlternateAddresses(serviceList);
FailoverFeature ff = new FailoverFeature();
ff.setStrategy(strategy);
// setup the feature by using JAXWS front-end API
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
// set a fake address to kick off the failover feature
factory.setAddress("http://localhost:" + PORT2 + "/SoapContext/GreeterPort");
factory.getFeatures().add(ff);
factory.setServiceClass(Greeter.class);
Greeter proxy = factory.create(Greeter.class);
Response<GreetMeResponse> response = proxy.greetMeAsync("cxf");
int waitCount = 0;
while (!response.isDone() && waitCount < 15) {
Thread.sleep(1000);
waitCount++;
}
assertTrue("Response still not received.", response.isDone());
}
use of org.apache.cxf.greeter_control.types.GreetMeResponse 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.types.GreetMeResponse in project cxf by apache.
the class JaxwsExecutorTest method testUseCustomExecutorOnClient.
@Test
public void testUseCustomExecutorOnClient() throws Exception {
BasicGreeterService service = new BasicGreeterService();
class CustomExecutor implements Executor {
private int count;
public void execute(Runnable command) {
count++;
command.run();
}
public int getCount() {
return count;
}
}
CustomExecutor executor = new CustomExecutor();
service.setExecutor(executor);
assertSame(executor, service.getExecutor());
Greeter proxy = service.getGreeterPort();
updateAddressPort(proxy, PORT);
assertEquals(0, executor.getCount());
Response<GreetMeResponse> response = proxy.greetMeAsync("cxf");
int waitCount = 0;
while (!response.isDone() && waitCount < 15) {
Thread.sleep(1000);
waitCount++;
}
assertTrue("Response still not received.", response.isDone());
assertEquals(1, executor.getCount());
}
Aggregations