Search in sources :

Example 6 with Response

use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.

the class DispatchHello method kkktestHelloRequestResponseJAXBandSource.

/* public void testStubPropertySoapUseActionNegative() {

        try {
            Hello stub = getDynamicStubDynamicServer();
            // get stub
            Boolean prop = (Boolean)((BindingProvider) stub).getRequestContext().get(BindingProvider.SOAPACTION_USE_PROPERTY);
             ((BindingProvider) stub).getRequestContext().get(BindingProvider.SOAPACTION_URI_PROPERTY);

        } catch (Exception ex) {

            if (ex instanceof WebServiceException) {
                System.out.println("Property test passes");
            }
        }
    }
    */
public void kkktestHelloRequestResponseJAXBandSource() throws Exception {
    // test for bug 6194159
    JAXBContext jc = null;
    HelloResponse helloResult = null;
    Hello_Type hello = new Hello_Type();
    jc = createJAXBContext();
    try {
        hello.setArgument("foo");
        hello.setExtra("Test ");
        Dispatch dispatch = getDispatchJAXB();
        Dispatch dispatch2 = getDispatchSource();
        dispatch.getRequestContext().put("com.sun.xml.pw.testprop", "test");
        Response response = dispatch.invokeAsync(hello);
        if (!response.isDone()) {
            dispatch2.invokeAsync(makeStreamSource(helloMsg));
        }
        Object result = response.get();
        assertEquals(((HelloResponse) result).getExtra(), hello.getExtra());
        assertEquals(((HelloResponse) result).getArgument(), hello.getArgument());
    } catch (Exception jex) {
        fail("Expected HelloResponse go Exception");
    }
}
Also used : Response(jakarta.xml.ws.Response) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext) MalformedURLException(java.net.MalformedURLException) WebServiceException(jakarta.xml.ws.WebServiceException) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException)

Example 7 with Response

use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.

the class Hello1CallbackHandler method testHelloAsyncCallback0Handler.

/*
     * Adds handler to increment value of request and response.
     */
public void testHelloAsyncCallback0Handler() throws Exception {
    try {
        // should be no handlers, but to be safe
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
        // test with no handler first
        int orig = 1;
        final IntHolder intHolder = new IntHolder();
        Future<?> response = stub.hello0Async(orig, new AsyncHandler<Integer>() {

            public void handleResponse(Response<Integer> resp) {
                try {
                    // add 10 to make sure this was called
                    intHolder.setValue(resp.get().intValue() + 10);
                } catch (Exception e) {
                    e.printStackTrace();
                    // will cause failure
                    intHolder.setValue(-100);
                }
            }
        });
        // wait, but only up to 15 seconds. if it takes more,
        // it's considered a hangup
        response.get(15, TimeUnit.SECONDS);
        assertEquals("did not get expected value back in response", orig + 10, intHolder.getValue());
        // add handler
        ClientServerTestUtil.addHandlerToBinding(new SOAPTestHandler(), (BindingProvider) stub);
        // 1 per handler invocation
        int diff = 2;
        response = stub.hello0Async(orig, new AsyncHandler<Integer>() {

            public void handleResponse(Response<Integer> resp) {
                try {
                    intHolder.setValue(resp.get().intValue());
                } catch (Exception e) {
                    e.printStackTrace();
                    // will cause failure
                    intHolder.setValue(-100);
                }
            }
        });
        response.get(15, TimeUnit.SECONDS);
        assertEquals("handlers did not execute successfully", orig + diff, intHolder.getValue());
    } finally {
        ClientServerTestUtil.clearHandlers((BindingProvider) stub);
    }
}
Also used : Response(jakarta.xml.ws.Response) AsyncHandler(jakarta.xml.ws.AsyncHandler) SOAPTestHandler(async.wsdl_hello_lit.client.handlers.SOAPTestHandler) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with Response

use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.

the class DispatchHelloLiteralTest method testHelloAsyncPollXMLMulti.

public void testHelloAsyncPollXMLMulti() throws Exception {
    Dispatch dispatch = getDispatchSource();
    int i = 0;
    while (i < 20) {
        Collection<Source> sourceList = makeMsgSource(helloMsg);
        Collection<Source> responseList = makeMsgSource(helloResponse);
        for (Iterator iter = sourceList.iterator(); iter.hasNext(); ) {
            Object sourceObject = iter.next();
            Response result = null;
            result = dispatch.invokeAsync(sourceObject);
            result.get();
        }
        i++;
    }
}
Also used : Response(jakarta.xml.ws.Response) Iterator(java.util.Iterator) Dispatch(jakarta.xml.ws.Dispatch) InputSource(org.xml.sax.InputSource) DOMSource(javax.xml.transform.dom.DOMSource) StreamSource(javax.xml.transform.stream.StreamSource) SAXSource(javax.xml.transform.sax.SAXSource)

Example 9 with Response

use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.

the class DispatchHelloLiteralTest method FAILSMULTITHREADISSUEtestHelloAsyncPollJAXBSource.

// test for bug
public void FAILSMULTITHREADISSUEtestHelloAsyncPollJAXBSource() throws Exception {
    JAXBContext jc = createJAXBContext();
    Hello_Type hello = new Hello_Type();
    HelloResponse helloResult = new HelloResponse();
    hello.setExtra("Test ");
    hello.setArgument("Dispatch ");
    Dispatch dispatch = getDispatchJAXB();
    Dispatch dispatchSrc = getDispatchSource();
    StreamSource streamSource = new StreamSource(new StringReader(helloMsg));
    Response result = dispatch.invokeAsync(hello);
    if (!result.isDone()) {
        dispatchSrc.invoke(streamSource);
    }
    Object obj = result.get();
    HelloResponse res = (HelloResponse) obj;
    assertEquals(result.isCancelled(), false);
    assertEquals(res.getExtra(), hello.getExtra());
    assertEquals(res.getArgument(), hello.getArgument());
}
Also used : Response(jakarta.xml.ws.Response) StreamSource(javax.xml.transform.stream.StreamSource) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext)

Example 10 with Response

use of jakarta.xml.ws.Response in project metro-jax-ws by eclipse-ee4j.

the class DispatchHelloLiteralTest method testHelloAsyncPollJAXB.

public void testHelloAsyncPollJAXB() throws Exception {
    JAXBContext jc = createJAXBContext();
    Hello_Type hello = new Hello_Type();
    HelloResponse helloResult = new HelloResponse();
    hello.setExtra("Test ");
    hello.setArgument("Dispatch ");
    Dispatch dispatch = getDispatchJAXB();
    Response result = dispatch.invokeAsync(hello);
    Object obj = result.get();
    HelloResponse res = (HelloResponse) obj;
    assertEquals(result.isCancelled(), false);
    assertEquals(res.getExtra(), hello.getExtra());
    assertEquals(res.getArgument(), hello.getArgument());
}
Also used : Response(jakarta.xml.ws.Response) Dispatch(jakarta.xml.ws.Dispatch) JAXBContext(jakarta.xml.bind.JAXBContext)

Aggregations

Response (jakarta.xml.ws.Response)11 Dispatch (jakarta.xml.ws.Dispatch)9 JAXBContext (jakarta.xml.bind.JAXBContext)7 StreamSource (javax.xml.transform.stream.StreamSource)4 JAXBException (jakarta.xml.bind.JAXBException)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)2 MalformedURLException (java.net.MalformedURLException)2 Iterator (java.util.Iterator)2 DOMSource (javax.xml.transform.dom.DOMSource)2 SAXSource (javax.xml.transform.sax.SAXSource)2 InputSource (org.xml.sax.InputSource)2 SOAPTestHandler (async.wsdl_hello_lit.client.handlers.SOAPTestHandler)1 AsyncHandler (jakarta.xml.ws.AsyncHandler)1 URISyntaxException (java.net.URISyntaxException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Source (javax.xml.transform.Source)1