use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class ChainResolverTest method testReturnFirstWithDefaultAndCacheAndRealResolver.
/**
* Test case for IVY-389.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-389">IVY-389</a>
*/
@Test
public void testReturnFirstWithDefaultAndCacheAndRealResolver() throws Exception {
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
// 1 ---- we first do a first resolve which puts a default file in cache
chainToPutDefaultModuleInCache().getDependency(dd, data);
// 2 ---- now we ask to resolve dependencies with a chain in return first mode with check
// modified = false, in which the first resolver is not able to find the module, but the
// second is
ChainResolver chain = returnFirstChain();
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
// the module returned should be the default one found in cache since check modified is
// false
assertTrue(rmr.getDescriptor().isDefault());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class ChainResolverTest method testLatestRevisionResolve.
@Test
public void testLatestRevisionResolve() 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", false, null), 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 testLatestTimeResolve.
@Test
public void testLatestTimeResolve() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
settings.setDefaultLatestStrategy(new LatestTimeStrategy());
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("3", 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 testResolveOrder.
@Test
public void testResolveOrder() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, null), MockResolver.buildMockResolver(settings, "3", true, null) };
for (MockResolver resolver : resolvers) {
chain.add(resolver);
}
assertResolversSizeAndNames(chain, resolvers.length);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("2", rmr.getResolver().getName());
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), resolvers[0].askedDeps);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), resolvers[1].askedDeps);
assertTrue(resolvers[2].askedDeps.isEmpty());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class ChainResolverTest method testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver.
/**
* Test case for IVY-207.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-207">IVY-207</a>
*/
@Test
public void testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver() throws Exception {
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
// 1 ---- we first do a first resolve which puts a default file in cache
chainToPutDefaultModuleInCache().getDependency(dd, data);
// 2 ---- now we ask to resolve dependencies with a chain in return first mode, in which the
// first resolver is not able to find the module, but the second is
ChainResolver chain = returnFirstChain();
chain.setCheckmodified(true);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertFalse(rmr.getDescriptor().isDefault());
assertEquals("2", rmr.getResolver().getName());
}
Aggregations