Search in sources :

Example 1 with MavenTimedSnapshotVersionMatcher

use of org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher in project ant-ivy by apache.

the class IBiblioMavenSnapshotsResolutionTest method before.

@Before
public void before() throws Exception {
    TestHelper.createCache();
    this.ivy = new Ivy();
    this.ivy.configure(new File("test/repositories/ivysettings.xml"));
    // add the maven timestamped snapshot version matcher
    this.ivy.getSettings().addVersionMatcher(new MavenTimedSnapshotVersionMatcher());
}
Also used : MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) Ivy(org.apache.ivy.Ivy) File(java.io.File) Before(org.junit.Before)

Example 2 with MavenTimedSnapshotVersionMatcher

use of org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher 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 3 with MavenTimedSnapshotVersionMatcher

use of org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher in project ant-ivy by apache.

the class XmlSettingsParserTest method testMavenTimedSnapshotVersionMatcher.

/**
 * Tests that the {@code maven-tsnap-vm} version matcher, configured in the settings file,
 * is parsed correctly
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testMavenTimedSnapshotVersionMatcher() throws Exception {
    final IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-maven-tsnap-vmatcher.xml"));
    final VersionMatcher mavenTSnapVersionMatcher = settings.getVersionMatcher(new MavenTimedSnapshotVersionMatcher().getName());
    assertNotNull("Maven timestamped snapshot version matcher is missing", mavenTSnapVersionMatcher);
    assertTrue("Unexpected type for Maven timestamped snapshot version matcher", mavenTSnapVersionMatcher instanceof MavenTimedSnapshotVersionMatcher);
}
Also used : ChainVersionMatcher(org.apache.ivy.plugins.version.ChainVersionMatcher) MockVersionMatcher(org.apache.ivy.plugins.version.MockVersionMatcher) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) VersionMatcher(org.apache.ivy.plugins.version.VersionMatcher) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Aggregations

MavenTimedSnapshotVersionMatcher (org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher)3 File (java.io.File)2 Test (org.junit.Test)2 Ivy (org.apache.ivy.Ivy)1 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)1 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)1 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)1 ResolveReport (org.apache.ivy.core.report.ResolveReport)1 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)1 IvySettings (org.apache.ivy.core.settings.IvySettings)1 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)1 ChainVersionMatcher (org.apache.ivy.plugins.version.ChainVersionMatcher)1 MockVersionMatcher (org.apache.ivy.plugins.version.MockVersionMatcher)1 VersionMatcher (org.apache.ivy.plugins.version.VersionMatcher)1 Before (org.junit.Before)1