@Test
public void testABlackHoleUrl() throws Exception {

    assumeThat(getAvailableNetworkInterface(), isAvailable());
    Callable<String> downloadAttempt = () -> {
        AttachmentContent attachmentContent = mock(AttachmentContent.class);
        when(attachmentContent.getRemoteUrl()).thenReturn("http://" + BLACK_HOLE_ADDRESS + "/filename");
        try (InputStream download = attachmentContentDownloader
                .download(attachmentContent, downloadTimeout)) {
            return CharStreams.toString(new InputStreamReader(download));
        }
    };
    ExecutorService executor = newSingleThreadExecutor();
    try {
        Future<String> future = executor.submit(downloadAttempt);
        try {
            try {
                String read = future.get(1, TimeUnit.MINUTES);
                fail("downloader managed to escape with '" + read + "' from the black hole! " +
                        "Try this test again with a more massive black hole");
            } catch (ExecutionException e) {
                Throwable futureException = e.getCause();
                assertThat(futureException, is(notNullValue()));
                assertTrue(futureException instanceof SocketException || futureException instanceof SocketTimeoutException);
            }
        } catch (TimeoutException e) {
            fail("downloader got stuck on a black hole");
            throw e; // unreachable
        }
    } finally {
        executor.shutdown();
        executor.awaitTermination(1, TimeUnit.MINUTES);
    }
}