use of org.apache.ivy.plugins.latest.LatestTimeStrategy in project ant-ivy by apache.
the class FileSystemResolverTest method testFormattedLatestTime.
@Test
public void testFormattedLatestTime() 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 LatestTimeStrategy());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.1");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1+"), false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
Date pubdate = new GregorianCalendar(2005, 0, 2, 11, 0, 0).getTime();
assertEquals(pubdate, rmr.getPublicationDate());
}
use of org.apache.ivy.plugins.latest.LatestTimeStrategy 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.plugins.latest.LatestTimeStrategy 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.LatestTimeStrategy in project ant-ivy by apache.
the class FileSystemResolverTest method testLatestTime.
@Test
public void testLatestTime() 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 LatestTimeStrategy());
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