use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class GetTest method testDownloadCorrupted.
@Test
public void testDownloadCorrupted() throws Exception {
RecordingTransferListener transferListener = new RecordingTransferListener();
session().setTransferListener(transferListener);
addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact");
addDelivery("gid/aid/version/aid-version-classifier.extension.sha1", "foo");
addDelivery("gid/aid/version/aid-version-classifier.extension.md5", "bar");
File f = TestFileUtils.createTempFile("");
Artifact a = artifact("bla");
ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_WARN);
Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
connector().get(downs, null);
TransferEvent corruptedEvent = null;
for (TransferEvent e : transferListener.getEvents()) {
if (TransferEvent.EventType.CORRUPTED.equals(e.getType())) {
corruptedEvent = e;
break;
}
}
assertNotNull(corruptedEvent);
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class GetTest method testDownloadArtifactChecksumFailure.
@Test
public void testDownloadArtifactChecksumFailure() throws Exception {
addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact");
addDelivery("gid/aid/version/aid-version-classifier.extension.sha1", "foo");
addDelivery("gid/aid/version/aid-version-classifier.extension.md5", "bar");
File f = TestFileUtils.createTempFile("");
Artifact a = artifact("bla");
ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
connector().get(downs, null);
assertNotNull(down.getException());
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class GetTest method testDownloadArtifactNoChecksumAvailable.
@Test
public void testDownloadArtifactNoChecksumAvailable() throws Exception {
addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact");
File f = TestFileUtils.createTempFile("");
Artifact a = artifact("foo");
ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
connector().get(downs, null);
TestFileUtils.assertContent("", f);
assertNotNull(down.getException());
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class GetTest method testClosedGet.
@Test(expected = IllegalStateException.class)
public void testClosedGet() throws Exception {
connector().close();
File f = TestFileUtils.createTempFile("");
Artifact a = artifact("foo");
ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
connector().get(downs, null);
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class TransferEventTester method testFailedTransferEvents.
/**
* Test the order of events and their properties for the unsuccessful up- and download of artifact and metadata.
* Failure is triggered by setting the file to transfer to {@code null} for uploads, and asking for a non-existent
* item for downloads.
*/
public static void testFailedTransferEvents(RepositoryConnectorFactory factory, TestRepositorySystemSession session, RemoteRepository repository) throws NoRepositoryConnectorException, IOException {
RecordingTransferListener listener = new RecordingTransferListener(session.getTransferListener());
session.setTransferListener(listener);
RepositoryConnector connector = factory.newInstance(session, repository);
byte[] pattern = "tmpFile".getBytes("us-ascii");
File tmpFile = TestFileUtils.createTempFile(pattern, 10000);
Collection<ArtifactUpload> artUps = ConnectorTestUtils.createTransfers(ArtifactUpload.class, 1, null);
Collection<ArtifactDownload> artDowns = ConnectorTestUtils.createTransfers(ArtifactDownload.class, 1, tmpFile);
Collection<MetadataUpload> metaUps = ConnectorTestUtils.createTransfers(MetadataUpload.class, 1, null);
Collection<MetadataDownload> metaDowns = ConnectorTestUtils.createTransfers(MetadataDownload.class, 1, tmpFile);
connector.put(artUps, null);
LinkedList<TransferEvent> events = new LinkedList<TransferEvent>(listener.getEvents());
checkFailedEvents(events, null);
listener.clear();
connector.get(artDowns, null);
events = new LinkedList<TransferEvent>(listener.getEvents());
checkFailedEvents(events, null);
listener.clear();
connector.put(null, metaUps);
events = new LinkedList<TransferEvent>(listener.getEvents());
checkFailedEvents(events, null);
listener.clear();
connector.get(null, metaDowns);
events = new LinkedList<TransferEvent>(listener.getEvents());
checkFailedEvents(events, null);
connector.close();
session.setTransferListener(null);
}
Aggregations