use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest 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);
}
use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest 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);
}
use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest in project scout.rt by eclipse.
the class AbstractJaxWsClientTest method testSetupSleep.
@Test
public void testSetupSleep() {
final int sleepTimeMillis = 500;
SleepRequest req = new SleepRequest();
req.setMillis(sleepTimeMillis);
final JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().getPort();
final long start = System.currentTimeMillis();
try {
port.sleep(req);
} finally {
long dt = System.currentTimeMillis() - start;
if (dt < sleepTimeMillis) {
fail("Operation took less than " + sleepTimeMillis);
}
}
}
use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest in project scout.rt by eclipse.
the class AbstractJaxWsClientTest method testSetupSleepWithReadTimeout.
@Test
public void testSetupSleepWithReadTimeout() {
final int sleepTimeMillis = 5000;
SleepRequest req = new SleepRequest();
req.setMillis(sleepTimeMillis);
final JaxWsConsumerTestServicePortType port = BEANS.get(JaxWsConsumerTestClient.class).newInvocationContext().withReadTimeout(1, TimeUnit.SECONDS).getPort();
try {
port.sleep(req);
fail("invocation is expected to be cancelled");
} catch (WebServiceException e) {
if (!(e.getCause() instanceof SocketTimeoutException)) {
throw e;
}
}
}
use of org.eclipse.scout.jaxws.consumer.jaxwsconsumertestservice.SleepRequest 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());
}
Aggregations