use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class FileSystemResolverTest method testNoRevision.
@Test
public void testNoRevision() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
settings.addResolver(resolver);
assertEquals("test", resolver.getName());
resolver.addIvyPattern(settings.getBaseDir() + FS + "test" + FS + "repositories" + FS + "norevision" + FS + "ivy-[module].xml");
resolver.addArtifactPattern(settings.getBaseDir() + FS + "test" + FS + "repositories" + FS + "norevision" + FS + "[artifact].[ext]");
File modify = new File("test/repositories/norevision/ivy-mod1.1.xml");
File artifact = new File("test/repositories/norevision/mod1.1.jar");
// 'publish' 'before' version
FileUtil.copy(new File("test/repositories/norevision/ivy-mod1.1-before.xml"), modify, null, true);
FileUtil.copy(new File("test/repositories/norevision/mod1.1-before.jar"), artifact, null, true);
Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime();
modify.setLastModified(pubdate.getTime());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), rmr.getId());
assertEquals(pubdate, rmr.getPublicationDate());
Artifact[] artifacts = rmr.getDescriptor().getArtifacts("default");
File archiveFileInCache = cacheManager.getArchiveFileInCache(artifacts[0]);
resolver.download(artifacts, getDownloadOptions());
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/norevision/ivy-mod1.1-after.xml"), modify, null, true);
FileUtil.copy(new File("test/repositories/norevision/mod1.1-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 get the new version even if checkModified is false, because we ask a
// latest.integration
resolver.setCheckmodified(false);
rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
assertEquals(ModuleRevisionId.newInstance("org1", "mod1.1", "1.1"), rmr.getId());
assertEquals(pubdate, rmr.getPublicationDate());
artifacts = rmr.getDescriptor().getArtifacts("default");
archiveFileInCache = cacheManager.getArchiveFileInCache(artifacts[0]);
assertFalse(archiveFileInCache.exists());
// should download the new artifact
artifacts = rmr.getDescriptor().getArtifacts("default");
resolver.download(artifacts, getDownloadOptions());
assertTrue(archiveFileInCache.exists());
r = new BufferedReader(new FileReader(archiveFileInCache));
assertEquals("after", r.readLine());
r.close();
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class IBiblioResolverTest method testErrorReport.
@Test
public void testErrorReport() throws Exception {
IBiblioResolver resolver = new IBiblioResolver();
resolver.setRoot("http://unknown.host.comx/");
resolver.setName("test");
resolver.setM2compatible(true);
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
MockMessageLogger mockMessageImpl = new MockMessageLogger();
IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNull(rmr);
mockMessageImpl.assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.pom");
mockMessageImpl.assertLogContains("tried http://unknown.host.comx/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class JarResolverTest method testSubdirInFile.
@Test
public void testSubdirInFile() throws Exception {
JarResolver resolver = new JarResolver();
resolver.setName("jarresolver1_subdir");
resolver.setFile(new File("test/jar-repos/jarrepo1_subdir.jar").getAbsolutePath());
resolver.addIvyPattern("1/[organisation]/[module]/ivys/ivy-[revision].xml");
resolver.addArtifactPattern("1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
resolver.setSettings(settings);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull(rmr);
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class BintrayResolverTest method testBintrayArtifacts.
@Test
public void testBintrayArtifacts() throws Exception {
BintrayResolver resolver = new BintrayResolver();
resolver.setName("test");
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ant", "ant-antunit", "1.2");
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mrid, false);
dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "javadoc", "jar"), ExactPatternMatcher.INSTANCE, null));
dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "sources", "jar"), ExactPatternMatcher.INSTANCE, null));
ResolvedModuleRevision rmr = resolver.getDependency(dd, data);
assertNotNull(rmr);
assertEquals(mrid, rmr.getId());
DefaultArtifact profiler = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "javadoc", "jar");
DefaultArtifact trace = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "sources", "jar");
DownloadReport report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
ArtifactDownloadReport ar = report.getArtifactReport(profiler);
assertNotNull(ar);
assertEquals(profiler, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
ar = report.getArtifactReport(trace);
assertNotNull(ar);
assertEquals(trace, ar.getArtifact());
assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
// test to ask to download again, should use cache
report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
assertNotNull(report);
assertEquals(2, report.getArtifactsReports().length);
ar = report.getArtifactReport(profiler);
assertNotNull(ar);
assertEquals(profiler, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
ar = report.getArtifactReport(trace);
assertNotNull(ar);
assertEquals(trace, ar.getArtifact());
assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class BintrayResolverTest method testErrorReport.
@Test
public void testErrorReport() throws Exception {
BintrayResolver resolver = new BintrayResolver();
resolver.setSubject("unknown");
resolver.setRepo("unknown");
resolver.setName("test");
resolver.setM2compatible(true);
resolver.setSettings(settings);
assertEquals("test", resolver.getName());
MockMessageLogger mockMessageImpl = new MockMessageLogger();
IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload", "1.0");
ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNull(rmr);
mockMessageImpl.assertLogContains("trying https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
mockMessageImpl.assertLogContains("tried https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
Aggregations