use of org.apache.hello_world_soap_http.types.GreetMeLater in project cxf by apache.
the class DispatchClientServerTest method doJAXBPayload.
private void doJAXBPayload(Dispatch<Object> disp) throws Exception {
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
String expected = "Hello Jeeves";
GreetMe greetMe = new GreetMe();
greetMe.setRequestType("Jeeves");
Object response = disp.invoke(greetMe);
assertNotNull(response);
String responseValue = ((GreetMeResponse) response).getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue));
// Test oneway
disp.invokeOneWay(greetMe);
// Test async polling
Response<Object> response2 = disp.invokeAsync(greetMe);
assertNotNull(response2);
GreetMeResponse greetMeResponse = (GreetMeResponse) response2.get();
String responseValue2 = greetMeResponse.getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue2));
// Test async callback
TestJAXBHandler tjbh = new TestJAXBHandler();
Future<?> fd = disp.invokeAsync(greetMe, tjbh);
assertNotNull(fd);
waitForFuture(fd);
String responseValue3 = ((GreetMeResponse) tjbh.getResponse()).getResponseType();
assertTrue("Expected string, " + expected, expected.equals(responseValue3));
org.apache.hello_world_soap_http.types.TestDocLitFault fr = new org.apache.hello_world_soap_http.types.TestDocLitFault();
fr.setFaultType(BadRecordLitFault.class.getSimpleName());
tjbh = new TestJAXBHandler();
fd = disp.invokeAsync(fr, tjbh);
waitForFuture(fd);
try {
fd.get();
fail("did not get expected exception");
} catch (ExecutionException ex) {
// expected
}
GreetMeLater later = new GreetMeLater();
later.setRequestType(1000);
HTTPClientPolicy pol = new HTTPClientPolicy();
pol.setReceiveTimeout(100);
disp.getRequestContext().put(HTTPClientPolicy.class.getName(), pol);
Response<Object> o = disp.invokeAsync(later);
try {
o.get(10, TimeUnit.SECONDS);
fail("Should have gotten a SocketTimeoutException");
} catch (ExecutionException ex) {
assertTrue(ex.getCause() instanceof SocketTimeoutException);
}
later.setRequestType(20000);
pol.setReceiveTimeout(20000);
disp.getRequestContext().put(HTTPClientPolicy.class.getName(), pol);
o = disp.invokeAsync(later);
try {
o.get(100, TimeUnit.MILLISECONDS);
fail("Should have gotten a SocketTimeoutException");
} catch (TimeoutException ex) {
// ignore - expected
}
}
Aggregations