use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.
the class BintrayResolverTest method testBintrayArtifacts.
@Test
public void testBintrayArtifacts() throws Exception {
BintrayResolver resolver = new BintrayResolver();
resolver.setName("test");
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ant", "ant-antunit", "1.2");
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mrid, false);
dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "javadoc", "jar"), ExactPatternMatcher.INSTANCE, null));
dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "sources", "jar"), ExactPatternMatcher.INSTANCE, null));
ResolvedModuleRevision rmr = resolver.getDependency(dd, data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
DefaultArtifact profiler = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "javadoc", "jar");
DefaultArtifact trace = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "sources", "jar");
DownloadReport report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(profiler);
assertNotNull(ar);
assertEquals(profiler, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
ar = report.getArtifactReport(trace);
assertNotNull(ar);
assertEquals(trace, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
ar = report.getArtifactReport(profiler);
assertNotNull(ar);
assertEquals(profiler, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
ar = report.getArtifactReport(trace);
assertNotNull(ar);
assertEquals(trace, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.module.descriptor.DefaultArtifact 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.module.descriptor.DefaultArtifact in project ant-ivy by apache.
the class PackagerResolverTest method testZipResourceInclusion.
@Test
public void testZipResourceInclusion() throws Exception {
Locale oldLocale = Locale.getDefault();
try {
// set the locale to UK as workaround for SUN bug 6240963
Locale.setDefault(Locale.UK);
// Create and configure resolver
PackagerResolver resolver = new PackagerResolver();
resolver.setSettings(settings);
String repoRoot = new File("test/repositories/IVY-1179/repo").toURI().toURL().toExternalForm();
resolver.addIvyPattern(repoRoot + "[organisation]/[module]/[revision]/ivy.xml");
resolver.setPackagerPattern(repoRoot + "[organisation]/[module]/[revision]/packager.xml");
resolver.setBuildRoot(builddir);
resolver.setResourceCache(cachedir);
resolver.setPreserveBuildDirectories(true);
resolver.setVerbose(true);
resolver.setProperty("packager.website.url", new File("test/repositories/IVY-1179/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "A", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "A", "jar", "jar");
resolver.download(new Artifact[] { artifact }, downloadOptions());
// assert that the file A.jar is extracted from the archive
File jar = new File(builddir, "org/A/1.0/artifacts/jars/A.jar");
assertTrue(jar.exists());
// assert that the file README is not extracted from the archive
File readme = new File(builddir, "org/A/1.0/extract/A-1.0/README");
assertFalse(readme.exists());
} finally {
Locale.setDefault(oldLocale);
}
}
use of org.apache.ivy.core.module.descriptor.DefaultArtifact in project ant-ivy by apache.
the class PackagerResolverTest method testTarResourceInclusion.
@Test
public void testTarResourceInclusion() throws Exception {
Locale oldLocale = Locale.getDefault();
try {
// set the locale to UK as workaround for SUN bug 6240963
Locale.setDefault(Locale.UK);
// Create and configure resolver
PackagerResolver resolver = new PackagerResolver();
resolver.setSettings(settings);
String repoRoot = new File("test/repositories/IVY-1179/repo").toURI().toURL().toExternalForm();
resolver.addIvyPattern(repoRoot + "[organisation]/[module]/[revision]/ivy.xml");
resolver.setPackagerPattern(repoRoot + "[organisation]/[module]/[revision]/packager.xml");
resolver.setBuildRoot(builddir);
resolver.setResourceCache(cachedir);
resolver.setPreserveBuildDirectories(true);
resolver.setVerbose(true);
resolver.setProperty("packager.website.url", new File("test/repositories/IVY-1179/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "B", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "B", "jar", "jar");
resolver.download(new Artifact[] { artifact }, downloadOptions());
// assert that the file B.jar is extracted from the archive
File jar = new File(builddir, "org/B/1.0/artifacts/jars/B.jar");
assertTrue(jar.exists());
// assert that the file README is not extracted from the archive
File readme = new File(builddir, "org/B/1.0/extract/B-1.0/README");
assertFalse(readme.exists());
} finally {
Locale.setDefault(oldLocale);
}
}
use of org.apache.ivy.core.module.descriptor.DefaultArtifact 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());
}
Aggregations