Search in sources :

Example 11 with ConfigurationResolveReport

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

the class ResolveTest method testResolveExtendedAndExtends.

@Test
public void testResolveExtendedAndExtends() throws Exception {
    // mod6.1 depends on mod1.2 2.0 in conf default, and conf extension extends default
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org6/mod6.1/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "default", "extension" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "0.3");
    assertEquals(mrid, md.getModuleRevisionId());
    ConfigurationResolveReport crr = report.getConfigurationReport("default");
    assertNotNull(crr);
    assertEquals(1, crr.getArtifactsNumber());
    crr = report.getConfigurationReport("extension");
    assertNotNull(crr);
    assertEquals(1, crr.getArtifactsNumber());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertTrue(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 12 with ConfigurationResolveReport

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

the class ResolveTest method testIVY999.

/**
 * Test case for IVY-999.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-999">IVY-999</a>
 */
@Test
public void testIVY999() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport rr = ivy.resolve(ResolveTest.class.getResource("ivy-999.xml"), getResolveOptions(new String[] { "*" }));
    ConfigurationResolveReport crr = rr.getConfigurationReport("default");
    Set<ModuleRevisionId> modRevIds = crr.getModuleRevisionIds();
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "4.4")));
    assertFalse(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "3.8")));
}
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 13 with ConfigurationResolveReport

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

the class ResolveTest method testEvictWithConfInMultiConf2.

@Test
public void testEvictWithConfInMultiConf2() throws Exception {
    // same as preceding one but the conflict appears in a root conf and not in another
    // which should keep the evicted
    // bug 105 - test #4
    // mod6.1 r1.3 conf A depends on
    // mod5.2 r1.0 which depends on mod5.1 r4.0 conf B
    // 
    // mod6.1 r1.3 conf B depends on
    // mod5.2 r1.0 which depends on mod5.1 r4.0 conf B
    // mod5.1 r4.2 conf A
    // 
    // mod5.1 r4.2 conf B depends on mod1.2 r2.0
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod6.1/ivy-1.3.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.1", "1.3");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.2", "art51A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.2", "art51B", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org5", "mod5.1", "4.0")).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.0", "art51A", "jar", "jar").exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.1", "4.0", "art51B", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org5", "mod5.2", "1.0")).exists());
    assertTrue(getArchiveFileInCache("org5", "mod5.2", "1.0", "mod5.2", "jar", "jar").exists());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
    // 4.2 artifacts should be present in conf B only
    ConfigurationResolveReport crr = report.getConfigurationReport("A");
    assertNotNull(crr);
    assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length);
    crr = report.getConfigurationReport("B");
    assertNotNull(crr);
    assertEquals(2, crr.getDownloadReports(ModuleRevisionId.newInstance("org5", "mod5.1", "4.2")).length);
}
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 14 with ConfigurationResolveReport

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

the class ResolveTest method testIVY1333.

/**
 * Test case for IVY-1333.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1333">IVY-1333</a>
 */
@Test
public void testIVY1333() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(new File("test/repositories/IVY-1333/ivysettings.xml"));
    ivy.getSettings().setDefaultCache(cache);
    ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1333/ivy.xml"), getResolveOptions(new String[] { "*" }));
    ConfigurationResolveReport crr = rr.getConfigurationReport("default");
    Set<ModuleRevisionId> modRevIds = crr.getModuleRevisionIds();
    assertEquals(3, modRevIds.size());
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep1", "1.0")));
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep2", "1.0")));
    Map<String, String> extra = new HashMap<>();
    extra.put("o:a", "58701");
    assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "badArtifact", "1.0.0.m4", extra)));
}
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) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 15 with ConfigurationResolveReport

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

the class ResolveTest method testResolveMultipleConfsWithLatest.

/**
 * Test case for IVY-188.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-188">IVY-188</a>
 */
@Test
public void testResolveMultipleConfsWithLatest() throws Exception {
    // mod6.2 has two confs compile and run
    // depends on mod6.1 in conf (compile->default)
    // depends on mod1.2 latest (which is 2.2) in conf (run->default)
    // mod6.1
    // depends on mod1.2 2.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org6/mod6.2/ivys/ivy-0.6.xml"), getResolveOptions(new String[] { "compile", "run" }));
    assertNotNull(report);
    assertFalse(report.hasError());
    ConfigurationResolveReport crr = report.getConfigurationReport("compile");
    assertNotNull(crr);
    assertEquals(2, crr.getArtifactsNumber());
    crr = report.getConfigurationReport("run");
    assertNotNull(crr);
    assertEquals(1, crr.getArtifactsNumber());
    assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.2")).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) 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