use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testReturnFirst.
@Test
public void testReturnFirst() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
chain.setReturnFirst(true);
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", true, new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", false, null), MockResolver.buildMockResolver(settings, "3", true, new GregorianCalendar(2005, 1, 25).getTime()), // younger -> should the one kept
MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, new GregorianCalendar(2005, 1, 22).getTime()), MockResolver.buildMockResolver(settings, "6", true, 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("1", rmr.getResolver().getName());
for (int i = 1; i < resolvers.length; i++) {
assertTrue(resolvers[i].askedDeps.isEmpty());
}
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testFixedWithDefaultAndRealResolver.
/**
* Test case for IVY-206.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-206">IVY-206</a>
*/
@Test
public void testFixedWithDefaultAndRealResolver() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
// no ivy pattern for first resolver: will only find a 'default' module
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("1");
resolver.setSettings(settings);
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
chain.add(resolver);
// second resolver has an ivy pattern and will thus find the real module, which should be
// kept
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);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("2", rmr.getResolver().getName());
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class ChainResolverTest method testFixedWithDefault.
@Test
public void testFixedWithDefault() 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), // default
MockResolver.buildMockResolver(settings, "3", false, null), MockResolver.buildMockResolver(settings, "4", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // not default -> should be the one kept
MockResolver.buildMockResolver(settings, "5", 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("4", rmr.getResolver().getName());
List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
for (int i = 0; i < 4; i++) {
assertEquals("invalid asked dependencies for " + resolvers[i], ddAsList, resolvers[i].askedDeps);
}
for (int i = 4; i < resolvers.length; i++) {
assertTrue("invalid asked dependencies for " + resolvers[i], resolvers[i].askedDeps.isEmpty());
}
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class DualResolverTest method testResolveFail.
@Test
public void testResolveFail() throws Exception {
DualResolver dual = new DualResolver();
MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false, new GregorianCalendar(2005, 1, 20).getTime());
MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", false, new GregorianCalendar(2005, 1, 20).getTime());
dual.setIvyResolver(ivyResolver);
dual.setArtifactResolver(artifactResolver);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
ResolvedModuleRevision rmr = dual.getDependency(dd, data);
assertNull(rmr);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), artifactResolver.askedDeps);
}
use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.
the class DualResolverTest method testResolveFromArtifact.
@Test
public void testResolveFromArtifact() throws Exception {
DualResolver dual = new DualResolver();
MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false, new GregorianCalendar(2005, 1, 20).getTime());
MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", true, new GregorianCalendar(2005, 1, 20).getTime());
dual.setIvyResolver(ivyResolver);
dual.setArtifactResolver(artifactResolver);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
ResolvedModuleRevision rmr = dual.getDependency(dd, data);
assertNotNull(rmr);
assertEquals(artifactResolver, rmr.getResolver());
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), artifactResolver.askedDeps);
}
Aggregations