Java Code Examples for org.apache.ivy.core.report.ResolveReport#getConfigurationReport()

The following examples show how to use org.apache.ivy.core.report.ResolveReport#getConfigurationReport() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Test case for IVY-407.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-407">IVY-407</a>
 */
@Test
public void testLatestTime1() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);

    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").setLastModified(time);
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.2.jar")
            .setLastModified(time + 2000);

    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-latest-time-1.xml"),
        getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        if (mrid.getName().equals("mod1.1")) {
            assertEquals("1.0", mrid.getRevision());
        } else if (mrid.getName().equals("mod1.2")) {
            assertEquals("2.2", mrid.getRevision());
        }
    }
}
 
Example 2
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testLatestTime2() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class.getResource("ivysettings-latest-time.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);

    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").setLastModified(time);
    new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.2.jar")
            .setLastModified(time + 2000);

    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-latest-time-2.xml"),
        getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        if (mrid.getName().equals("mod1.1")) {
            assertEquals("1.0", mrid.getRevision());
        } else if (mrid.getName().equals("mod1.2")) {
            assertEquals("2.2", mrid.getRevision());
        }
    }
}
 
Example 3
Source File: LatestCompatibleConflictManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void resolveAndAssert(String mrid, String expectedModuleSet) throws ParseException,
        IOException {
    ResolveReport report = fixture.resolve(mrid);
    assertFalse(report.hasError());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    TestHelper.assertModuleRevisionIds(expectedModuleSet, defaultReport.getModuleRevisionIds());
}
 
Example 4
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Test case for IVY-383.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-383">IVY-383</a>
 */
@Test
public void testIvy383() throws Exception {
    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-383.xml"), getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        if (mrid.getName().equals("mod1.1")) {
            assertEquals("1.0", mrid.getRevision());
        } else if (mrid.getName().equals("mod1.2")) {
            assertEquals("2.2", mrid.getRevision());
        }
    }
}
 
Example 5
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Test case for IVY-407 (with transitivity). There are 5 modules A, B, C, D and E.
 * <ol>
 * <li>publish C-1.0.0, C-1.0.1 and C-1.0.2</li>
 * <li>B needs C-1.0.0 : retrieve ok and publish B-1.0.0</li>
 * <li>A needs B-1.0.0 and C-1.0.2 : retrieve ok and publish A-1.0.0</li>
 * <li>D needs C-1.0.1 : retrieve ok and publish D-1.0.0</li>
 * <li>E needs D-1.0.0 and A-1.0.0 (D before A in ivy file) :
 * retrieve failed to get C-1.0.2 from A (get apparently C-1.0.1 from D)</li>
 * </ol>
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-407">IVY-407</a>
 */
@Test
public void testLatestTimeTransitivity() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class
            .getResource("ivysettings-latest-time-transitivity.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);

    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.0.xml").setLastModified(time);
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.1.xml")
            .setLastModified(time + 2000);
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.2.xml")
            .setLastModified(time + 4000);

    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-latest-time-transitivity.xml"),
        getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        switch (mrid.getName()) {
            case "A":
                assertEquals("A revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
            case "B":
                // by transitivity
                assertEquals("B revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
            case "C":
                assertEquals("C revision should be 1.0.2", "1.0.2", mrid.getRevision());
                break;
            case "D":
                assertEquals("D revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
        }
    }
}
 
Example 6
Source File: IBiblioMavenSnapshotsResolutionTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
/**
 * 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);

}
 
Example 7
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 3 votes vote down vote up
/**
 * Test case for IVY-1399.
 * Dependency tree:
 * <pre>
 * Mycompany#target;1
 *     MyCompany#A;1
 *         conflicting-dependency#dep;1
 *         OtherCompany#prefers-later;1
 *             conflicting-dependency#dep;2
 *     MyCompany#B;1
 *         MyCompany#A;1
 *             ...
 *         OtherCompany#prefers-later;1
 *             ...
 *         MyCompany#C;1
 *             conflicting-dependency#dep;1
 * </pre>
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-1399">IVY-1399</a>
 */
@Test
public void testEvictedModules() throws Exception {
    ivy.configure(LatestConflictManagerTest.class
            .getResource("ivysettings-evicted.xml"));

    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);
    ResolveReport report = ivy.resolve(
            new File("test/repositories/IVY-1399/MyCompany/target/ivy-1.xml"),
            getResolveOptions());
    report.getConfigurationReport("all");
}