@Test
public void testWaitForInterrupted() {

    CompletableFuture<Object> neverCompletingFuture = new CompletableFuture<>();
    final Thread currentThread = Thread.currentThread();
    //start a new thread to interrupt this thread, which is waiting for the future
    Runnable interrupter = currentThread::interrupt;
    new Thread(interrupter).start();
    try {
        HttpUtils.waitFor(neverCompletingFuture);
        fail("No exception was thrown!");
    } catch (IOException e) {
        assertThat(e.getCause()).isInstanceOf(InterruptedException.class);
        assertThat(Thread.currentThread().isInterrupted()).isTrue();
    }
}