URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
assertNotNull(wsdl);
HelloWorldService service = new HelloWorldService(wsdl, serviceName);
assertNotNull(service);
HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
final Thread thread = Thread.currentThread();
class TestAsyncHandler implements AsyncHandler<String> {
String expected;
public TestAsyncHandler(String x) {
expected = x;
}
public String getExpected() {
return expected;
}
public void handleResponse(Response<String> response) {
try {
Thread thread2 = Thread.currentThread();
assertNotSame(thread, thread2);
assertEquals("Hello " + expected, response.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}
TestAsyncHandler h1 = new TestAsyncHandler("Homer");
TestAsyncHandler h2 = new TestAsyncHandler("Maggie");
TestAsyncHandler h3 = new TestAsyncHandler("Bart");
TestAsyncHandler h4 = new TestAsyncHandler("Lisa");
TestAsyncHandler h5 = new TestAsyncHandler("Marge");
Future<?> f1 = greeter.greetMeAsync("Santa's Little Helper",
new TestAsyncHandler("Santa's Little Helper"));
f1.get();
f1 = greeter.greetMeAsync("PauseForTwoSecs Santa's Little Helper",
new TestAsyncHandler("Santa's Little Helper"));
long start = System.currentTimeMillis();
f1 = greeter.greetMeAsync("PauseForTwoSecs " + h1.getExpected(), h1);
Future<?> f2 = greeter.greetMeAsync("PauseForTwoSecs " + h2.getExpected(), h2);
Future<?> f3 = greeter.greetMeAsync("PauseForTwoSecs " + h3.getExpected(), h3);
Future<?> f4 = greeter.greetMeAsync("PauseForTwoSecs " + h4.getExpected(), h4);
Future<?> f5 = greeter.greetMeAsync("PauseForTwoSecs " + h5.getExpected(), h5);
long mid = System.currentTimeMillis();
assertEquals("Hello " + h1.getExpected(), f1.get());
assertEquals("Hello " + h2.getExpected(), f2.get());
assertEquals("Hello " + h3.getExpected(), f3.get());
assertEquals("Hello " + h4.getExpected(), f4.get());