Search in sources :

Example 16 with ConfigurationResolveReport

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

the class ResolveTest method testVersionRange1.

@Test
public void testVersionRange1() throws Exception {
    // mod 1.4 depends on mod1.2 [1.0,2.0[
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] { "default" }));
    assertFalse(report.hasError());
    // dependencies
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "1.1");
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(depId).length);
    assertTrue(getIvyFileInCache(depId).exists());
}
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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 17 with ConfigurationResolveReport

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

the class ResolveTest method testResolveConflict2.

@Test
public void testResolveConflict2() throws Exception {
    // mod4.1 v 4.14 depends on
    // - mod1.1 v 1.0 which depends on mod1.2 v 2.0
    // - mod3.1 v 1.1 which depends on mod1.2 v 2.1
    // - mod6.1 v 0.3 which depends on mod1.2 v 2.0
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod4.1/ivy-4.14.xml"), getResolveOptions(new String[] { "*" }));
    // dependencies
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).length);
    assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).length);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.14");
    File r = getConfigurationResolveReportInCache(ResolveOptions.getDefaultResolveId(mrid.getModuleId()), "default");
    assertTrue(r.exists());
    final boolean[] found = new boolean[] { false };
    SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
    saxParser.parse(r, new DefaultHandler() {

        @Override
        public void startElement(String uri, String localName, String qName, Attributes attributes) {
            if ("revision".equals(qName) && "2.0".equals(attributes.getValue("name"))) {
                found[0] = true;
            }
        }
    });
    // the report should contain the evicted revision
    assertTrue(found[0]);
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org3", "mod3.1", "1.1")).exists());
    assertTrue(getArchiveFileInCache("org3", "mod3.1", "1.1", "mod3.1", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Attributes(org.xml.sax.Attributes) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) SAXParser(javax.xml.parsers.SAXParser) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) DefaultHandler(org.xml.sax.helpers.DefaultHandler) Test(org.junit.Test)

Example 18 with ConfigurationResolveReport

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

the class ResolveTest method testLatestMilestone.

@Test
public void testLatestMilestone() throws Exception {
    // mod9.2 depends on latest.milestone of mod6.4
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org9/mod9.2/ivys/ivy-1.1.xml"), getResolveOptions(new String[] { "default" }));
    assertFalse(report.hasError());
    // dependencies
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org6", "mod6.4", "3");
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(depId).length);
    assertTrue(getIvyFileInCache(depId).exists());
}
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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 19 with ConfigurationResolveReport

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

the class ResolveTest method testResolveMultipleConfsWithConflicts.

/**
 * Test case for IVY-173.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-173">IVY-173</a>
 */
@Test
public void testResolveMultipleConfsWithConflicts() throws Exception {
    // mod6.2 has two confs compile and run
    // depends on mod1.2 2.1 in conf (compile->default)
    // depends on mod1.1 1.0 in conf (*->default)
    // depends on mod6.1 in conf (*->default)
    // mod6.1
    // depends on mod1.2 2.1
    // mod1.1
    // depends on mod1.2 2.0
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org6/mod6.2/ivys/ivy-0.5.xml"), getResolveOptions(new String[] { "compile", "run" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.5");
    assertEquals(mrid, md.getModuleRevisionId());
    ConfigurationResolveReport crr = report.getConfigurationReport("compile");
    assertNotNull(crr);
    assertEquals(3, crr.getArtifactsNumber());
    crr = report.getConfigurationReport("run");
    assertNotNull(crr);
    assertEquals(3, crr.getArtifactsNumber());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org6", "mod6.1", "0.5")).exists());
    assertTrue(getArchiveFileInCache("org6", "mod6.1", "0.5", "mod6.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
    assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) 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) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 20 with ConfigurationResolveReport

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

the class ResolveTest method testMultiConfs.

@Test
public void testMultiConfs() throws Exception {
    // mod 5.2 depends on mod5.1 conf B in its conf B and conf A in its conf A
    // mod5.1 conf B publishes art51B
    // mod5.1 conf A publishes art51A
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod5.2/ivy-2.0.xml"), getResolveOptions(new String[] { "B", "A" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org5", "mod5.2", "2.0");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org5", "mod5.1", "4.1");
    ConfigurationResolveReport crr = report.getConfigurationReport("A");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(depId).length);
    File r = new File(cache, ResolveOptions.getDefaultResolveId(mrid.getModuleId()) + "-A.xml");
    assertTrue(r.exists());
    final boolean[] found = new boolean[] { false };
    SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
    saxParser.parse(r, new DefaultHandler() {

        @Override
        public void startElement(String uri, String localName, String qName, Attributes attributes) {
            if ("artifact".equals(qName) && "art51B".equals(attributes.getValue("name"))) {
                found[0] = true;
            }
        }
    });
    assertFalse(found[0]);
    assertTrue(getIvyFileInCache(depId).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.1", "art51A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.1", "art51B", "jar", "jar").exists());
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) Attributes(org.xml.sax.Attributes) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) SAXParser(javax.xml.parsers.SAXParser) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) DefaultHandler(org.xml.sax.helpers.DefaultHandler) 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