use of org.apache.hello_world_soap_http.types.GreetMeResponse 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
}
}
use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.
the class BareInInterceptorTest method testInterceptorOutbound.
@Test
public void testInterceptorOutbound() throws Exception {
setUpUsingHelloWorld();
BareInInterceptor interceptor = new BareInInterceptor();
message.setContent(XMLStreamReader.class, XMLInputFactory.newInstance().createXMLStreamReader(getTestStream(getClass(), "resources/GreetMeDocLiteralResp.xml")));
message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
interceptor.handleMessage(message);
List<?> parameters = message.getContent(List.class);
assertEquals(1, parameters.size());
Object obj = parameters.get(0);
assertTrue(obj instanceof GreetMeResponse);
GreetMeResponse greet = (GreetMeResponse) obj;
assertEquals("TestSOAPOutputPMessage", greet.getResponseType());
}
use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteWrapperReturn.
@Test
public void testWriteWrapperReturn() throws Exception {
JAXBDataBinding db = getTestWriterFactory(GreetMeResponse.class);
DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
assertNotNull(dw);
GreetMeResponse retVal = new GreetMeResponse();
retVal.setResponseType("TESTOUTPUTMESSAGE");
dw.write(retVal, streamWriter);
streamWriter.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMeResponse"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "responseType"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextText(reader);
assertEquals("TESTOUTPUTMESSAGE", reader.getText());
}
use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.
the class NettyClientTest method testCallAsync.
@Test
public void testCallAsync() throws Exception {
updateAddressPort(g, PORT);
GreetMeResponse resp = (GreetMeResponse) g.greetMeAsync("asyncTest", new AsyncHandler<GreetMeResponse>() {
public void handleResponse(Response<GreetMeResponse> res) {
try {
res.get().getResponseType();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}).get();
assertEquals("Hello asyncTest", resp.getResponseType());
MyLaterResponseHandler handler = new MyLaterResponseHandler();
g.greetMeLaterAsync(1000, handler).get();
// need to check the result here
assertEquals("Hello, finally!", handler.getResponse().getResponseType());
}
use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.
the class AsyncHTTPConduitTest method testCallAsync.
@Test
public void testCallAsync() throws Exception {
updateAddressPort(g, PORT);
GreetMeResponse resp = (GreetMeResponse) g.greetMeAsync(request, new AsyncHandler<GreetMeResponse>() {
public void handleResponse(Response<GreetMeResponse> res) {
try {
res.get().getResponseType();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
}).get();
assertEquals("Hello " + request, resp.getResponseType());
g.greetMeLaterAsync(1000, new AsyncHandler<GreetMeLaterResponse>() {
public void handleResponse(Response<GreetMeLaterResponse> res) {
}
}).get();
}
Aggregations