Search in sources :

Example 6 with ConfigurationResolveReport

use of org.apache.ivy.core.report.ConfigurationResolveReport 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());
}
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 7 with ConfigurationResolveReport

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

the class ResolveTest method testConfigurationMapping4.

/**
 * 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 testConfigurationMapping4() 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/4/ivy.xml"), getResolveOptions(new String[] { "default" }));
    ConfigurationResolveReport conf = report.getConfigurationReport("default");
    assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "a", "1.0.2", "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);
}
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 8 with ConfigurationResolveReport

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

the class ResolveTest method testConfigurationMapping5.

/**
 * 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 testConfigurationMapping5() 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/5/ivy.xml"), getResolveOptions(new String[] { "*" }));
    ConfigurationResolveReport conf = report.getConfigurationReport("default");
    assertContainsArtifact("test", "a", "1.0.2", "a", "txt", "txt", conf);
    assertDoesntContainArtifact("test", "a", "1.0.2", "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);
}
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 9 with ConfigurationResolveReport

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

the class ResolveTest method testResolveModeDynamic2.

@Test
public void testResolveModeDynamic2() throws Exception {
    // same as ResolveModeDynamic1, but resolve mode is set in settings
    Map<String, String> attributes = new HashMap<>();
    attributes.put("organisation", "org1");
    attributes.put("module", "mod1.2");
    ivy.getSettings().addModuleConfiguration(attributes, ExactPatternMatcher.INSTANCE, null, null, null, ResolveOptions.RESOLVEMODE_DYNAMIC);
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.1.xml"), getResolveOptions(new String[] { "default" }));
    assertNotNull(report);
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "2.2");
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertEquals(1, crr.getDownloadReports(depId).length);
    assertTrue(getIvyFileInCache(depId).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) HashMap(java.util.HashMap) 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 10 with ConfigurationResolveReport

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

the class ResolveTest method testLatest.

@Test
public void testLatest() throws Exception {
    // mod1.4 depends on latest mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml"), getResolveOptions(new String[] { "default" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.1");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "2.2");
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(1, crr.getDownloadReports(depId).length);
    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 ("artifact".equals(qName) && "mod1.2".equals(attributes.getValue("name"))) {
                found[0] = true;
            }
        }
    });
    assertTrue(found[0]);
    assertTrue(getIvyFileInCache(depId).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "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) 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