use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.
the class ClientServerTest method testAsyncCallUseProperAssignedExecutor.
@Test
public void testAsyncCallUseProperAssignedExecutor() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
class TestExecutor implements Executor {
private AtomicInteger count = new AtomicInteger();
public void execute(Runnable command) {
int c = count.incrementAndGet();
LOG.info("asyn call time " + c);
command.run();
}
public int getCount() {
return count.get();
}
}
Executor executor = new TestExecutor();
service.setExecutor(executor);
assertNotNull(service);
assertSame(executor, service.getExecutor());
assertEquals(((TestExecutor) executor).getCount(), 0);
Greeter greeter = service.getPort(portName, Greeter.class);
updateAddressPort(greeter, PORT);
List<Response<GreetMeResponse>> responses = new ArrayList<>();
for (int i = 0; i < 5; i++) {
responses.add(greeter.greetMeAsync("asyn call" + i));
}
// wait for all the responses
for (Response<GreetMeResponse> resp : responses) {
resp.get();
}
assertEquals(5, ((TestExecutor) executor).getCount());
}
Aggregations