@Test
public void testWithBrokenURL() throws Exception {

    AttachmentContent attachmentContent = saveRemoteAttachment(TestUtils.BLACK_HOLE_ADDRESS);
    AttachmentContent attachmentGood = saveRemoteAttachment(url);
    assertThat(repository.getOnlyRemoteAttachments(), hasSize(2));
    assertThat(retrieveRemoteAttachments(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout), is(1));
    assertThat(repository.getOnlyRemoteAttachments(), hasSize(1));
    assertThat(attachmentConnector.getAttachmentStream(attachmentGood, dummyUser,
            new Project()
                    .setVisbility(Visibility.ME_AND_MODERATORS)
                    .setCreatedBy(dummyUser.getEmail())
                    .setAttachments(Collections.singleton(new Attachment().setAttachmentContentId(attachmentGood.getId())))),
            hasLength(greaterThan(0l)));
    assertThat(repository.getOnlyRemoteAttachments(), hasSize(1));
    assertThat(retrieveRemoteAttachments(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout), is(0));
    assertThat(repository.getOnlyRemoteAttachments(), hasSize(1));
    try {
        assertThat(attachmentConnector.getAttachmentStream(attachmentContent, dummyUser,
            new Project()
                    .setVisbility(Visibility.ME_AND_MODERATORS)
                    .setCreatedBy(dummyUser.getEmail())
                    .setAttachments(Collections.singleton(new Attachment().setAttachmentContentId(attachmentContent.getId())))),
            hasLength(greaterThan(0l)));
        fail("expected exception not thrown");
    } catch (SW360Exception e) {
        assertThat(e.getWhy(), containsString(attachmentContent.getId()));
    }
}