Search in sources :

Example 16 with ResolveReport

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

the class IBiblioMavenSnapshotsResolutionTest method testSnapshotResolution.

/**
 * Tests that an Ivy module that depends on regular and timestamped snapshots of Maven
 * artifacts, when resolved using a {@link IBiblioResolver} and with
 * {@link MavenTimedSnapshotVersionMatcher} configured in {@link IvySettings}, is resolved
 * correctly for such snapshot dependencies.
 *
 * @throws Exception
 *             if something goes wrong
 */
@Test
public void testSnapshotResolution() throws Exception {
    final IvySettings settings = this.ivy.getSettings();
    assertNotNull("Maven timestamped snapshot revision version matcher is absent", settings.getVersionMatcher(new MavenTimedSnapshotVersionMatcher().getName()));
    final ResolveOptions resolveOptions = new ResolveOptions();
    resolveOptions.setConfs(new String[] { "default" });
    final ResolveReport report = ivy.resolve(new File("test/repositories/2/maven-snapshot-deps-test/ivy-with-maven-snapshot-deps.xml"), resolveOptions);
    assertNotNull("Resolution report was null", report);
    assertFalse("Resolution report has error(s)", report.hasError());
    final ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull("Module descriptor in resolution report was null", md);
    final ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ivy", "maven-snapshot-deps-test", "1.2.3");
    assertEquals("Unexpected module resolved", mrid, md.getModuleRevisionId());
    final ConfigurationResolveReport crr = report.getConfigurationReport("default");
    final ModuleRevisionId exactRevision = ModuleRevisionId.newInstance("org.apache.ivy.maven-snapshot-test", "exact-revision", "2.3.4");
    final ArtifactDownloadReport[] dr1 = crr.getDownloadReports(exactRevision);
    assertNotNull("Artifact download report missing for dependency " + exactRevision, dr1);
    assertEquals("Unexpected number of artifact download report for dependency " + exactRevision, dr1.length, 1);
    final ArtifactDownloadReport exactRevDownloadReport = dr1[0];
    assertEquals("Unexpected download status for dependency " + exactRevision, exactRevDownloadReport.getDownloadStatus(), DownloadStatus.SUCCESSFUL);
    final ModuleRevisionId regularSnapshot = ModuleRevisionId.newInstance("org.apache.ivy.maven-snapshot-test", "regular-snapshot", "1.2.3-SNAPSHOT");
    final ArtifactDownloadReport[] dr2 = crr.getDownloadReports(regularSnapshot);
    assertNotNull("Artifact download report missing for dependency " + regularSnapshot, dr2);
    assertEquals("Unexpected number of artifact download report for dependency " + regularSnapshot, dr2.length, 1);
    final ArtifactDownloadReport regularSnapshotDownloadReport = dr2[0];
    assertEquals("Unexpected download status for dependency " + regularSnapshot, regularSnapshotDownloadReport.getDownloadStatus(), DownloadStatus.SUCCESSFUL);
    final ModuleRevisionId timestampedSnapshot = ModuleRevisionId.newInstance("org.apache.ivy.maven-snapshot-test", "timestamped-snapshot", "5.6.7-20170911.130943-1");
    final ArtifactDownloadReport[] dr3 = crr.getDownloadReports(timestampedSnapshot);
    assertNotNull("Artifact download report missing for dependency " + timestampedSnapshot, dr3);
    assertEquals("Unexpected number of artifact download report for dependency " + timestampedSnapshot, dr3.length, 1);
    final ArtifactDownloadReport timestampedSnapshotDownloadReport = dr3[0];
    assertEquals("Unexpected download status for dependency " + timestampedSnapshot, timestampedSnapshotDownloadReport.getDownloadStatus(), DownloadStatus.SUCCESSFUL);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) IvySettings(org.apache.ivy.core.settings.IvySettings) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) File(java.io.File) Test(org.junit.Test)

Example 17 with ResolveReport

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

the class XmlReportParserTest method testGetResolvedModule.

@Test
public void testGetResolvedModule() throws Exception {
    ResolveReport report = ivy.resolve(new File("test/java/org/apache/ivy/plugins/report/ivy-with-info.xml"), getResolveOptions(new String[] { "default" }).setValidate(false).setResolveId("testGetResolvedModule"));
    assertNotNull(report);
    ModuleRevisionId modRevId = report.getModuleDescriptor().getModuleRevisionId();
    XmlReportParser parser = new XmlReportParser();
    parser.parse(ivy.getResolutionCacheManager().getConfigurationResolveReportInCache("testGetResolvedModule", "default"));
    ModuleRevisionId parsedModRevId = parser.getResolvedModule();
    assertEquals("Resolved module doesn't equals parsed module", modRevId, parsedModRevId);
}
Also used : ResolveReport(org.apache.ivy.core.report.ResolveReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) File(java.io.File) Test(org.junit.Test)

Example 18 with ResolveReport

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

the class XmlReportWriterTest method testEscapeXml.

@Test
public void testEscapeXml() throws Exception {
    ivy.configure(new File("test/repositories/IVY-635/ivysettings.xml"));
    ResolveReport report = ivy.resolve(new File("test/java/org/apache/ivy/plugins/report/ivy-635.xml"), getResolveOptions(new String[] { "default" }));
    assertNotNull(report);
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    XmlReportWriter writer = new XmlReportWriter();
    writer.output(report.getConfigurationReport("default"), buffer);
    buffer.flush();
    String xml = buffer.toString();
    String expectedArtName = "art1&_.txt";
    assertTrue("XML doesn't contain escaped artifact name", xml.contains(expectedArtName));
}
Also used : ResolveReport(org.apache.ivy.core.report.ResolveReport) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) Test(org.junit.Test)

Example 19 with ResolveReport

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

the class XmlReportWriterTest method testWriteOrigin.

@Test
public void testWriteOrigin() throws Exception {
    ResolveReport report = ivy.resolve(new File("test/repositories/1/special-encoding-root-ivy.xml"), getResolveOptions(new String[] { "default" }));
    assertNotNull(report);
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    XmlReportWriter writer = new XmlReportWriter();
    writer.output(report.getConfigurationReport("default"), buffer);
    buffer.flush();
    String xml = buffer.toString(XmlReportWriter.REPORT_ENCODING);
    String expectedLocation = "location=\"" + new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").getAbsolutePath() + "\"";
    String expectedIsLocal = "is-local=\"true\"";
    String expectedOrg = "organisation=\"sp\u00E9cial\"";
    assertTrue("XML doesn't contain artifact location attribute", xml.contains(expectedLocation));
    assertTrue("XML doesn't contain artifact is-local attribute", xml.contains(expectedIsLocal));
    assertTrue("XML doesn't contain the organisation", xml.contains(expectedOrg));
    // check that the XML is valid
    XMLHelper.parse(new ByteArrayInputStream(buffer.toByteArray()), null, new DefaultHandler(), null);
}
Also used : ResolveReport(org.apache.ivy.core.report.ResolveReport) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) DefaultHandler(org.xml.sax.helpers.DefaultHandler) Test(org.junit.Test)

Example 20 with ResolveReport

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

the class ResolveTest method testResolveConflictFromPoms.

/**
 * Test case for IVY-618.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-618">IVY-618</a>
 */
@Test
public void testResolveConflictFromPoms() throws Exception {
    ResolveReport report = ivy.resolve(new File("test/repositories/2/mod17.1/ivy-1.0.xml"), getResolveOptions(new String[] { "*" }));
    assertNotNull(report);
    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