use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class MirroredURLResolverTest method testSolo.
@Test
public void testSolo() throws Exception {
DependencyResolver resolver = settings.getResolver("solo");
assertNotNull(resolver);
assertTrue(resolver instanceof MirroredURLResolver);
MirroredURLResolver mirrored = (MirroredURLResolver) resolver;
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
assertNotNull(rmr);
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class MockResolver method buildMockResolver.
static MockResolver buildMockResolver(ResolverSettings settings, String name, boolean findRevision, final ModuleRevisionId mrid, final Date publicationDate, final boolean isdefault) {
final MockResolver r = new MockResolver();
r.setName(name);
r.setSettings(settings);
if (findRevision) {
DefaultModuleDescriptor md = new DefaultModuleDescriptor(mrid, "integration", publicationDate, isdefault);
r.rmr = new ResolvedModuleRevision(r, r, md, new MetadataArtifactDownloadReport(md.getMetadataArtifact()));
}
return r;
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class PackagerResolverTest method testFile.
@Test
public void testFile() 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/packager/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/packager/website").toURI().toURL().toExternalForm());
resolver.setName("packager");
assertEquals("packager", resolver.getName());
// Get module descriptor
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", "mod", "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());
// Download artifact
Artifact artifact = new DefaultArtifact(mrid, pubdate, "mod", "jar", "jar");
DownloadReport report = resolver.download(new Artifact[] { artifact }, downloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
System.out.println("download details: " + ar.getDownloadDetails());
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// Verify resource cache now contains the distribution archive
assertTrue(new File(cachedir, "mod-1.0.tar.gz").exists());
// Download again, should use Ivy cache this time
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());
// Now download the maven2 artifact
artifact = DefaultArtifact.cloneWithAnotherName(artifact, "foobar-janfu");
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.SUCCESSFUL, ar.getDownloadStatus());
} finally {
Locale.setDefault(oldLocale);
}
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class URLResolverTest method testDownloadWithUseOriginIsTrue.
@Test
public void testDownloadWithUseOriginIsTrue() 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");
((DefaultRepositoryCacheManager) resolver.getRepositoryCacheManager()).setUseOrigin(true);
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 }, new DownloadOptions());
assertNotNull(report);
assertEquals(1, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(artifact);
assertNotNull(ar);
assertEquals(artifact, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class URLResolverTest method testLatestFileWithOpaqueURL.
@Test
public void testLatestFileWithOpaqueURL() throws Exception {
URLResolver resolver = new URLResolver();
resolver.setSettings(settings);
String rootpath = new File("test/repositories/1").getAbsoluteFile().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", "2.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
assertEquals(pubdate, rmr.getPublicationDate());
}
Aggregations