use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testBranches6.
/**
* Test case for IVY-717.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-717">IVY-717</a>
*/
@Test
public void testBranches6() throws Exception {
// bar1;4 -> foo#foo1#${ivy.branch};5
// foo#foo1#branch1;5 -> foo#foo2#${ivy.branch};1
// foo#foo1#trunk;5 -> {}
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/branches/ivysettings.xml"));
ivy.setVariable("ivy.branch", "branch1");
ResolveReport report = ivy.resolve(new File("test/repositories/branches/bar/bar1/trunk/4/ivy.xml"), getResolveOptions(new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
assertTrue(getArchiveFileInCache(ivy, "foo#foo1#branch1;5", "foo1", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "foo#foo2#branch1;1", "foo2", "jar", "jar").exists());
ivy.setVariable("ivy.branch", "trunk");
report = ivy.resolve(new File("test/repositories/branches/bar/bar1/trunk/4/ivy.xml"), getResolveOptions(new String[] { "*" }).setValidate(false));
assertFalse(report.hasError());
assertEquals(1, report.getConfigurationReport("default").getNodesNumber());
assertTrue(getArchiveFileInCache(ivy, "foo#foo1#trunk;5", "foo1", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method ivyTestCache.
/**
* Configures an Ivy instance using a resolver locating modules on file system, in a
* build/testCache2 location which is created for the test and removed after, and can thus
* easily simulate a repository availability problem
*
* @return the configured ivy instance
*/
private Ivy ivyTestCache() {
Ivy ivy = Ivy.newInstance();
DualResolver resolver = new DualResolver();
resolver.setName("dual");
FileSystemResolver r = new FileSystemResolver();
r.setName("1");
r.addIvyPattern(ivy.getSettings().getBaseDir().getPath() + "/build/testCache2/ivy-[module]-[revision].xml");
resolver.add(r);
r = new FileSystemResolver();
r.setName("2");
r.addArtifactPattern(ivy.getSettings().getBaseDir().getPath() + "/build/testCache2/[artifact]-[revision].[ext]");
resolver.add(r);
ivy.getSettings().addResolver(resolver);
ivy.getSettings().setDefaultResolver("dual");
return ivy;
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveSeveralDefaultWithArtifactsAndConfs2.
/**
* Second test case for IVY-283.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-283">IVY-283</a>
*/
@Test
public void testResolveSeveralDefaultWithArtifactsAndConfs2() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-283/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-283/ivy-d.xml"), getResolveOptions(new String[] { "*" }));
assertFalse(report.hasError());
// dependencies
ConfigurationResolveReport crr = report.getConfigurationReport("build");
assertNotNull(crr);
assertEquals(9, crr.getDownloadReports(ModuleRevisionId.newInstance("medicel", "module_a", "local")).length);
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_a", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_b", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_c", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_d", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_e", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_f", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_g", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_h", "jar", "jar").exists());
assertTrue(getArchiveFileInCache(ivy, "medicel", "module_a", "local", "lib_a_i", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testIVY1236.
/**
* Test case for IVY-1236.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1236">IVY-1236</a>
*/
@Test
public void testIVY1236() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-1236/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-1236/ivy.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
assertNotNull(report.getUnresolvedDependencies());
assertEquals("Number of unresolved dependencies not correct", 0, report.getUnresolvedDependencies().length);
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("myorg", "modB", "1.0")).exists());
assertTrue(getArchiveFileInCache("myorg", "modB", "1.0", "modB", "jar", "jar").exists());
assertTrue(getArchiveFileInCache("myorg", "modB", "1.0", "modB-A", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testMultipleCache.
@Test
public void testMultipleCache() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/ivysettings-multicache.xml"));
// mod2.1 depends on mod1.1 which depends on mod1.2
ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.1/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
assertFalse(report.hasError());
// dependencies
DefaultArtifact depArtifact = TestHelper.newArtifact("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar");
ModuleRevisionId depMrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
DefaultRepositoryCacheManager cacheMgr1 = (DefaultRepositoryCacheManager) ivy.getSettings().getDefaultRepositoryCacheManager();
DefaultRepositoryCacheManager cacheMgr2 = (DefaultRepositoryCacheManager) ivy.getSettings().getRepositoryCacheManager("cache2");
// ivy file should be cached in default cache, and artifact in cache2
assertTrue(cacheMgr1.getIvyFileInCache(depMrid).exists());
assertFalse(cacheMgr1.getArchiveFileInCache(depArtifact).exists());
assertEquals(new File(cache, "repo1/mod1.1/ivy-1.0.xml").getCanonicalFile(), cacheMgr1.getIvyFileInCache(depMrid).getCanonicalFile());
assertFalse(cacheMgr2.getIvyFileInCache(depMrid).exists());
assertTrue(cacheMgr2.getArchiveFileInCache(depArtifact).exists());
assertEquals(new File(cache, "repo2/mod1.1-1.0/mod1.1.jar").getCanonicalFile(), cacheMgr2.getArchiveFileInCache(depArtifact).getCanonicalFile());
}
Aggregations