Search in sources :

Example 56 with ResolveReport

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

the class ResolveTest method testResolverDirectlyUsingCache.

@Test
public void testResolverDirectlyUsingCache() throws Exception {
    Ivy ivy = new Ivy();
    ivy.configure(ResolveTest.class.getResource("badcacheconf.xml"));
    File depIvyFileInCache = getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"));
    // creates a
    FileUtil.copy(File.createTempFile("test", "xml"), depIvyFileInCache, null);
    // fake
    // dependency
    // file in cache
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.4/ivys/ivy-0.3.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org2", "mod2.4", "0.3");
    assertEquals(mrid, md.getModuleRevisionId());
    assertTrue(getResolvedIvyFileInCache(mrid).exists());
    // dependencies
    assertTrue(depIvyFileInCache.exists());
    assertFalse(getArchiveFileInCache(ivy, "org1", "mod1.1", "1.0", "mod1.1", "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) Ivy(org.apache.ivy.Ivy) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 57 with ResolveReport

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

the class ResolveTest method testArtifactOrigin.

@Test
public void testArtifactOrigin() throws Exception {
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "default" }));
    assertNotNull(report);
    ArtifactDownloadReport[] dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"));
    assertNotNull(dReports);
    assertEquals("number of downloaded artifacts not correct", 1, dReports.length);
    Artifact artifact = dReports[0].getArtifact();
    assertNotNull(artifact);
    String expectedLocation = new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").getAbsolutePath();
    // verify the origin in the report
    ArtifactOrigin reportOrigin = dReports[0].getArtifactOrigin();
    assertNotNull(reportOrigin);
    assertTrue("isLocal for artifact not correct", reportOrigin.isLocal());
    assertEquals("location for artifact not correct", expectedLocation, reportOrigin.getLocation());
    // verify the saved origin on disk
    ArtifactOrigin ivyOrigin = getSavedArtifactOrigin(artifact);
    assertNotNull(ivyOrigin);
    assertTrue("isLocal for artifact not correct", ivyOrigin.isLocal());
    assertEquals("location for artifact not correct", expectedLocation, ivyOrigin.getLocation());
    // now resolve the same artifact again and verify the origin of the (not-downloaded)
    // artifact
    report = ivy.resolve(new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "default" }));
    assertNotNull(report);
    dReports = report.getConfigurationReport("default").getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"));
    assertNotNull(dReports);
    assertEquals("number of downloaded artifacts not correct", 1, dReports.length);
    assertEquals("download status not correct", DownloadStatus.NO, dReports[0].getDownloadStatus());
    reportOrigin = dReports[0].getArtifactOrigin();
    assertNotNull(reportOrigin);
    assertTrue("isLocal for artifact not correct", reportOrigin.isLocal());
    assertEquals("location for artifact not correct", expectedLocation, reportOrigin.getLocation());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ArtifactOrigin(org.apache.ivy.core.cache.ArtifactOrigin) JarFile(java.util.jar.JarFile) File(java.io.File) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 58 with ResolveReport

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

the class ResolveTest method testTransitiveSetting2.

/**
 * Test case for IVY-105.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-105">IVY-105</a>
 */
@Test
public void testTransitiveSetting2() throws Exception {
    // mod2.7 depends on mod1.1 and mod2.4
    // mod2.4 depends on mod1.1 with transitive set to false
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File("test/repositories/1/org2/mod2.7/ivys/ivy-0.6.xml"), getResolveOptions(new String[] { "*" }));
    assertFalse(report.hasError());
    // dependencies
    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.0")).exists());
    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 59 with ResolveReport

use of org.apache.ivy.core.report.ResolveReport 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 60 with ResolveReport

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

the class ResolveTest method testMultipleEviction.

/**
 * Test case for IVY-644.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-644">IVY-644</a>
 */
@Test
public void testMultipleEviction() throws Exception {
    ResolveReport report = ivy.resolve(new File("test/repositories/1/IVY-644/M1/ivys/ivy-1.0.xml"), getResolveOptions(new String[] { "test", // NB the order impact the bug
    "runtime" }));
    assertFalse(report.hasError());
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

ResolveReport (org.apache.ivy.core.report.ResolveReport)278 Test (org.junit.Test)259 File (java.io.File)253 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)218 JarFile (java.util.jar.JarFile)199 Ivy (org.apache.ivy.Ivy)102 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)101 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)94 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)15 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)13 BuildException (org.apache.tools.ant.BuildException)9 URL (java.net.URL)8 HashMap (java.util.HashMap)8 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)8 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)7 Artifact (org.apache.ivy.core.module.descriptor.Artifact)7 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)6