@Test
public void should_return_async_sum() throws ExecutionException, InterruptedException {
final Integer numberOne = 5;
final Integer numberTwo = 10;
long start = System.currentTimeMillis();
final Future<Integer> resultFuture = bean.addNumbers(numberOne, numberTwo);
assertThat(resultFuture.isDone(), is(equalTo(false)));
assertThat(System.currentTimeMillis() - start, is(lessThan(MyAsyncBeanMethodLevel.AWAIT)));
await().until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return resultFuture.isDone();
}
});
assertThat(resultFuture.get(), is(equalTo(numberOne + numberTwo)));
}