assertFalse(futureWithException.isDone());
// now we verify that shutdown is still not complete (until both tasks are complete)
try
{
shutdown.waitForShutdown(new Timespan(200));
fail("should timeout");
}
catch(TimeoutException e)
{
// expected
}
assertFalse(futureWithRes.isDone());
assertFalse(futureWithException.isDone());
// we finally unblock the tasks
o.wakeUp();
// we get both normal results
assertEquals(10, (int) futureWithRes.get());
try
{
futureWithException.get();
fail("MyException should be thrown");
}
catch(ExecutionException ex)
{
assertTrue(ex.getCause() instanceof MyException);
}
// now we should be able to shutdown
shutdown.waitForShutdown(new Timespan(200));
executorService.shutdown();
executorService.awaitTermination(200, TimeUnit.MILLISECONDS);
}