use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testIVY999.
/**
* Test case for IVY-999.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-999">IVY-999</a>
*/
@Test
public void testIVY999() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport rr = ivy.resolve(ResolveTest.class.getResource("ivy-999.xml"), getResolveOptions(new String[] { "*" }));
ConfigurationResolveReport crr = rr.getConfigurationReport("default");
Set<ModuleRevisionId> modRevIds = crr.getModuleRevisionIds();
assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "4.4")));
assertFalse(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "3.8")));
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveTransitivelyToPomRelocatedToNewVersion.
@Test
public void testResolveTransitivelyToPomRelocatedToNewVersion() throws Exception {
ivy = new Ivy();
ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
ivy.pushContext();
try {
ResolveReport report = ivy.resolve(new File("test/repositories/m2/org/relocated/testRelocationUser/1.1/" + "testRelocationUser-1.1.pom"), getResolveOptions(new String[] { "compile" }));
assertNotNull(report);
assertFalse(report.hasError());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test2", "1.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test2", "1.0", "test2", "jar", "jar").exists());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test", "1.0")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test", "1.0", "test", "jar", "jar").exists());
} finally {
ivy.popContext();
}
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testErrorResolveMaven2ParentPomWithCycle.
@Test
public void testErrorResolveMaven2ParentPomWithCycle() throws Exception {
// IVY-1545
// test6 has parent parent4, parent4 parent is parent5, parent5 parent is parent4, a cycle.
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/parentPom/ivysettings.xml"));
ivy.getSettings().setDefaultResolver("parentChain");
try {
ivy.resolve(new File("test/repositories/parentPom/org/apache/dm/test6/1.0/test6-1.0.pom"), getResolveOptions(new String[] { "*" }));
// don't expect to get here, should suffer StackOverflowError if cycle is not detected
fail("Expected CircularDependencyException from parent cycle detection");
} catch (CircularDependencyException e) {
// ok
assertEquals("org.apache.dm#parent4;1.0->org.apache.dm#parent5;1.0", e.getMessage());
}
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolverDirectlyUsingCache.
@Test
public void testResolverDirectlyUsingCache() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(ResolveTest.class.getResource("badcacheconf.xml"));
File depIvyFileInCache = getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"));
// creates a
FileUtil.copy(File.createTempFile("test", "xml"), depIvyFileInCache, null);
// fake
// dependency
// file in cache
ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.4/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.4", "0.3");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// dependencies
assertTrue(depIvyFileInCache.exists());
assertFalse(getArchiveFileInCache(ivy, "org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testIVY1333.
/**
* Test case for IVY-1333.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1333">IVY-1333</a>
*/
@Test
public void testIVY1333() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-1333/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1333/ivy.xml"), getResolveOptions(new String[] { "*" }));
ConfigurationResolveReport crr = rr.getConfigurationReport("default");
Set<ModuleRevisionId> modRevIds = crr.getModuleRevisionIds();
assertEquals(3, modRevIds.size());
assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep1", "1.0")));
assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep2", "1.0")));
Map<String, String> extra = new HashMap<>();
extra.put("o:a", "58701");
assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "badArtifact", "1.0.0.m4", extra)));
}
Aggregations