EventLoopCheckingFuture extends CompletableFuture<T> { public static <U> EventLoopCheckingFuture<U> exceptionallyCompletedFuture(Throwable cause) { requireNonNull(cause, "cause"); final EventLoopCheckingFuture<U> future = new EventLoopCheckingFuture<>(); future.completeExceptionally(cause); return future; }  static EventLoopCheckingFuture<U> completedFuture(@Nullable U value); static EventLoopCheckingFuture<U> exceptionallyCompletedFuture(Throwable cause); @Override T get(); @Override T get(long timeout, TimeUnit unit); @Override T join();  }
@Test void exceptionallyCompletedFuture() { final Throwable cause = new Throwable(); final EventLoopCheckingFuture<?> future = EventLoopCheckingFuture.exceptionallyCompletedFuture(cause); assertThat(future).isCompletedExceptionally(); assertThatThrownBy(future::join).isInstanceOf(CompletionException.class) .hasCauseReference(cause); }