use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class ChainResolverTest method testFixedWithDefaultAndRealResolver.
/**
* Test case for IVY-206.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-206">IVY-206</a>
*/
@Test
public void testFixedWithDefaultAndRealResolver() throws Exception {
ChainResolver chain = new ChainResolver();
chain.setName("chain");
chain.setSettings(settings);
// no ivy pattern for first resolver: will only find a 'default' module
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("1");
resolver.setSettings(settings);
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
chain.add(resolver);
// second resolver has an ivy pattern and will thus find the real module, which should be
// kept
resolver = new FileSystemResolver();
resolver.setName("2");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
chain.add(resolver);
settings.addResolver(chain);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
ResolvedModuleRevision rmr = chain.getDependency(dd, data);
assertNotNull(rmr);
assertEquals("2", rmr.getResolver().getName());
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision 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.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class DualResolverTest method testResolveFail.
@Test
public void testResolveFail() throws Exception {
DualResolver dual = new DualResolver();
MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false, new GregorianCalendar(2005, 1, 20).getTime());
MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", false, new GregorianCalendar(2005, 1, 20).getTime());
dual.setIvyResolver(ivyResolver);
dual.setArtifactResolver(artifactResolver);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
ResolvedModuleRevision rmr = dual.getDependency(dd, data);
assertNull(rmr);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), artifactResolver.askedDeps);
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class DualResolverTest method testResolveFromArtifact.
@Test
public void testResolveFromArtifact() throws Exception {
DualResolver dual = new DualResolver();
MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false, new GregorianCalendar(2005, 1, 20).getTime());
MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", true, new GregorianCalendar(2005, 1, 20).getTime());
dual.setIvyResolver(ivyResolver);
dual.setArtifactResolver(artifactResolver);
DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
ResolvedModuleRevision rmr = dual.getDependency(dd, data);
assertNotNull(rmr);
assertEquals(artifactResolver, rmr.getResolver());
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
assertEquals(Collections.<DependencyDescriptor>singletonList(dd), artifactResolver.askedDeps);
}
use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.
the class FileSystemResolverTest method testSHA256Checksum.
/**
* Tests that <code>SHA-256</code> algorithm can be used for checksums on resolvers
*
* @throws Exception if something goes wrong
*/
@Test
public void testSHA256Checksum() throws Exception {
final FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("sha256-checksum-resolver");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
resolver.setChecksums("SHA-256");
final ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "2.0");
final ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
assertNotNull("Resolved module revision was null for " + mrid, rmr);
final DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions());
final ArtifactDownloadReport[] successfulDownloadReports = dr.getArtifactsReports(DownloadStatus.SUCCESSFUL);
assertNotNull("No artifacts were downloaded successfully", successfulDownloadReports);
assertEquals("Unexpected number of successfully downloaded artifacts", 1, successfulDownloadReports.length);
final ArtifactDownloadReport successfulDownloadReport = successfulDownloadReports[0];
final Artifact downloadedArtifact = successfulDownloadReport.getArtifact();
assertEquals("Unexpected organization of downloaded artifact", "test", downloadedArtifact.getModuleRevisionId().getOrganisation());
assertEquals("Unexpected module of downloaded artifact", "allright", downloadedArtifact.getModuleRevisionId().getModuleId().getName());
assertEquals("Unexpected revision of downloaded artifact", "2.0", downloadedArtifact.getModuleRevisionId().getRevision());
}
Aggregations