use of org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType in project cxf by apache.
the class WSAFromWSDLTest method testAddNumbers2.
@Test
public void testAddNumbers2() throws Exception {
ByteArrayOutputStream input = setupInLogging();
ByteArrayOutputStream output = setupOutLogging();
AddNumbersPortType port = getPort();
assertEquals(3, port.addNumbers2(1, 2));
String expectedOut = BASE_URI + "add2In";
String expectedIn = BASE_URI + "add2Out";
assertTrue(output.toString().indexOf(expectedOut) != -1);
assertTrue(input.toString().indexOf(expectedIn) != -1);
}
use of org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType in project cxf by apache.
the class WSAFromWSDLTest method testAddNumbers3.
@Test
public void testAddNumbers3() throws Exception {
ByteArrayOutputStream input = setupInLogging();
ByteArrayOutputStream output = setupOutLogging();
AddNumbersPortType port = getPort();
assertEquals(3, port.addNumbers3(1, 2));
String expectedOut = "3in";
String expectedIn = "3out";
assertTrue(output.toString().indexOf(expectedOut) != -1);
assertTrue(input.toString().indexOf(expectedIn) != -1);
}
use of org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType in project cxf by apache.
the class WSAPureWsdlTest method testProviderEndpoint.
@Test
public void testProviderEndpoint() throws Exception {
String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
ByteArrayOutputStream input = setupInLogging();
ByteArrayOutputStream output = setupOutLogging();
AddNumbersPortType port = getPort();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add-provider");
assertEquals(3, port.addNumbers(1, 2));
assertLogContains(output.toString(), "//wsa:Action", base + "addNumbersRequest");
assertLogContains(input.toString(), "//wsa:Action", base + "addNumbersResponse");
output.reset();
input.reset();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add-providernows");
assertEquals(3, port.addNumbers(1, 2));
assertLogContains(output.toString(), "//wsa:Action", base + "addNumbersRequest");
assertLogContains(input.toString(), "//wsa:Action", base + "addNumbersResponse");
}
use of org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType in project cxf by apache.
the class WSAPureWsdlTest method testBasicInvocationTimeouts.
@Test
public void testBasicInvocationTimeouts() throws Exception {
AddNumbersPortType port = getPort();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
HTTPConduit conduit = (HTTPConduit) ((Client) port).getConduit();
conduit.getClient().setConnectionTimeout(25);
conduit.getClient().setReceiveTimeout(10);
try {
// read timeout
port.addNumbersAsync(5092, 25).get();
fail("should have failed");
} catch (Exception t) {
// expected
assertTrue(t.getCause().toString(), t.getCause() instanceof java.net.SocketTimeoutException);
}
AsyncHandler<AddNumbersResponse> handler = new AsyncHandler<AddNumbersResponse>() {
public void handleResponse(Response<AddNumbersResponse> res) {
// System.out.println("in handle response");
synchronized (this) {
notifyAll();
}
}
};
synchronized (handler) {
port.addNumbersAsync(5092, 25, handler);
handler.wait(1000);
}
try {
// connection timeout
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT2 + "/jaxws/add");
port.addNumbersAsync(25, 25).get();
fail("should have failed");
} catch (Exception t) {
// expected
assertTrue(t.getCause().getCause().toString(), t.getCause().getCause() instanceof java.net.ConnectException || t.getCause().getCause() instanceof java.net.SocketTimeoutException);
}
synchronized (handler) {
port.addNumbersAsync(25, 25, handler);
handler.wait(1000);
}
MAPCodec mp = getMAPCodec((Client) port);
assertEquals(0, mp.getUncorrelatedExchanges().size());
}
use of org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType in project cxf by apache.
the class WSAPureWsdlTest method testBasicInvocation.
@Test
public void testBasicInvocation() throws Exception {
ByteArrayOutputStream input = setupInLogging();
ByteArrayOutputStream output = setupOutLogging();
Response<AddNumbersResponse> resp;
AddNumbersPortType port = getPort();
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
assertEquals(3, port.addNumbers(1, 2));
String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
assertLogContains(output.toString(), "//wsa:Action", base + "addNumbersRequest");
assertLogContains(input.toString(), "//wsa:Action", base + "addNumbersResponse");
resp = port.addNumbers3Async(1, 2);
assertEquals(3, resp.get().getReturn());
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/doesntexist");
resp = port.addNumbers3Async(1, 2);
try {
resp.get();
} catch (ExecutionException ex) {
assertTrue("Found " + ex.getCause().getClass(), ex.getCause() instanceof IOException);
Client c = ClientProxy.getClient(port);
for (Interceptor<? extends Message> m : c.getOutInterceptors()) {
if (m instanceof MAPCodec) {
assertTrue(((MAPCodec) m).getUncorrelatedExchanges().isEmpty());
}
}
}
}
Aggregations