use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.
the class ChainResolverTest method testDownloadWithDual.
@Test
public void testDownloadWithDual() {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
chain.setDual(true);
// first resolver has only an artifact pattern which don't lead to anything: it won't find
// the module
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("1");
resolver.setSettings(settings);
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/nowhere/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
chain.add(resolver);
resolver = new FileSystemResolver();
resolver.setName("2");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
chain.add(resolver);
settings.addResolver(chain);
MockMessageLogger mockLogger = new MockMessageLogger();
IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockLogger);
DownloadReport report = chain.download(new Artifact[] { new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar") }, new DownloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
assertEquals(DownloadStatus.SUCCESSFUL, report.getArtifactsReports()[0].getDownloadStatus());
mockLogger.assertLogDoesntContain("[FAILED ] org1#mod1.1;1.0!mod1.1.jar");
}
use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.
the class URLResolverTest method testFile.
@Test
public void testFile() throws Exception {
URLResolver resolver = new URLResolver();
resolver.setSettings(settings);
String rootpath = new File("test/repositories/1").toURI().toURL().toExternalForm();
resolver.addIvyPattern(rootpath + "/[organisation]/[module]/ivys/ivy-[revision].xml");
resolver.addArtifactPattern(rootpath + "/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
resolver.setName("test");
assertEquals("test", resolver.getName());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
assertEquals(pubdate, rmr.getPublicationDate());
// test to ask to download
DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar");
DownloadReport report = resolver.download(new Artifact[] { artifact }, downloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { artifact }, downloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.
the class P2DescriptorTest method testResolveSource.
@Test
public void testResolveSource() throws Exception {
settings.setDefaultResolver("p2-sources");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy", "2.2.0.final_20100923230623");
ResolvedModuleRevision rmr = p2SourceResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);
DownloadReport report = p2SourceResolver.download(rmr.getDescriptor().getAllArtifacts(), new DownloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
for (int i = 0; i < 2; i++) {
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[i];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
DownloadReport report2 = p2SourceResolver.download(new Artifact[] { artifact }, new DownloadOptions());
assertNotNull(report2);
assertEquals(1, report2.getArtifactsReports().length);
ar = report2.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
}
use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.
the class P2DescriptorTest method testResolvePacked.
@Test
public void testResolvePacked() throws Exception {
settings.setDefaultResolver("p2-with-packed");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit", "4.10.0.v4_10_0_v20120426-0900");
ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2WithPackedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
assertNotNull(ar.getUnpackedLocalFile());
}
use of org.apache.ivy.core.report.DownloadReport in project ant-ivy by apache.
the class P2DescriptorTest method testResolveNotZipped.
@Test
public void testResolveNotZipped() throws Exception {
settings.setDefaultResolver("p2-zipped");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.eclipse.e4.core.services", "1.0.0.v20120521-2346");
ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
assertNull(ar.getUnpackedLocalFile());
}
Aggregations