use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method whenCompleteAsync_withExecutor_withExceptionFromFirstStage_failsWithFirstException.
@Test
public void whenCompleteAsync_withExecutor_withExceptionFromFirstStage_failsWithFirstException() {
CompletableFuture<Object> future = newCompletableFuture(true, 0L);
CompletableFuture<Object> chained = future.whenCompleteAsync((v, t) -> {
throw new IllegalArgumentException();
}, countingExecutor);
assertTrueEventually(() -> 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 thenRun_exceptional.
@Test
public void thenRun_exceptional() {
CompletableFuture<Object> future = newCompletableFuture(true, 0L);
CompletableFuture<Void> chained = future.thenRun(CompletableFutureTestUtil::ignore);
assertTrueEventually(() -> assertTrue(chained.isDone()));
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_withExceptionFromBiFunction.
@Test
public void handleAsync_withExceptionFromBiFunction() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
CompletableFuture<Object> chained = future.handleAsync((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.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method applyToEitherAsync_whenExecutionRejected.
@Test
public void applyToEitherAsync_whenExecutionRejected() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
future.applyToEitherAsync(newCompletedFuture(null), v -> null, REJECTING_EXECUTOR).join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method testWhenComplete_whenCancelled.
@Test
public void testWhenComplete_whenCancelled() {
CompletableFuture<Object> future = newCompletableFuture(false, 10000L);
assertTrue(future.cancel(true));
CompletableFuture<Object> nextStage = future.whenComplete((v, t) -> {
assertInstanceOf(CancellationException.class, t);
});
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(CancellationException.class));
nextStage.join();
}
Aggregations