use of org.apache.ivy.core.module.descriptor.Artifact 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.module.descriptor.Artifact in project ant-ivy by apache.
the class UpdateSiteAndIbiblioResolverTest method testArtifactRef.
@Test
public void testArtifactRef() throws ParseException {
// Simple Dependency for ibiblio
ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("log4j", "log4j", "1.2.16");
ResolvedModuleRevision rmr1 = chain.getDependency(new DefaultDependencyDescriptor(mrid1, false), data);
// Simple Dependency for updatesite
ModuleRevisionId mrid2 = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy", "2.0.0.final_20090108225011");
ResolvedModuleRevision rmr2 = chain.getDependency(new DefaultDependencyDescriptor(mrid2, false), data);
assertNotNull(rmr1);
assertNotNull(rmr2);
Artifact[] artifacts1 = rmr1.getDescriptor().getArtifacts("default");
Artifact[] artifacts2 = rmr2.getDescriptor().getArtifacts("default");
chain.exists(artifacts2[0]);
chain.exists(artifacts1[0]);
}
use of org.apache.ivy.core.module.descriptor.Artifact 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.module.descriptor.Artifact in project ant-ivy by apache.
the class PublishEngineTest method testAtomicity.
@Test
public void testAtomicity() throws Exception {
IvySettings settings = new IvySettings();
final PublishEngine engine = new PublishEngine(settings, new EventManager());
final int[] counter = new int[] { 0 };
final DefaultModuleDescriptor md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.parse("#A;1.0"));
final FileSystemResolver resolver = new FileSystemResolver() {
public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
super.publish(artifact, src, overwrite);
synchronized (PublishEngineTest.this) {
counter[0]++;
}
sleepSilently(50);
synchronized (PublishEngineTest.this) {
counter[0]++;
}
}
};
resolver.setName("test");
resolver.setSettings(settings);
String publishRepoDir = new File("build/test/publish/repo").getAbsolutePath();
resolver.addIvyPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
resolver.addArtifactPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), new File("build/test/publish/module/A.jar"), null);
XmlModuleDescriptorWriter.write(md, new File("build/test/publish/module/ivy.xml"));
resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "before publishing");
// run publish asynchronously
new Thread() {
public void run() {
try {
engine.publish(md, Collections.singletonList("build/test/publish/module/[artifact].[ext]"), resolver, new PublishOptions().setSrcIvyPattern("build/test/publish/module/[artifact].[ext]"));
synchronized (PublishEngineTest.this) {
counter[0]++;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}.start();
while (true) {
sleepSilently(5);
synchronized (this) {
if (counter[0] == 5) {
break;
} else if (counter[0] < 4) {
resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "after " + (counter[0] / 2) + " artifacts published");
}
}
}
resolveAndAssertFound(settings, resolver, "#A;1.0");
}
use of org.apache.ivy.core.module.descriptor.Artifact 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