Search in sources :

Example 76 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class Maven2LocalTest method testNotUseMetadataForListing.

@Test
public void testNotUseMetadataForListing() throws Exception {
    IBiblioResolver resolver = maven2Resolver();
    resolver.setUseMavenMetadata(false);
    ResolvedModuleRevision m = resolver.getDependency(new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org.apache", "test-metadata", "latest.integration"), false), data);
    assertNotNull(m);
    // should trust listing revisions (latest=1.2) instead of the metadata (latest=1.1)
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-metadata", "1.2"), m.getId());
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 77 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class BintrayResolverTest method testBintray.

@Test
public void testBintray() throws Exception {
    BintrayResolver resolver = new BintrayResolver();
    resolver.setSettings(settings);
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ant", "ant-antunit", "1.2");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "jar", "jar");
    DownloadReport report = resolver.download(new Artifact[] { artifact }, downloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] { artifact }, downloadOptions());
    assertNotNull(report);
    assertEquals(1, report.getArtifactsReports().length);
    ar = report.getArtifactReport(artifact);
    assertNotNull(ar);
    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 78 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class ChainResolverTest method testLatestWithDefault.

@Test
public void testLatestWithDefault() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setLatestStrategy(new LatestRevisionStrategy());
    MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", true, ModuleRevisionId.newInstance("org", "mod", "1"), new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest -> but default
    MockResolver.buildMockResolver(settings, "3", true, ModuleRevisionId.newInstance("org", "mod", "2"), new GregorianCalendar(2005, 1, 25).getTime()), MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> should the one kept
    MockResolver.buildMockResolver(settings, "6", true, ModuleRevisionId.newInstance("org", "mod", "3"), new GregorianCalendar(2005, 1, 18).getTime()), MockResolver.buildMockResolver(settings, "7", false, null) };
    for (MockResolver resolver : resolvers) {
        chain.add(resolver);
    }
    assertResolversSizeAndNames(chain, resolvers.length);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "latest.integration"), false);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals("5", rmr.getResolver().getName());
    List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
    for (MockResolver resolver : resolvers) {
        assertEquals(ddAsList, resolver.askedDeps);
    }
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) GregorianCalendar(java.util.GregorianCalendar) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) LatestRevisionStrategy(org.apache.ivy.plugins.latest.LatestRevisionStrategy) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 79 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class ChainResolverTest method testWithDefault.

@Test
public void testWithDefault() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setLatestStrategy(new LatestRevisionStrategy());
    MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime(), true), // latest -> but default
    MockResolver.buildMockResolver(settings, "3", false, null), MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // latest -> should be the one kept
    MockResolver.buildMockResolver(settings, "6", false, null), MockResolver.buildMockResolver(settings, "7", false, null) };
    for (MockResolver resolver : resolvers) {
        chain.add(resolver);
    }
    assertResolversSizeAndNames(chain, resolvers.length);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "4"), false);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals("5", rmr.getResolver().getName());
    List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
    for (int i = 0; i < 5; i++) {
        assertEquals(ddAsList, resolvers[i].askedDeps);
    }
    for (int i = 5; i < resolvers.length; i++) {
        assertTrue(resolvers[i].askedDeps.isEmpty());
    }
}
Also used : DependencyDescriptor(org.apache.ivy.core.module.descriptor.DependencyDescriptor) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) GregorianCalendar(java.util.GregorianCalendar) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) LatestRevisionStrategy(org.apache.ivy.plugins.latest.LatestRevisionStrategy) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 80 with ResolvedModuleRevision

use of org.apache.ivy.core.resolve.ResolvedModuleRevision in project ant-ivy by apache.

the class MirroredURLResolverTest method testFailover.

@Test
public void testFailover() throws Exception {
    DependencyResolver resolver = settings.getResolver("failover");
    assertNotNull(resolver);
    assertTrue(resolver instanceof MirroredURLResolver);
    MirroredURLResolver mirrored = (MirroredURLResolver) resolver;
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
    ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
    assertNotNull(rmr);
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Aggregations

ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)89 Test (org.junit.Test)63 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)61 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)45 Artifact (org.apache.ivy.core.module.descriptor.Artifact)25 GregorianCalendar (java.util.GregorianCalendar)24 File (java.io.File)19 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)19 Date (java.util.Date)18 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)18 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)18 DownloadReport (org.apache.ivy.core.report.DownloadReport)18 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)17 IOException (java.io.IOException)14 ParseException (java.text.ParseException)14 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)13 ResolveData (org.apache.ivy.core.resolve.ResolveData)11 MockResolver (org.apache.ivy.plugins.resolver.MockResolver)9 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)8 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)8