Search in sources :

Example 16 with GreetMeResponse

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());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) ArrayList(java.util.ArrayList) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) BareDocumentResponse(org.apache.hello_world_soap_http.types.BareDocumentResponse) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) GreetMeLaterResponse(org.apache.hello_world_soap_http.types.GreetMeLaterResponse) Response(javax.xml.ws.Response) Executor(java.util.concurrent.Executor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Greeter(org.apache.hello_world_soap_http.Greeter) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Aggregations

GreetMeResponse (org.apache.hello_world_soap_http.types.GreetMeResponse)16 Test (org.junit.Test)15 Response (javax.xml.ws.Response)8 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)8 AsyncHandler (javax.xml.ws.AsyncHandler)7 ExecutionException (java.util.concurrent.ExecutionException)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Endpoint (javax.xml.ws.Endpoint)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URL (java.net.URL)2 TimeoutException (java.util.concurrent.TimeoutException)2 QName (javax.xml.namespace.QName)2 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)2 DepthXMLStreamReader (org.apache.cxf.staxutils.DepthXMLStreamReader)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 SOAPService (org.apache.hello_world_soap_http.SOAPService)2 GreetMe (org.apache.hello_world_soap_http.types.GreetMe)2 SocketTimeoutException (java.net.SocketTimeoutException)1 ArrayList (java.util.ArrayList)1