use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class AbstractInvocationFuture_JoinTest method whenRuntimeException.
@Test
public void whenRuntimeException() throws Exception {
ExpectedRuntimeException ex = new ExpectedRuntimeException();
future.completeExceptionally(ex);
Future joinFuture = spawn(new Callable<Object>() {
@Override
public Object call() throws Exception {
return future.join();
}
});
assertCompletesEventually(joinFuture);
try {
joinFuture.get();
fail();
} catch (ExecutionException e) {
CompletionException wrapper = assertInstanceOf(CompletionException.class, e.getCause());
assertSame(ex, wrapper.getCause());
}
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenRun_whenActionThrowsException.
private void thenRun_whenActionThrowsException(long completionDelay) {
CompletableFuture<Object> future = newCompletableFuture(false, completionDelay);
CompletableFuture<Void> chained = future.thenRun(() -> {
throw new ExpectedRuntimeException();
});
assertTrueEventually(() -> assertTrue(future.isDone()));
assertTrueEventually(() -> assertTrue(chained.isDone()));
assertFalse(future.isCompletedExceptionally());
assertTrue(chained.isCompletedExceptionally());
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
chained.join();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method handle_withExceptionFromBiFunction.
@Test
public void handle_withExceptionFromBiFunction() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
CompletableFuture<Object> chained = future.handle((v, t) -> {
throw new ExpectedRuntimeException();
});
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
chained.join();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method whenCompleteAsync_withExceptionFromBiConsumer.
@Test
public void whenCompleteAsync_withExceptionFromBiConsumer() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
CompletableFuture<Object> chained = future.whenComplete((v, t) -> {
throw new ExpectedRuntimeException();
});
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
chained.join();
}
use of com.hazelcast.test.ExpectedRuntimeException in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method whenCompleteAsync_withExecutor_withExceptionFromBiConsumer.
@Test
public void whenCompleteAsync_withExecutor_withExceptionFromBiConsumer() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
CompletableFuture<Object> chained = future.whenCompleteAsync((v, t) -> {
throw new ExpectedRuntimeException();
}, countingExecutor);
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
chained.join();
}
Aggregations