null, true);
Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
modify.setLastModified(pubdate.getTime());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(pubdate, rmr.getPublicationDate());
Artifact[] artifacts = rmr.getDescriptor().getArtifacts("default");
resolver.download(artifacts, getDownloadOptions());
File archiveFileInCache = cacheManager.getArchiveFileInCache(artifacts[0]);
assertTrue(archiveFileInCache.exists());
BufferedReader r = new BufferedReader(new FileReader(archiveFileInCache));
assertEquals("before", r.readLine());
r.close();
// updates ivy file and artifact in repository
FileUtil.copy(new File("test/repositories/checkmodified/ivy-1.0-after.xml"), modify, null,
true);
FileUtil.copy(new File("test/repositories/checkmodified/mod1.1-1.0-after.jar"), artifact,
null, true);
pubdate = new GregorianCalendar(2005, 4, 1, 11, 0, 0).getTime();
modify.setLastModified(pubdate.getTime());
// no need to update new artifact timestamp cause it isn't used
// should not get the new version: checkmodified is false and dependency is not told to be a
// changing one
resolver.setCheckmodified(false);
rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(),
rmr.getPublicationDate());
assertTrue(archiveFileInCache.exists());
r = new BufferedReader(new FileReader(archiveFileInCache));
assertEquals("before", r.readLine());
r.close();
// should now get the new version cause we say it's a changing one
rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false, true), data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
assertEquals(pubdate, rmr.getPublicationDate());
assertFalse(archiveFileInCache.exists());
artifacts = rmr.getDescriptor().getArtifacts("default");
resolver.download(artifacts, getDownloadOptions());
assertTrue(archiveFileInCache.exists());
r = new BufferedReader(new FileReader(archiveFileInCache));
assertEquals("after", r.readLine());
r.close();