Search in sources :

Example 31 with ConfigurationResolveReport

use of org.apache.ivy.core.report.ConfigurationResolveReport in project ant-ivy by apache.

the class ResolveTest method testConfigurationMapping3.

/**
 * 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 testConfigurationMapping3() 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/3/ivy.xml"), getResolveOptions(new String[] { "buildtime" }));
    ConfigurationResolveReport conf = report.getConfigurationReport("buildtime");
    assertContainsArtifact("test", "a", "1.0.2", "a-bt", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf);
    assertContainsArtifact("test", "b", "1.0.1", "b-bt", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "b", "1.0.1", "b", "txt", "txt", conf);
    assertContainsArtifact("test", "c", "1.0.1", "c-bt", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "c", "1.0.1", "c", "txt", "txt", conf);
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 32 with ConfigurationResolveReport

use of org.apache.ivy.core.report.ConfigurationResolveReport in project ant-ivy by apache.

the class ResolveTest method testIVY1233.

/**
 * Test case for IVY-1233.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1233">IVY-1233</a>
 */
@Test
public void testIVY1233() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-1233/ivysettings.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1233/ivy.xml"), getResolveOptions(new String[] { "*" }));
    ConfigurationResolveReport crr = rr.getConfigurationReport("default");
    Set<ModuleRevisionId> modRevIds = crr.getModuleRevisionIds();
    assertEquals(3, modRevIds.size());
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", "a", "1.0")));
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", "b", "2.0")));
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", "c", "3.0")));
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 33 with ConfigurationResolveReport

use of org.apache.ivy.core.report.ConfigurationResolveReport in project ant-ivy by apache.

the class ResolveTest method testResolveConflict3.

/**
 * Test case for IVY-264.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-264">IVY-264</a>
 */
@Test
public void testResolveConflict3() throws Exception {
    // a depends on x latest, y latest, z latest
    // x and z depends on commons-lang 1.0.1
    // y depends on commons-lang 2.0
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-264/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/repositories/IVY-264/ivy.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    // dependencies
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("myorg", "commons-lang", "1.0.1")).length);
    assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("myorg", "commons-lang", "2.0")).length);
    assertFalse(getArchiveFileInCache(ivy, "myorg", "commons-lang", "1.0.1", "commons-lang", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache(ivy, "myorg", "commons-lang", "2.0", "commons-lang", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 34 with ConfigurationResolveReport

use of org.apache.ivy.core.report.ConfigurationResolveReport in project ant-ivy by apache.

the class ResolveTest method testResolveMergeTransitiveAfterConflict.

@Test
public void testResolveMergeTransitiveAfterConflict() throws Exception {
    // mod20.4 -> mod20.3;1.0 mod20.2;1.0
    // mod20.3;1.0 -> mod20.1;1.0
    // mod20.2;1.0 -> mod20.1;1.1 (transitive false)
    // mod20.1;1.0 -> mod1.2;1.0
    // mod20.1;1.1 -> mod1.2;1.0
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org20/mod20.4/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
    // dependencies
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "1.0")).length);
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "1.0", "mod1.2", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 35 with ConfigurationResolveReport

use of org.apache.ivy.core.report.ConfigurationResolveReport in project ant-ivy by apache.

the class ResolveTest method testResolveMultipleExtendsAndConfs.

/**
 * Test case for IVY-240.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-240">IVY-240</a>
 */
@Test
public void testResolveMultipleExtendsAndConfs() throws Exception {
    // mod6.3 1.1 has four confs libraries, run (extends libraries), compile (extends run) and
    // test (extends libraries)
    // mod6.3 depends on mod6.2 2.0 in conf (run->default)
    // mod6.3 depends on mod6.1 2.+ in conf (test->default)
    // mod6.2 2.0 depends on mod6.1 2.0 in conf (default->standalone)
    // mod6.1 2.0 has two confs default and standalone
    // mod6.1 2.0 depends on mod1.2 2.2 in conf (default->default)
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod6.3/ivy-1.1.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ConfigurationResolveReport crr = report.getConfigurationReport("libraries");
    assertEquals(0, crr.getArtifactsNumber());
    crr = report.getConfigurationReport("run");
    assertEquals(2, crr.getArtifactsNumber());
    assertContainsArtifact("org6", "mod6.2", "2.0", "mod6.2", "jar", "jar", crr);
    assertContainsArtifact("org6", "mod6.1", "2.0", "mod6.1", "jar", "jar", crr);
    crr = report.getConfigurationReport("compile");
    assertEquals(2, crr.getArtifactsNumber());
    assertContainsArtifact("org6", "mod6.2", "2.0", "mod6.2", "jar", "jar", crr);
    assertContainsArtifact("org6", "mod6.1", "2.0", "mod6.1", "jar", "jar", crr);
    crr = report.getConfigurationReport("test");
    assertEquals(2, crr.getArtifactsNumber());
    assertContainsArtifact("org6", "mod6.1", "2.0", "mod6.1", "jar", "jar", crr);
    assertContainsArtifact("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar", crr);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)45 ResolveReport (org.apache.ivy.core.report.ResolveReport)43 File (java.io.File)40 Test (org.junit.Test)40 JarFile (java.util.jar.JarFile)34 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)27 Ivy (org.apache.ivy.Ivy)16 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)12 SAXParser (javax.xml.parsers.SAXParser)4 Attributes (org.xml.sax.Attributes)4 DefaultHandler (org.xml.sax.helpers.DefaultHandler)4 HashMap (java.util.HashMap)3 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)3 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 IvyContext (org.apache.ivy.core.IvyContext)1 ResolutionCacheManager (org.apache.ivy.core.cache.ResolutionCacheManager)1 EndResolveEvent (org.apache.ivy.core.event.resolve.EndResolveEvent)1