use of org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch in project scout.rt by eclipse.
the class FutureAwaitTest method testAwaitDoneAndGetWithTimeout_Timeout.
@Test(timeout = 5000)
public void testAwaitDoneAndGetWithTimeout_Timeout() throws java.lang.InterruptedException {
final BlockingCountDownLatch setupLatch = new BlockingCountDownLatch(1);
// Init
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
setupLatch.countDownAndBlock();
return "result";
}
}, Jobs.newInput().withExceptionHandling(null, false));
// Wait until ready
assertTrue(setupLatch.await());
// Run the test and verify
try {
future.awaitDoneAndGet(5, TimeUnit.MILLISECONDS);
fail("timeout expected");
} catch (TimedOutError e) {
// NOOP
}
// cleanup
setupLatch.unblock();
Jobs.getJobManager().awaitDone(Jobs.newFutureFilterBuilder().andMatchFuture(future).toFilter(), 10, TimeUnit.SECONDS);
}
use of org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch in project scout.rt by eclipse.
the class FutureAwaitTest method testAwaitDone_Cancelled.
@Test(timeout = 5000)
public void testAwaitDone_Cancelled() throws java.lang.InterruptedException {
final BlockingCountDownLatch setupLatch = new BlockingCountDownLatch(1);
// Init
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
setupLatch.countDownAndBlock();
return "result";
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()));
// Wait until ready
assertTrue(setupLatch.await());
// Run the test and verify
future.cancel(false);
assertTrue(future.isCancelled());
future.awaitDone();
try {
future.awaitDoneAndGet();
fail("cancellation expected");
} catch (FutureCancelledError e) {
// NOOP
}
}
use of org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch in project scout.rt by eclipse.
the class FutureAwaitTest method testJobManagerAwaitDone_Cancelled.
@Test(timeout = 5000)
public void testJobManagerAwaitDone_Cancelled() throws java.lang.InterruptedException {
final BlockingCountDownLatch setupLatch = new BlockingCountDownLatch(1);
// Init
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
setupLatch.countDownAndBlock();
return "result";
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()));
// Wait until ready
assertTrue(setupLatch.await());
// Run the test and verify
future.cancel(false);
Jobs.getJobManager().awaitDone(Jobs.newFutureFilterBuilder().andMatchFuture(future).toFilter(), 10, TimeUnit.SECONDS);
assertTrue(future.isCancelled());
setupLatch.unblock();
}
use of org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch in project scout.rt by eclipse.
the class FutureAwaitTest method testJobManagerAwaitDone_Timeout.
@Test(timeout = 5000)
public void testJobManagerAwaitDone_Timeout() throws java.lang.InterruptedException {
final BlockingCountDownLatch setupLatch = new BlockingCountDownLatch(1);
// Init
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
setupLatch.countDownAndBlock();
return "result";
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()));
// Wait until ready
assertTrue(setupLatch.await());
// Run the test and verify
try {
Jobs.getJobManager().awaitDone(Jobs.newFutureFilterBuilder().andMatchFuture(future).toFilter(), 1, TimeUnit.MILLISECONDS);
fail("timeout expected");
} catch (TimedOutError e) {
// NOOP
}
// cleanup
setupLatch.unblock();
Jobs.getJobManager().awaitDone(Jobs.newFutureFilterBuilder().andMatchFuture(future).toFilter(), 10, TimeUnit.SECONDS);
}
use of org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch in project scout.rt by eclipse.
the class FutureAwaitTest method testAwaitDoneWithTimeout_Cancelled.
@Test(timeout = 5000)
public void testAwaitDoneWithTimeout_Cancelled() throws java.lang.InterruptedException {
final BlockingCountDownLatch setupLatch = new BlockingCountDownLatch(1);
// Init
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
setupLatch.countDownAndBlock();
return "result";
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()));
// Wait until ready
assertTrue(setupLatch.await());
// Run the test and verify
future.cancel(false);
assertTrue(future.isCancelled());
future.awaitDone(10, TimeUnit.SECONDS);
}
Aggregations