Search in sources :

Example 1 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testAcquirePortInSameTransactionMultipleTimesEcho.

/*
   * ************************************************************
   * Test acquire port in same transaction multiple times
   * ************************************************************/
@Test
public void testAcquirePortInSameTransactionMultipleTimesEcho() {
    JaxWsConsumerTestServicePortType port0 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    assertSendEcho(port0, 0);
    JaxWsConsumerTestServicePortType port1 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    if (BEANS.get(JaxWsImplementorSpecifics.class).isPoolingSupported()) {
        assertSamePort(port0, port1);
    } else {
        assertDifferentPort(port0, port1);
    }
    assertSendEcho(port1, 1);
}
Also used : JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) JaxWsImplementorSpecifics(org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics) Test(org.junit.Test)

Example 2 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testAcquirePortConcurrentlyInDifferentTransactions.

@Test
public void testAcquirePortConcurrentlyInDifferentTransactions() throws InterruptedException {
    final CountDownLatch txn1InitLatch = new CountDownLatch(1);
    final CountDownLatch txn2InitLatch = new CountDownLatch(1);
    final Holder<JaxWsConsumerTestServicePortType> txn1PortHolder = new Holder<>(JaxWsConsumerTestServicePortType.class);
    final Holder<JaxWsConsumerTestServicePortType> txn2PortHolder = new Holder<>(JaxWsConsumerTestServicePortType.class);
    Jobs.schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            JaxWsConsumerTestServicePortType port0 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            assertSendEcho(port0, 0);
            txn1PortHolder.setValue(port0);
            txn1InitLatch.countDown();
            txn2InitLatch.await();
            JaxWsConsumerTestServicePortType port1 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            assertSamePort(port0, port1);
            assertSendEcho(port1, 1);
        }
    }, Jobs.newInput().withRunContext(ServerRunContexts.empty()));
    txn1InitLatch.await();
    Jobs.schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            JaxWsConsumerTestServicePortType port0 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            assertSendEcho(port0, 0);
            txn2PortHolder.setValue(port0);
            txn2InitLatch.countDown();
            JaxWsConsumerTestServicePortType port1 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            assertSamePort(port0, port1);
            assertSendEcho(port1, 1);
        }
    }, Jobs.newInput().withRunContext(ServerRunContexts.empty()));
    txn2InitLatch.await();
    assertDifferentPort(txn1PortHolder.getValue(), txn2PortHolder.getValue());
}
Also used : 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 3 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testAcquirePortInSameTransactionMultipleTimesGetHeader.

@Test
public void testAcquirePortInSameTransactionMultipleTimesGetHeader() {
    GetHeaderRequest req = new GetHeaderRequest();
    req.setHeaderName(X_SCOUT_JAX_WS_TEST_HEADER);
    // 1. add HTTP header on port0
    JaxWsConsumerTestServicePortType port0 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    final String headerValueSent = "test header value";
    BEANS.get(JaxWsImplementorSpecifics.class).setHttpRequestHeader(((BindingProvider) port0).getRequestContext(), X_SCOUT_JAX_WS_TEST_HEADER, headerValueSent);
    GetHeaderResponse resp = port0.getHeader(req);
    assertNotNull(resp);
    assertTrue(resp.isHeaderSet());
    assertEquals(headerValueSent, resp.getHeaderValue());
    // 2. acquire port1 and do not set a header
    JaxWsConsumerTestServicePortType port1 = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
    if (BEANS.get(JaxWsImplementorSpecifics.class).isPoolingSupported()) {
        assertSamePort(port0, port1);
    } else {
        assertDifferentPort(port0, port1);
    }
    resp = port1.getHeader(req);
    assertNotNull(resp);
    assertFalse(resp.isHeaderSet());
    assertNull(resp.getHeaderValue());
}
Also used : GetHeaderResponse(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.GetHeaderResponse) GetHeaderRequest(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.GetHeaderRequest) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) JaxWsImplementorSpecifics(org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics) Test(org.junit.Test)

Example 4 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testAcquirePortInDifferentTransactions.

/*
   * ************************************************************
   * Test acquire port in different transactions
   * ************************************************************/
@Test
public void testAcquirePortInDifferentTransactions() 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();
    ServerRunContexts.copyCurrent().run(new IRunnable() {

        @Override
        public void run() throws Exception {
            JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
            assertSendEcho(port, 0);
            txn1PortHolder.setValue(port);
        }
    });
    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);
        }
    });
    if (BEANS.get(JaxWsImplementorSpecifics.class).isPoolingSupported()) {
        assertSamePort(txn1PortHolder.getValue(), txn2PortHolder.getValue());
    } else {
        assertDifferentPort(txn1PortHolder.getValue(), txn2PortHolder.getValue());
    }
}
Also used : Holder(org.eclipse.scout.rt.platform.holders.Holder) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) JaxWsConsumerTestServicePortType(org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.JaxWsConsumerTestServicePortType) SocketTimeoutException(java.net.SocketTimeoutException) WebServiceException(javax.xml.ws.WebServiceException) JaxWsImplementorSpecifics(org.eclipse.scout.rt.server.jaxws.implementor.JaxWsImplementorSpecifics) Test(org.junit.Test)

Example 5 with JaxWsConsumerTestServicePortType

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

the class AbstractJaxWsClientTest method testSamePortMultipleTimesSleepWithReadTimeoutCheckResponseCode.

@Test
public void testSamePortMultipleTimesSleepWithReadTimeoutCheckResponseCode() {
    final JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().withReadTimeout(500, TimeUnit.MILLISECONDS).getPort();
    // 1. invoke echo, response code 200 expected
    EchoRequest echoReq = new EchoRequest();
    echoReq.setMessage("test message");
    port.echo(echoReq);
    assertHttpResponseCode(port, 200);
    // 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);
    // 3. invoke echo again, response code 200 expected
    port.echo(echoReq);
    assertHttpResponseCode(port, 200);
}
Also used : 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