Examples of AsyncPort


Examples of org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncPort

     *               the record for longest method name in Apache here.
     */
    public void testAsyncCallback_asyncMEP_asyncWire_Addressing_WebServiceException()
            throws Exception {
        setupAddressingAndListener();
        AsyncPort port = getPort(new AddressingFeature());

        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                DOCLITWR_ASYNC_ENDPOINT);
        //rc.put(AddressingConstants.WSA_REPLY_TO, AddressingConstants.Final.WSA_ANONYMOUS_URL);
        rc.put("org.apache.axis2.jaxws.use.async.mep", Boolean.TRUE);

        CallbackHandler<ThrowExceptionResponse> handler = new CallbackHandler<ThrowExceptionResponse>();
        Future<?> resp = port.throwExceptionAsync(ExceptionTypeEnum.WSE,
                handler);

        AsyncClient.waitBlocking(resp);
        Exception e = null;
        try {
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncPort

     *               will throw a wsdl:fault which should result in a
     *               EE/SimpleFault
     */
    public void testAsyncCallback_asyncMEP_WsdlFault() throws Exception {

        AsyncPort port = getPort();
        CallbackHandler<ThrowExceptionResponse> handler = new CallbackHandler<ThrowExceptionResponse>();
        Future<?> resp = port.throwExceptionAsync(ExceptionTypeEnum.WSDL_FAULT,
                handler);

        AsyncClient.waitBlocking(resp);

        try {
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncPort

    }
   
    private AsyncPort getPort(WebServiceFeature... features) {

        AsyncService service = new AsyncService();
        AsyncPort port = service.getAsyncPort(features);
        assertNotNull("Port is null", port);

        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                DOCLITWR_ASYNC_ENDPOINT);
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.asyncdoclit.client.AsyncPort

     */
 
    public void testAsyncCallback_asyncWire_ConnectException() throws Exception {
        setupAddressingAndListener();
       
        AsyncPort port = getPort();
        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, CONNECT_EXCEPTION_ENDPOINT);
        rc.put("org.apache.axis2.jaxws.use.async.mep", Boolean.TRUE);

        try {
            String resp = port.throwException(ExceptionTypeEnum.WSE);
            fail("Did not get an exception as expected");
        } catch (Exception ee) {
            assertTrue("ExecutionException.getCause should be an instance of WebServiceException",
                       ee instanceof WebServiceException);
            assertTrue("Didn't get a cause within the WebServiceException",
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort

    public void testService_isAlive() throws Exception {
        final String MESSAGE = "testServiceAlive";

        String title = myClassName + " : " + getName() + " : ";

        AsyncPort port = getPort((Executor)null);

        String req1base = "sleepAsync";
        String req2base = "remappedAsync";

        String request1 = null;
        String request2 = null;

        for (int i = 0; i < 10; i++) {
           
            request1 = req1base + "_" + i;
            request2 = req2base + "_" + i;

            TestLogger.logger.debug(title + "iteration [" + i + "] using request1 [" + request1 +
                    "]  request2 [" + request2 + "]");

            // submit request #1 to the server-side web service that
            // the web service will keep until we ask for it
            Response<SleepResponse> resp1 = port.sleepAsync(request1);

            // submit request #2 to the server that essentially processes
            // without delay
            Response<CustomAsyncResponse> resp2 = port.remappedAsync(request2);

            // wait until the response for request #2 is done
            waitBlocking(resp2);

            // check the waiting request #1
            String asleep = port.isAsleep(request1);
            //System.out.println(title+"iteration ["+i+"]   port.isAsleep(request1 ["+request1+"]) = ["+asleep+"]");

            // wakeup the waiting request #1
            String wake = port.wakeUp(request1);
            //System.out.println(title+"iteration ["+i+"]   port.wakeUp(request1 ["+request1+"]) = ["+wake+"]");

            // wait until the response for request #1 is done
            waitBlocking(resp1);
       
            // get the responses
            String req1_result = null;
            String req2_result = null;

            try {
                req1_result = resp1.get().getMessage();
                req2_result = resp2.get().getResponse();
            } catch (Exception e) {
                TestLogger.logger.debug(
                        title + "iteration [" + i + "] using request1 [" + request1 +
                                "]  request2 [" + request2 + "] :  got exception [" +
                                e.getClass().getName() + "]  [" + e.getMessage() + "] ");
                e.printStackTrace();
                fail(e.toString());
            }

            // check status on request #1
            assertEquals("sleepAsync did not sleep as expected", request1, asleep);
            assertEquals("sleepAsync did not return expected response ", request1, req1_result);

            // check status on request #2
            assertEquals("remappedAsync did not return expected response", request2, req2_result);
           

            // Calling get() again should return the same object as the first call to get()
            assertEquals("sleepAsync did not return expected response ", request1, resp1.get().getMessage());
            assertEquals("remappedAsync did not return expected response", request2, resp2.get().getResponse());
           
        }
       
        // check the callback operation
    CallbackHandler<SleepResponse> sleepCallbackHandler = new CallbackHandler<SleepResponse>();

        request1 = req1base + "_with_Callback";
        //System.out.println(title+" port.sleepAsync("+request1+", callbackHander)  being submitted....");
    Future<?> sr = port.sleepAsync(request1, sleepCallbackHandler);

        // wait a bit for the server to process the request ...
        Thread.sleep(500);

        // check the waiting request
        String asleepWithCallback = port.isAsleep(request1);
        //System.out.println(title+" port.isAsleep("+request1+") = ["+asleepWithCallback+"]");

        // wakeup the waiting request
        String wake = port.wakeUp(request1);
        //System.out.println(title+" port.wakeUp("+request1+") = ["+wake+"]");

        // wait a bit..
        Thread.sleep(500);
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort

        final String MESSAGE = "testExecutorShutdownNow";

        String title = myClassName + " : " + getName() + " : ";

        AsyncService service = getService(null);
        AsyncPort port = getPort(service);

    // get the default executor and check to make sure it is an executor service
        ExecutorService ex = null;
        Executor executor = service.getExecutor();
        if ((executor != null) && (executor instanceof ExecutorService))
        {
            ex = (ExecutorService) executor;
        }
        else
        {
            TestLogger.logger.debug(title + " No executor service available. Nothing to test.");
            return;
        }


        // submit a request to the server that will wait until we ask for it
    CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();

        String request1 = "sleepAsync_with_Callback_1";

        TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
                ", callbackHander1)  #1 being submitted....");
    Future<?> sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
        TestLogger.logger.debug(
                title + " port.sleepAsync(" + request1 + ", callbackHander1)  #1 .....submitted.");

        // wait a bit to make sure that the server has the request
        Thread.sleep(1000);

    // tell the executor to shutdown immediately, which
        // attempts to stop all actively executing tasks via Thread.interrupt()
        // and should prevent new tasks from being submitted
        TestLogger.logger
                .debug(title + " shutting down executor [" + ex.getClass().getName() + "]");
        ex.shutdownNow();

        // check the waiting request
        TestLogger.logger.debug(title + " port.isAsleep(" + request1 + ") #1 being submitted....");
        String asleepWithCallback1 = port.isAsleep(request1);
        TestLogger.logger.debug(
                title + " port.isAsleep(" + request1 + ") #1 = [" + asleepWithCallback1 + "]");

        // wakeup the waiting request
        TestLogger.logger.debug(title + " port.wakeUp(request1) #1 being submitted....");
        String wake1 = port.wakeUp(request1);
        TestLogger.logger.debug(title + " port.wakeUp(" + request1 + ") #1 = [" + wake1 + "]");

        // wait a bit..
        Thread.sleep(2000);
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort

        final String MESSAGE = "testExecutorShutdownNow_2";

        String title = myClassName + " : " + getName() + " : ";

        AsyncService service = getService(null);
        AsyncPort port = getPort(service);

    // get the default executor and check to make sure it is an executor service
    ExecutorService ex = Executors.newSingleThreadExecutor();
    service.setExecutor(ex);


        // submit a request to the server that will wait until we ask for it
    CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();

        String request1 = "sleepAsync_with_Callback_1";

        TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
                ", callbackHander1)  #1 being submitted....");
    Future<?> sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
        TestLogger.logger.debug(
                title + " port.sleepAsync(" + request1 + ", callbackHander1)  #1 .....submitted.");

        // wait a bit to make sure that the server has the request
        Thread.sleep(1000);

    // tell the executor to shutdown immediately, which
        // attempts to stop all actively executing tasks via Thread.interrupt()
        // and should prevent new tasks from being submitted
        TestLogger.logger
                .debug(title + " shutting down executor [" + ex.getClass().getName() + "]");
        ex.shutdownNow();

        // check the waiting request
        TestLogger.logger.debug(title + " port.isAsleep(" + request1 + ") #1 being submitted....");
        String asleepWithCallback1 = port.isAsleep(request1);
        TestLogger.logger.debug(
                title + " port.isAsleep(" + request1 + ") #1 = [" + asleepWithCallback1 + "]");

        // wakeup the waiting request
        TestLogger.logger.debug(title + " port.wakeUp(request1) #1 being submitted....");
        String wake1 = port.wakeUp(request1);
        TestLogger.logger.debug(title + " port.wakeUp(" + request1 + ") #1 = [" + wake1 + "]");

        // wait a bit..
        Thread.sleep(2000);
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort

        final String MESSAGE = "testExecutorShutdownNow_3";

        String title = myClassName + " : " + getName() + " : ";

        AsyncService service = getService(null);
        AsyncPort port = getPort(service);

    // get the default executor and check to make sure it is an executor service
        ExecutorService ex = null;
        Executor executor = service.getExecutor();
        if ((executor != null) && (executor instanceof ExecutorService))
        {
            ex = (ExecutorService) executor;

            // tell the executor to shutdown immediately, which
            // attempts to stop all actively executing tasks via Thread.interrupt()
            // and should prevent new tasks from being submitted
            TestLogger.logger
                    .debug(title + " shutting down executor [" + ex.getClass().getName() + "]");
            ex.shutdownNow();
        }
        else
        {
            TestLogger.logger.debug(title + " No executor service available. Nothing to test.");
            return;
        }


        boolean gotRequestException = false;

        String request1 = "sleepAsync_with_Callback_1";
        CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
        Future<?> sr1 = null;

        try
        {
            // submit a request to the server that will wait until we ask for it
            TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
                    ", callbackHander1)  #1 being submitted....");
            sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
            TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
                    ", callbackHander1)  #1 .....submitted.");
        }
        catch (Exception exc)
        {
            TestLogger.logger.debug(title + " request [" + request1 + "] :  got exception [" +
                    exc.getClass().getName() + "]  [" + exc.getMessage() + "] ");
            gotRequestException = true;
        }

        // if the request went through, continue processing to see if the response is stopped
        // this makes sure that the server doesn't keep the request forever
        boolean gotResponseException = false;

        if (!gotRequestException)
        {
            // wakeup the waiting request
            TestLogger.logger.debug(title + " port.wakeUp(request1) #1 being submitted....");
            String wake1 = port.wakeUp(request1);
            TestLogger.logger.debug(title + " port.wakeUp(" + request1 + ") #1 = [" + wake1 + "]");

            // try to get the response
            try {
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort

    }


    private AsyncPort getPort(AsyncService service) {

        AsyncPort port = service.getAsyncPort();
        assertNotNull("Port is null", port);

        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                DOCLITWR_ASYNC_ENDPOINT);
View Full Code Here

Examples of org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort

     * specific Executor
     */
    private AsyncPort getPort(Executor ex) {
        AsyncService service = getService(ex);

        AsyncPort port = service.getAsyncPort();
        assertNotNull("Port is null", port);

        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                DOCLITWR_ASYNC_ENDPOINT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.