Search in sources :

Example 1 with SetHeaderRequest

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest in project scout.rt by eclipse.

the class AbstractJaxWsClientTest method testAcquirePortInSameTransactionMultipleTimesSleepWithReadTimeoutCheckResponseHeaders.

@Test
public void testAcquirePortInSameTransactionMultipleTimesSleepWithReadTimeoutCheckResponseHeaders() {
    // 1. invoke set header on port0
    final JaxWsConsumerTestServicePortType port0 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    final String testHeaderValue = "test header value";
    SetHeaderRequest headerReq = new SetHeaderRequest();
    headerReq.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    headerReq.setHeaderValue(testHeaderValue);
    port0.setHeader(headerReq);
    assertHttpResponseHeader(port0, X_SCOUT_JAX_WS_TEST_HEADER, testHeaderValue);
    // 2. invoke sleep on port1
    final JaxWsConsumerTestServicePortType port1 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().withReadTimeout(500, TimeUnit.MILLISECONDS).getPort();
    if (BEANS.get(JaxWsImplementorSpecifics.class).isPoolingSupported()) {
        assertSamePort(port0, port1);
    } else {
        assertDifferentPort(port0, port1);
    }
    SleepRequest req = new SleepRequest();
    req.setMillis(5000);
    try {
        port1.sleep(req);
        fail("invocation is expected to be cancelled");
    } catch (WebServiceException e) {
        if (!(e.getCause() instanceof SocketTimeoutException)) {
            throw e;
        }
    }
    assertHttpResponseCode(port1, 0);
    assertHttpResponseHeader(port1, X_SCOUT_JAX_WS_TEST_HEADER, null);
    // 3. invoke echo on port1
    EchoRequest echoReq = new EchoRequest();
    echoReq.setMessage("test message");
    port1.echo(echoReq);
    assertHttpResponseCode(port1, 200);
    assertHttpResponseHeader(port1, X_SCOUT_JAX_WS_TEST_HEADER, null);
}
Also used : SetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest) SleepRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest) SocketTimeoutException(java.net.SocketTimeoutException) WebServiceException(javax.xml.ws.WebServiceException) EchoRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) JaxWsImplementorSpecifics(org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics) Test(org.junit.Test)

Example 2 with SetHeaderRequest

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest in project scout.rt by eclipse.

the class AbstractJaxWsClientTest method testSamePortMultipleTimesSetHeader.

@Test
public void testSamePortMultipleTimesSetHeader() {
    JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    // 1. invoke echo without header
    EchoRequest echoReq = new EchoRequest();
    echoReq.setMessage("test message");
    port.echo(echoReq);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, null);
    // 2. set header
    final String expectedHeader = "test header value";
    SetHeaderRequest req = new SetHeaderRequest();
    req.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    req.setHeaderValue(expectedHeader);
    SetHeaderResponse resp = port.setHeader(req);
    assertNotNull(resp);
    assertEquals("ok", resp.getMessage());
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, expectedHeader);
    // 3. invoke echo without header
    echoReq.setMessage("test message");
    port.echo(echoReq);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, null);
}
Also used : SetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest) SetHeaderResponse(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse) EchoRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) Test(org.junit.Test)

Example 3 with SetHeaderRequest

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest in project scout.rt by eclipse.

the class AbstractJaxWsClientTest method testSetupSetHeader.

@Test
public void testSetupSetHeader() {
    final String expectedHeader = "test header value";
    SetHeaderRequest req = new SetHeaderRequest();
    req.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    req.setHeaderValue(expectedHeader);
    JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    SetHeaderResponse resp = port.setHeader(req);
    assertNotNull(resp);
    assertEquals("ok", resp.getMessage());
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, expectedHeader);
}
Also used : SetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest) SetHeaderResponse(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) Test(org.junit.Test)

Example 4 with SetHeaderRequest

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest in project scout.rt by eclipse.

the class AbstractJaxWsClientTest method testSamePortMultipleTimesSleepWithReadTimeoutCheckResponseHeaders.

@Test
public void testSamePortMultipleTimesSleepWithReadTimeoutCheckResponseHeaders() {
    final JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().withReadTimeout(500, TimeUnit.MILLISECONDS).getPort();
    // 1. invoke set header
    final String testHeaderValue = "test header value";
    SetHeaderRequest headerReq = new SetHeaderRequest();
    headerReq.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    headerReq.setHeaderValue(testHeaderValue);
    port.setHeader(headerReq);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, testHeaderValue);
    // 2. invoke sleep
    SleepRequest req = new SleepRequest();
    req.setMillis(5000);
    try {
        port.sleep(req);
        fail("invocation is expected to be cancelled");
    } catch (WebServiceException e) {
        if (!(e.getCause() instanceof SocketTimeoutException)) {
            throw e;
        }
    }
    assertHttpResponseCode(port, 0);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, null);
    // 3. invoke echo
    EchoRequest echoReq = new EchoRequest();
    echoReq.setMessage("test message");
    port.echo(echoReq);
    assertHttpResponseCode(port, 200);
    assertHttpResponseHeader(port, X_SCOUT_JAX_WS_TEST_HEADER, null);
}
Also used : SetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest) SleepRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest) SocketTimeoutException(java.net.SocketTimeoutException) WebServiceException(javax.xml.ws.WebServiceException) EchoRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) Test(org.junit.Test)

Aggregations

JaxWsConsumerTestServicePortType (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType)4 SetHeaderRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest)4 Test (org.junit.Test)4 EchoRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest)3 SocketTimeoutException (java.net.SocketTimeoutException)2 WebServiceException (javax.xml.ws.WebServiceException)2 SetHeaderResponse (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse)2 SleepRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest)2 JaxWsImplementorSpecifics (org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics)1