executorService.shutdownNow();
}
}
public void testMultipleExecutions() throws Exception {
BlockingTaskAwareExecutorServiceImpl executorService = createExecutorService();
try {
List<DoSomething> tasks = new LinkedList<DoSomething>();
for (int i = 0; i < 30; ++i) {
tasks.add(new DoSomething());
}
for (DoSomething doSomething : tasks) {
executorService.execute(doSomething);
}
for (DoSomething doSomething : tasks) {
assert !doSomething.isReady();
assert !doSomething.isExecuted();
}
for (DoSomething doSomething : tasks) {
doSomething.markReady();
}
executorService.checkForReadyTasks();
for (final DoSomething doSomething : tasks) {
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return doSomething.isExecuted();
}
});
}
} finally {
executorService.shutdownNow();
}
}