use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method acceptEither_whenActionThrowsException.
@Test
public void acceptEither_whenActionThrowsException() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
CompletableFuture<Void> nextStage = future.acceptEither(new CompletableFuture<>(), (v) -> {
throw new ExpectedRuntimeException();
});
assertTrueEventually(() -> assertTrue(nextStage.isDone()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
nextStage.join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenAcceptBothAsync_onIncompleteFuture_whenExecutionRejected.
@Test
public void thenAcceptBothAsync_onIncompleteFuture_whenExecutionRejected() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
future.thenAcceptBothAsync(newCompletedFuture(null), (v, u) -> ignore(), REJECTING_EXECUTOR).join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenAccept_whenActionThrowsException.
private void thenAccept_whenActionThrowsException(long completionDelay) {
CompletableFuture<Object> future = newCompletableFuture(false, completionDelay);
CompletableFuture<Void> chained = future.thenAccept(value -> {
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.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenApply_whenActionThrowsException.
public void thenApply_whenActionThrowsException(long completionDelay) {
CompletableFuture<Object> future = newCompletableFuture(false, completionDelay);
CompletableFuture<Void> chained = future.thenApply(value -> {
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.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method handleAsync_withExecutor_withExceptionFromFirstStage_failsWithSecondException.
@Test
public void handleAsync_withExecutor_withExceptionFromFirstStage_failsWithSecondException() {
CompletableFuture<Object> future = newCompletableFuture(true, 0L);
CompletableFuture<Object> chained = future.handleAsync((v, t) -> {
throw new IllegalArgumentException();
}, countingExecutor);
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(IllegalArgumentException.class));
chained.join();
}
Aggregations