Search in sources :

Example 1 with GreetMeResponse

use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.

the class BareOutInterceptorTest method testWriteOutbound.

@Test
public void testWriteOutbound() throws Exception {
    GreetMeResponse greetMe = new GreetMeResponse();
    greetMe.setResponseType("responseType");
    message.setContent(List.class, Arrays.asList(greetMe));
    interceptor.handleMessage(message);
    writer.close();
    assertNull(message.getContent(Exception.class));
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    // System.err.println(baos.toString());
    XMLStreamReader xr = StaxUtils.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());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) QName(javax.xml.namespace.QName) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) Test(org.junit.Test)

Example 2 with GreetMeResponse

use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.

the class XMLStreamDataReaderTest method testReadWrapperReturn.

@Test
public void testReadWrapperReturn() throws Exception {
    JAXBDataBinding db = getDataBinding(GreetMeResponse.class);
    reader = getTestReader("../resources/GreetMeDocLiteralResp.xml");
    assertNotNull(reader);
    DataReader<XMLStreamReader> dr = db.createReader(XMLStreamReader.class);
    assertNotNull(dr);
    Object retValue = dr.read(reader);
    assertNotNull(retValue);
    assertTrue(retValue instanceof GreetMeResponse);
    assertEquals("TestSOAPOutputPMessage", ((GreetMeResponse) retValue).getResponseType());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) Test(org.junit.Test)

Example 3 with GreetMeResponse

use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.

the class DispatchClientServerTest method testJAXBObjectPAYLOADWithFeature.

@Test
public void testJAXBObjectPAYLOADWithFeature() throws Exception {
    createBus("org/apache/cxf/systest/dispatch/client-config.xml");
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    String bindingId = "http://schemas.xmlsoap.org/wsdl/soap/";
    String endpointUrl = "http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort";
    Service service = Service.create(wsdl, SERVICE_NAME);
    service.addPort(PORT_NAME, bindingId, endpointUrl);
    assertNotNull(service);
    JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
    Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD);
    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();
    assertEquals("Expected string, " + expected, expected, responseValue);
    assertEquals("Feature should be applied", 1, TestDispatchFeature.getCount());
    assertEquals("Feature based interceptors should be added", 1, TestDispatchFeature.getCount());
    assertEquals("Feature based In interceptors has be added to in chain.", 1, TestDispatchFeature.getInInterceptorCount());
    assertEquals("Feature based interceptors has to be added to out chain.", 1, TestDispatchFeature.getOutInterceptorCount());
    bus.shutdown(true);
}
Also used : GreetMe(org.apache.hello_world_soap_http.types.GreetMe) SOAPService(org.apache.hello_world_soap_http.SOAPService) Service(javax.xml.ws.Service) WebService(javax.jws.WebService) JAXBContext(javax.xml.bind.JAXBContext) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) URL(java.net.URL) Test(org.junit.Test)

Example 4 with GreetMeResponse

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 | ExecutionException e) {
                e.printStackTrace();
            }
        }
    }).get();
    assertEquals("Hello " + request, resp.getResponseType());
    g.greetMeLaterAsync(1000, new AsyncHandler<GreetMeLaterResponse>() {

        public void handleResponse(Response<GreetMeLaterResponse> res) {
        }
    }).get();
}
Also used : GreetMeLaterResponse(org.apache.hello_world_soap_http.types.GreetMeLaterResponse) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) Response(javax.xml.ws.Response) AsyncHandler(javax.xml.ws.AsyncHandler) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) Test(org.junit.Test)

Example 5 with GreetMeResponse

use of org.apache.hello_world_soap_http.types.GreetMeResponse in project cxf by apache.

the class AsyncHTTPConduitTest method testCallAsyncCallbackInvokedOnlyOnce.

@Test
public void testCallAsyncCallbackInvokedOnlyOnce() throws Exception {
    // This test is especially targeted for RHEL 6.8
    updateAddressPort(g, PORT_INV);
    int repeat = 100;
    final AtomicInteger count = new AtomicInteger(0);
    for (int i = 0; i < repeat; i++) {
        try {
            g.greetMeAsync(request, new AsyncHandler<GreetMeResponse>() {

                public void handleResponse(Response<GreetMeResponse> res) {
                    count.incrementAndGet();
                }
            }).get();
        } catch (Exception e) {
        }
    }
    Thread.sleep(1000);
    assertEquals("Callback should be invoked only once per request", repeat, count.intValue());
}
Also used : GreetMeLaterResponse(org.apache.hello_world_soap_http.types.GreetMeLaterResponse) GreetMeResponse(org.apache.hello_world_soap_http.types.GreetMeResponse) Response(javax.xml.ws.Response) AsyncHandler(javax.xml.ws.AsyncHandler) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Endpoint(javax.xml.ws.Endpoint) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) 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