use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class ResumeGetTest method testResumeInterruptedDownloadUsingRangeRequests.
@Test
public void testResumeInterruptedDownloadUsingRangeRequests() throws Exception {
FlakyHandler flakyHandler = new FlakyHandler(4);
server.setHandler(flakyHandler);
server.start();
File file = TestFileUtils.createTempFile("");
file.delete();
ArtifactDownload download = new ArtifactDownload(artifact, "", file, RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
RemoteRepository repo = new RemoteRepository("test", "default", url());
RepositoryConnector connector = factory.newInstance(session, repo);
try {
connector.get(Arrays.asList(download), null);
} finally {
connector.close();
}
assertNull(String.valueOf(download.getException()), download.getException());
assertTrue("Missing " + file.getAbsolutePath(), file.isFile());
assertEquals("Bad size of " + file.getAbsolutePath(), flakyHandler.totalSize, file.length());
assertContentPattern(file);
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class FileRepositoryConnector method get.
public void get(Collection<? extends ArtifactDownload> artifactDownloads, Collection<? extends MetadataDownload> metadataDownloads) {
checkClosed();
artifactDownloads = notNull(artifactDownloads);
metadataDownloads = notNull(metadataDownloads);
RunnableErrorForwarder errorForwarder = new RunnableErrorForwarder();
for (ArtifactDownload artifactDownload : artifactDownloads) {
FileRepositoryWorker worker = new FileRepositoryWorker(artifactDownload, repository, session);
worker.setLogger(logger);
worker.setFileProcessor(fileProcessor);
executor.execute(errorForwarder.wrap(worker));
}
for (MetadataDownload metadataDownload : metadataDownloads) {
FileRepositoryWorker worker = new FileRepositoryWorker(metadataDownload, repository, session);
worker.setLogger(logger);
worker.setFileProcessor(fileProcessor);
executor.execute(errorForwarder.wrap(worker));
}
errorForwarder.await();
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class ArtifactWorkerTest method downloadArtifact.
private File downloadArtifact(DefaultArtifact artifact) throws IOException, ArtifactTransferException {
File file = TestFileUtils.createTempFile("");
ArtifactDownload down = new ArtifactDownload(artifact, "", file, "");
down.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_FAIL);
FileRepositoryWorker worker = new FileRepositoryWorker(down, repository, session);
worker.setFileProcessor(TestFileProcessor.INSTANCE);
worker.run();
if (down.getException() != null) {
throw down.getException();
}
return file;
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class WagonRepositoryConnector method get.
public void get(Collection<? extends ArtifactDownload> artifactDownloads, Collection<? extends MetadataDownload> metadataDownloads) {
if (closed) {
throw new IllegalStateException("connector closed");
}
artifactDownloads = safe(artifactDownloads);
metadataDownloads = safe(metadataDownloads);
Collection<GetTask<?>> tasks = new ArrayList<GetTask<?>>();
RunnableErrorForwarder errorForwarder = new RunnableErrorForwarder();
for (MetadataDownload download : metadataDownloads) {
String resource = layout.getPath(download.getMetadata()).getPath();
GetTask<?> task = new GetTask<MetadataTransfer>(resource, download.getFile(), download.getChecksumPolicy(), download, METADATA);
tasks.add(task);
executor.execute(errorForwarder.wrap(task));
}
for (ArtifactDownload download : artifactDownloads) {
String resource = layout.getPath(download.getArtifact()).getPath();
GetTask<?> task = new GetTask<ArtifactTransfer>(resource, download.isExistenceCheck() ? null : download.getFile(), download.getChecksumPolicy(), download, ARTIFACT);
tasks.add(task);
executor.execute(errorForwarder.wrap(task));
}
errorForwarder.await();
}
use of org.sonatype.aether.spi.connector.ArtifactDownload in project sonatype-aether by sonatype.
the class TimeoutTest method testRequestTimeout.
@Test(timeout = 3000)
public void testRequestTimeout() throws Exception {
Map<String, Object> configProps = new HashMap<String, Object>();
configProps.put(ConfigurationProperties.CONNECT_TIMEOUT, "60000");
configProps.put(ConfigurationProperties.REQUEST_TIMEOUT, "1000");
session().setConfigProperties(configProps);
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);
assertNotNull(down.getException());
}
Aggregations