use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenApplyAsync_exceptional.
@Test
public void thenApplyAsync_exceptional() {
CompletableFuture<Object> future = newCompletableFuture(true, 1000L);
CompletableFuture<Object> chained = future.thenApplyAsync(Function.identity());
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 thenRunAsync_onIncompleteFuture_whenExecutionRejected.
@Test
public void thenRunAsync_onIncompleteFuture_whenExecutionRejected() {
CompletableFuture<Object> future = newCompletableFuture(false, 1000L);
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
future.thenRunAsync(() -> ignore(), REJECTING_EXECUTOR).join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenRun_whenActionThrowsException.
@Test
public void thenRun_whenActionThrowsException() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
CompletableFuture<Void> chained = future.thenRun(() -> {
throw new IllegalStateException();
});
assertTrueEventually(() -> assertTrue(chained.isDone()));
assertTrue(chained.isCompletedExceptionally());
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(IllegalStateException.class));
chained.join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method handle_withExceptionFromFirstStage_failsWithSecondException.
// since handle* methods process and substitute processing outcome of first stage,
// if the the handler BiFunction fails with an exception, the chained CompletionStage
// will fail with the exception thrown from the handler's body (not the one thrown from
// the original CompletionStage).
@Test
public void handle_withExceptionFromFirstStage_failsWithSecondException() {
CompletableFuture<Object> future = newCompletableFuture(true, 0L);
CompletableFuture<Object> chained = future.handle((v, t) -> {
throw new IllegalArgumentException();
});
assertTrueEventually(() -> assertTrue(chained.isCompletedExceptionally()));
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(IllegalArgumentException.class));
chained.join();
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class CompletableFutureAbstractTest method thenRunAsync_whenExecutionRejected.
// Tests for exceptional completion of dependent stage due to executor rejecting execution
@Test
public void thenRunAsync_whenExecutionRejected() {
CompletableFuture<Object> future = newCompletableFuture(false, 0L);
expectedException.expect(CompletionException.class);
expectedException.expectCause(new RootCauseMatcher(RejectedExecutionException.class));
future.thenRunAsync(() -> ignore(), REJECTING_EXECUTOR).join();
}
Aggregations