@Test
public void whenTaskThrowsThenThrowExecutionException() throws InterruptedException {

    CompletableFutureTask<Integer> task = CompletableFutureTask.runAsync(() -> {
        throw new MyException();
    }, executor);
    try {
        task.get();
        fail();
    } catch (ExecutionException exc) {
        assertTrue(exc.getCause() instanceof MyException);
    }
}