use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testResolveMaven2Snapshot2AsLatestIntegration.
/**
* Test case for IVY-1036.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1036">IVY-1036</a>
*/
@Test
public void testResolveMaven2Snapshot2AsLatestIntegration() throws Exception {
// here we test maven SNAPSHOT versions handling,
// with m2 snapshotRepository/uniqueVersion set to true
// but retrieving by latest.integration
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
ResolveReport report = ivy.resolve(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT2", "latest.integration"), getResolveOptions(new String[] { "*(public)" }), true);
assertNotNull(report);
assertFalse(report.hasError());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT2", "2.0.2-SNAPSHOT")).exists());
assertTrue(getArchiveFileInCache(ivy, "org.apache", "test-SNAPSHOT2", "2.0.2-SNAPSHOT", "test-SNAPSHOT2", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testFromCache2.
@Test
public void testFromCache2() throws Exception {
// mod1.1 depends on mod1.2
Ivy ivy = ivyTestCache();
// set up repository
FileUtil.forceDelete(new File("build/testCache2"));
File art = new File("build/testCache2/mod1.2-2.0.jar");
FileUtil.copy(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar"), art, null);
// we first do a simple resolve so that module is in cache
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
assertFalse(report.hasError());
// now we clean the repository to simulate repo not available (network pb for instance)
FileUtil.forceDelete(new File("build/testCache2"));
// now do a new resolve: it should use cached data
report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
assertFalse(report.hasError());
ModuleDescriptor md = report.getModuleDescriptor();
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(ivy, mrid).exists());
// dependencies
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testNamespaceExtraAttributes.
@Test
public void testNamespaceExtraAttributes() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/extra-attributes/ivysettings.xml"));
ivy.getSettings().setDefaultCache(cache);
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att-ns.xml"), getResolveOptions(ivy.getSettings(), new String[] { "*" }).setValidate(true));
assertFalse(report.hasError());
assertTrue(new File(cache, "apache/mymodule/task1/1855/ivy.xml").exists());
assertTrue(new File(cache, "apache/mymodule/task1/1855/mymodule-windows.jar").exists());
assertTrue(new File(cache, "apache/mymodule/task1/1855/mymodule-linux.jar").exists());
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testConfigurationMapping2.
/**
* Test case for IVY-84.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-84">IVY-84</a>
*/
@Test
public void testConfigurationMapping2() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-84/ivysettings.xml"));
ResolveReport report = ivy.resolve(new File("test/repositories/IVY-84/tests/2/ivy.xml"), getResolveOptions(new String[] { "*" }));
ConfigurationResolveReport conf = report.getConfigurationReport("default");
assertContainsArtifact("test", "a", "1.0.1", "a", "txt", "txt", conf);
assertDoesntContainArtifact("test", "a", "1.0.1", "a-bt", "txt", "txt", conf);
assertContainsArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf);
assertDoesntContainArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf);
assertContainsArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf);
assertDoesntContainArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf);
}
use of org.apache.ivy.Ivy in project ant-ivy by apache.
the class ResolveTest method testIVY1178.
/**
* Test case for IVY-1178.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1178">IVY-1178</a>
*/
@Test
public void testIVY1178() throws Exception {
Ivy ivy = new Ivy();
ivy.configure(new File("test/repositories/IVY-1178/ivysettings.xml"));
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-1178.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", "modD", "1.1")).exists());
assertTrue(getArchiveFileInCache("myorg", "modD", "1.1", "modD", "jar", "jar").exists());
// evicted dependencies
assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("myorg", "modD", "1.0")).exists());
assertFalse(getArchiveFileInCache("myorg", "modD", "1.0", "modD", "jar", "jar").exists());
// transitive dependencies of modD-1.1 (must not exist: transitive="false" !)
assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("myorg", "modE", "1.1")).exists());
assertFalse(getArchiveFileInCache("myorg", "modE", "1.1", "modE", "jar", "jar").exists());
}
Aggregations