use of org.apache.ivy.plugins.latest.LatestRevisionStrategy 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.plugins.latest.LatestRevisionStrategy in project ant-ivy by apache.
the class FileSystemResolverTest method testLatestRevision.
@Test
public void testLatestRevision() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
resolver.addIvyPattern(IVY_PATTERN);
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
resolver.setLatestStrategy(new LatestRevisionStrategy());
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());
}
use of org.apache.ivy.plugins.latest.LatestRevisionStrategy 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.plugins.latest.LatestRevisionStrategy in project ant-ivy by apache.
the class XmlSettingsParserTest method test.
@Test
public void test() throws Exception {
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-test.xml"));
File defaultCache = settings.getDefaultCache();
assertNotNull(defaultCache);
assertEquals("mycache", defaultCache.getName());
assertFalse(settings.isCheckUpToDate());
assertFalse(settings.doValidate());
assertEquals("[module]/ivys/ivy-[revision].xml", settings.getDefaultCacheIvyPattern());
assertEquals("[module]/[type]s/[artifact]-[revision].[ext]", settings.getDefaultCacheArtifactPattern());
LatestStrategy latest = settings.getLatestStrategy("mylatest-revision");
assertNotNull(latest);
assertTrue(latest instanceof LatestRevisionStrategy);
LatestRevisionStrategy l = (LatestRevisionStrategy) latest;
assertEquals(new Integer(-2), l.getSpecialMeanings().get("pre"));
assertEquals(new Integer(4), l.getSpecialMeanings().get("qa"));
DependencyResolver defaultResolver = settings.getDefaultResolver();
assertNotNull(defaultResolver);
assertEquals("libraries", defaultResolver.getName());
assertTrue(defaultResolver instanceof FileSystemResolver);
FileSystemResolver fsres = (FileSystemResolver) defaultResolver;
List<String> ivyPatterns = fsres.getIvyPatterns();
assertNotNull(ivyPatterns);
assertEquals(1, ivyPatterns.size());
assertLocationEquals("lib/[organisation]/[module]/ivys/ivy-[revision].xml", ivyPatterns.get(0));
LatestStrategy strategy = fsres.getLatestStrategy();
assertNotNull(strategy);
assertTrue(strategy instanceof LatestRevisionStrategy);
DependencyResolver internal = settings.getResolver("internal");
assertNotNull(internal);
assertTrue(internal instanceof ChainResolver);
ChainResolver chain = (ChainResolver) internal;
List<DependencyResolver> subresolvers = chain.getResolvers();
assertNotNull(subresolvers);
assertEquals(2, subresolvers.size());
FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers.get(0);
assertEquals("int1", fsInt1.getName());
assertEquals(1, fsInt1.getIvyPatterns().size());
assertLocationEquals("sharedrep/[organisation]/[module]/ivys/ivy-[revision].xml", fsInt1.getIvyPatterns().get(0));
assertEquals("int2", subresolvers.get(1).getName());
strategy = fsInt1.getLatestStrategy();
assertNotNull(strategy);
assertTrue(strategy instanceof LatestTimeStrategy);
assertEquals("libraries", settings.getResolver(ModuleRevisionId.newInstance("unknown", "lib", "1.0")).getName());
assertEquals("internal", settings.getResolver(ModuleRevisionId.newInstance("apache", "ant", "1.0")).getName());
assertEquals("int2", settings.getResolver(ModuleRevisionId.newInstance("apache", "ivy", "2.0")).getName());
assertEquals("int1", settings.getResolver(ModuleRevisionId.newInstance("apache", "ivy", "1.0")).getName());
assertEquals("int1", settings.getResolver(ModuleRevisionId.newInstance("apache", "ivyde", "1.0")).getName());
}
use of org.apache.ivy.plugins.latest.LatestRevisionStrategy in project ant-ivy by apache.
the class FileSystemResolverTest method testRelativePath.
@Test
public void testRelativePath() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
resolver.addIvyPattern(new File("src/java").getAbsolutePath() + "/../../" + REL_IVY_PATTERN);
resolver.addArtifactPattern(settings.getBaseDir() + "/src/../test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
resolver.setLatestStrategy(new LatestRevisionStrategy());
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