use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class Maven2LocalTest method testNotUseMetadataForListing.
@Test
public void testNotUseMetadataForListing() throws Exception {
IBiblioResolver resolver = maven2Resolver();
resolver.setUseMavenMetadata(false);
ResolvedModuleRevision m = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org.apache", "test-metadata", "latest.integration"), false), data);
assertNotNull(m);
// should trust listing revisions (latest=1.2) instead of the metadata (latest=1.1)
assertEquals(ModuleRevisionId.newInstance("org.apache", "test-metadata", "1.2"), m.getId());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class BintrayResolverTest method testBintray.
@Test
public void testBintray() throws Exception {
BintrayResolver resolver = new BintrayResolver();
resolver.setSettings(settings);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ant", "ant-antunit", "1.2");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "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.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class ChainResolverTest method testLatestWithDefault.
@Test
public void testLatestWithDefault() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
chain.setLatestStrategy(new LatestRevisionStrategy());
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", true, ModuleRevisionId.newInstance("org", "mod", "1"), new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest -> but default
MockResolver.buildMockResolver(settings, "3", true, ModuleRevisionId.newInstance("org", "mod", "2"), new GregorianCalendar(2005, 1, 25).getTime()), MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> should the one kept
MockResolver.buildMockResolver(settings, "6", true, ModuleRevisionId.newInstance("org", "mod", "3"), new GregorianCalendar(2005, 1, 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null) };
for (MockResolver resolver : resolvers) {
chain.add(resolver);
}
assertResolversSizeAndNames(chain, resolvers.length);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "latest.integration"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("5", rmr.getResolver().getName());
List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
for (MockResolver resolver : resolvers) {
assertEquals(ddAsList, resolver.askedDeps);
}
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class ChainResolverTest method testWithDefault.
@Test
public void testWithDefault() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
chain.setLatestStrategy(new LatestRevisionStrategy());
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest -> but default
MockResolver.buildMockResolver(settings, "3", false, null), MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> should be the one kept
MockResolver.buildMockResolver(settings, "6", false, null), MockResolver.buildMockResolver(settings, "7", false, null) };
for (MockResolver resolver : resolvers) {
chain.add(resolver);
}
assertResolversSizeAndNames(chain, resolvers.length);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "4"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("5", rmr.getResolver().getName());
List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
for (int i = 0; i < 5; i++) {
assertEquals(ddAsList, resolvers[i].askedDeps);
}
for (int i = 5; i < resolvers.length; i++) {
assertTrue(resolvers[i].askedDeps.isEmpty());
}
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class MirroredURLResolverTest method testFailover.
@Test
public void testFailover() throws Exception {
DependencyResolver resolver = settings.getResolver("failover");
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);
}
Aggregations