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);
}
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());
}
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());
}
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());
}
}
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);
}
Aggregations