use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class RetrieveTest method testRetrieveReport.
@Test
public void testRetrieveReport() throws Exception {
// mod1.1 depends on mod1.2
ResolveReport report = ivy.resolve(new File("test/repositories/1/org20/mod20.1/ivys/ivy-1.2.xml").toURI().toURL(), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = md.getModuleRevisionId();
RetrieveOptions options = getRetrieveOptions();
options.setConfs(new String[] { "A" });
Map<ArtifactDownloadReport, Set<String>> artifactsToCopy = ivy.getRetrieveEngine().determineArtifactsToCopy(mrid, "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]", options);
assertEquals(2, artifactsToCopy.size());
options.setConfs(new String[] { "B" });
artifactsToCopy = ivy.getRetrieveEngine().determineArtifactsToCopy(mrid, "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]", options);
assertEquals(2, artifactsToCopy.size());
options.setConfs(new String[] { "A", "B" });
artifactsToCopy = ivy.getRetrieveEngine().determineArtifactsToCopy(mrid, "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]", options);
assertEquals(3, artifactsToCopy.size());
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class OBRResolverTest method genericTestResolveDownload.
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException {
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
DownloadReport report = resolver.download(new Artifact[] { artifact }, new 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 }, new 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.ArtifactDownloadReport in project ant-ivy by apache.
the class P2DescriptorTest method testResolveZipped.
@Test
public void testResolveZipped() throws Exception {
settings.setDefaultResolver("p2-zipped");
ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ant", "1.8.3.v20120321-1730");
ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);
DownloadOptions options = new DownloadOptions();
DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(), options);
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());
// only the binary get unpacked
if (ar.getArtifact().getType().equals("source")) {
assertNull(ar.getUnpackedLocalFile());
} else {
assertNotNull(ar.getUnpackedLocalFile());
}
}
}
use of org.apache.ivy.core.report.ArtifactDownloadReport in project ant-ivy by apache.
the class UpdateSiteResolverTest method genericTestResolveDownload.
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException {
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
DownloadReport report = resolver.download(new Artifact[] { artifact }, new 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 }, new 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.ArtifactDownloadReport in project ant-ivy by apache.
the class ResolveTest method testMultiClassifierMavenDepResolution.
/**
* Tests that if a pom.xml has multiple dependencies for the same module, but for different Maven classifiers,
* then the resolution of such dependencies, preserves those multiple (Ivy) artifacts against the dependency
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1576">IVY-1576</a> for more details
*/
@Test
public void testMultiClassifierMavenDepResolution() throws Exception {
final File pomFile = new File("test/repositories/m2/org/apache/test-classifier/1.0/test-classifier-1.0.pom");
final ResolveReport resolveReport = ivy.resolve(pomFile.toURI().toURL(), new ResolveOptions().setConfs(new String[] { "*" }));
assertFalse(resolveReport.hasError());
final ModuleRevisionId dependencyId = ModuleRevisionId.newInstance("org.apache", "test-classified", "1.0");
final ArtifactDownloadReport[] adrs = resolveReport.getArtifactsReports(dependencyId);
assertNotNull("Artifact download reports is null for dependency " + dependencyId, adrs);
assertEquals("Unexpected number of artifact download reports for dependency " + dependencyId, 3, adrs.length);
final Set<String> classifiers = new HashSet<>();
Collections.addAll(classifiers, "other", "asl", "unix");
for (final ArtifactDownloadReport adr : adrs) {
final Artifact artifact = adr.getArtifact();
assertNotNull("Artifact is null for dependency " + dependencyId, artifact);
final ArtifactRevisionId artifactId = artifact.getId();
assertEquals("Unexpected artifact " + artifactId.getName(), "test-classified", artifactId.getName());
final String classifier = artifact.getExtraAttribute("m:classifier");
assertNotNull("No classifier extra attribute on artifact for dependency " + dependencyId, classifier);
assertTrue("Unexpected classifier " + classifier + " on artifact " + artifact, classifiers.remove(classifier));
// just make sure it's the correct jar file
assertJarContains(adr.getLocalFile(), classifier + ".txt");
}
assertTrue("Missing artifact(s) with classifiers " + classifiers, classifiers.isEmpty());
}
Aggregations