Search in sources :

Example 26 with ResolvedModuleRevision

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

the class ChainResolverTest method testReturnFirstWithDefaultAndCacheAndRealResolver.

/**
 * Test case for IVY-389.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-389">IVY-389</a>
 */
@Test
public void testReturnFirstWithDefaultAndCacheAndRealResolver() throws Exception {
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
    // 1 ---- we first do a first resolve which puts a default file in cache
    chainToPutDefaultModuleInCache().getDependency(dd, data);
    // 2 ---- now we ask to resolve dependencies with a chain in return first mode with check
    // modified = false, in which the first resolver is not able to find the module, but the
    // second is
    ChainResolver chain = returnFirstChain();
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    // the module returned should be the default one found in cache since check modified is
    // false
    assertTrue(rmr.getDescriptor().isDefault());
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 27 with ResolvedModuleRevision

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

the class ChainResolverTest method testLatestRevisionResolve.

@Test
public void testLatestRevisionResolve() 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", false, null), 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 28 with ResolvedModuleRevision

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

the class ChainResolverTest method testLatestTimeResolve.

@Test
public void testLatestTimeResolve() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    settings.setDefaultLatestStrategy(new LatestTimeStrategy());
    MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", true, new GregorianCalendar(2005, 1, 20).getTime()), MockResolver.buildMockResolver(settings, "2", false, null), MockResolver.buildMockResolver(settings, "3", true, new GregorianCalendar(2005, 1, 25).getTime()), // younger -> should the one kept
    MockResolver.buildMockResolver(settings, "4", false, null), MockResolver.buildMockResolver(settings, "5", true, new GregorianCalendar(2005, 1, 22).getTime()), MockResolver.buildMockResolver(settings, "6", true, 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("3", 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) LatestTimeStrategy(org.apache.ivy.plugins.latest.LatestTimeStrategy) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 29 with ResolvedModuleRevision

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

the class ChainResolverTest method testResolveOrder.

@Test
public void testResolveOrder() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    MockResolver[] resolvers = new MockResolver[] { MockResolver.buildMockResolver(settings, "1", false, null), MockResolver.buildMockResolver(settings, "2", true, null), MockResolver.buildMockResolver(settings, "3", true, null) };
    for (MockResolver resolver : resolvers) {
        chain.add(resolver);
    }
    assertResolversSizeAndNames(chain, resolvers.length);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals("2", rmr.getResolver().getName());
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), resolvers[0].askedDeps);
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), resolvers[1].askedDeps);
    assertTrue(resolvers[2].askedDeps.isEmpty());
}
Also used : ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 30 with ResolvedModuleRevision

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

the class ChainResolverTest method testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver.

/**
 * Test case for IVY-207.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-207">IVY-207</a>
 */
@Test
public void testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver() throws Exception {
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
    // 1 ---- we first do a first resolve which puts a default file in cache
    chainToPutDefaultModuleInCache().getDependency(dd, data);
    // 2 ---- now we ask to resolve dependencies with a chain in return first mode, in which the
    // first resolver is not able to find the module, but the second is
    ChainResolver chain = returnFirstChain();
    chain.setCheckmodified(true);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertFalse(rmr.getDescriptor().isDefault());
    assertEquals("2", rmr.getResolver().getName());
}
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