Search in sources :

Example 11 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testAcquirePortInDifferentTransactionsCancelFirstOne.

/**
 * Canceling a running web service invocation invalidates the port. This test verifies, that the canceled port is not
 * put back into the pool.
 */
@Test
public void testAcquirePortInDifferentTransactionsCancelFirstOne() throws InterruptedException {
    final Holder<JaxWsConsumerTestServicePortType> txn1PortHolder = new Holder<>(JaxWsConsumerTestServicePortType.class);
    final Holder<JaxWsConsumerTestServicePortType> txn2PortHolder = new Holder<>(JaxWsConsumerTestServicePortType.class);
    // This test case expects at most one port in the pool. It is guaranteed by discarding all pooled entries.
    BEANS.get(JaxWsConsumerTestClient.class).discardAllPoolEntries();
    final CountDownLatch requestRunningLatch = new CountDownLatch(1);
    final IFuture<Void> future = Jobs.schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            txn1PortHolder.setValue(port);
            SleepRequest req = new SleepRequest();
            req.setMillis(1000);
            requestRunningLatch.countDown();
            port.sleep(req);
        }
    }, Jobs.newInput().withRunContext(ServerRunContexts.copyCurrent()).withExceptionHandling(null, true));
    requestRunningLatch.await();
    SleepUtil.sleepSafe(50, TimeUnit.MILLISECONDS);
    Jobs.schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            future.cancel(true);
        }
    }, Jobs.newInput().withRunContext(ServerRunContexts.copyCurrent()));
    try {
        future.awaitDone();
    } catch (WebServiceRequestCancelledException e) {
    // NOSONAR
    // expected
    }
    assertTrue(future.isCancelled());
    ServerRunContexts.copyCurrent().run(new IRunnable() {

        @Override
        public void run() throws Exception {
            JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            assertSendEcho(port, 0);
            txn2PortHolder.setValue(port);
        }
    });
    assertDifferentPort(txn1PortHolder.getValue(), txn2PortHolder.getValue());
}
Also used : SleepRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest) Holder(org.eclipse.scout.rt.platform.holders.Holder) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) CountDownLatch(java.util.concurrent.CountDownLatch) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) SocketTimeoutException(java.net.SocketTimeoutException) WebServiceException(javax.xml.ws.WebServiceException) Test(org.junit.Test)

Example 12 with JaxWsConsumerTestServicePortType

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType 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 13 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testDifferentPortsInSameTransaction.

/*
   * ************************************************************
   * Test invoke different web services in same transaction
   * ************************************************************/
@Test
public void testDifferentPortsInSameTransaction() {
    JaxWsConsumerTestServicePortType echoPort = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    assertSendEcho(echoPort, 0);
    JaxWsPingTestServicePortType pingPort = BEANS.get(JaxWsPingTestClient.class).newInvocationContext().getPort();
    assertNotSame(echoPort, pingPort);
    PingRequest pingRequest = new PingRequest();
    pingRequest.setMessage("ping");
    PingResponse pingResponse = pingPort.ping(pingRequest);
    assertNotNull(pingResponse);
    assertEquals("ping", pingResponse.getMessage());
}
Also used : PingRequest(org.eclipse.scout.jaxws.consumer.jaxwspingtestservice.PingRequest) JaxWsPingTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwspingtestservice.JaxWsPingTestServicePortType) PingResponse(org.eclipse.scout.jaxws.consumer.jaxwspingtestservice.PingResponse) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) Test(org.junit.Test)

Example 14 with JaxWsConsumerTestServicePortType

use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType 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)14 Test (org.junit.Test)14 SocketTimeoutException (java.net.SocketTimeoutException)7 WebServiceException (javax.xml.ws.WebServiceException)7 SleepRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest)6 JaxWsImplementorSpecifics (org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics)5 EchoRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.EchoRequest)4 SetHeaderRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderRequest)4 Holder (org.eclipse.scout.rt.platform.holders.Holder)3 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 GetHeaderRequest (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.GetHeaderRequest)2 GetHeaderResponse (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.GetHeaderResponse)2 SetHeaderResponse (org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SetHeaderResponse)2 JaxWsPingTestServicePortType (org.eclipse.scout.jaxws.consumer.jaxwspingtestservice.JaxWsPingTestServicePortType)1 PingRequest (org.eclipse.scout.jaxws.consumer.jaxwspingtestservice.PingRequest)1 PingResponse (org.eclipse.scout.jaxws.consumer.jaxwspingtestservice.PingResponse)1