use of org.sonatype.aether.transfer.ArtifactTransferException in project sonatype-aether by sonatype.
the class DefaultArtifactResolverTest method testResolveRemoteArtifactUnsuccessful.
@Test
public void testResolveRemoteArtifactUnsuccessful() throws IOException, ArtifactResolutionException {
RecordingRepositoryConnector connector = new RecordingRepositoryConnector() {
@Override
public void get(Collection<? extends ArtifactDownload> artifactDownloads, Collection<? extends MetadataDownload> metadataDownloads) {
super.get(artifactDownloads, metadataDownloads);
ArtifactDownload download = artifactDownloads.iterator().next();
ArtifactTransferException exception = new ArtifactNotFoundException(download.getArtifact(), null, "not found");
download.setException(exception);
}
};
connector.setExpectGet(artifact);
remoteRepositoryManager.setConnector(connector);
ArtifactRequest request = new ArtifactRequest(artifact, null, "");
request.addRepository(new RemoteRepository("id", "default", "file:///"));
try {
resolver.resolveArtifact(session, request);
fail("expected exception");
} catch (ArtifactResolutionException e) {
connector.assertSeenExpected();
assertNotNull(e.getResults());
assertEquals(1, e.getResults().size());
ArtifactResult result = e.getResults().get(0);
assertSame(request, result.getRequest());
assertFalse(result.getExceptions().isEmpty());
assertTrue(result.getExceptions().get(0) instanceof ArtifactNotFoundException);
Artifact resolved = result.getArtifact();
assertNull(resolved);
}
}
Aggregations