Search in sources :

Example 6 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class ChainResolverTest method testReturnFirst.

@Test
public void testReturnFirst() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setReturnFirst(true);
    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("1", rmr.getResolver().getName());
    for (int i = 1; i < resolvers.length; i++) {
        assertTrue(resolvers[i].askedDeps.isEmpty());
    }
}
Also used : GregorianCalendar(java.util.GregorianCalendar) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 7 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class ChainResolverTest method testFixedWithDefaultAndRealResolver.

/**
 * Test case for IVY-206.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-206">IVY-206</a>
 */
@Test
public void testFixedWithDefaultAndRealResolver() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    // no ivy pattern for first resolver: will only find a 'default' module
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("1");
    resolver.setSettings(settings);
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    chain.add(resolver);
    // second resolver has an ivy pattern and will thus find the real module, which should be
    // kept
    resolver = new FileSystemResolver();
    resolver.setName("2");
    resolver.setSettings(settings);
    resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    chain.add(resolver);
    settings.addResolver(chain);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    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)

Example 8 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class ChainResolverTest method testFixedWithDefault.

@Test
public void testFixedWithDefault() 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), // default
    MockResolver.buildMockResolver(settings, "3", false, null), MockResolver.buildMockResolver(settings, "4", true, ModuleRevisionId.newInstance("org", "mod", "4"), new GregorianCalendar(2005, 1, 22).getTime()), // not default -> should be the one kept
    MockResolver.buildMockResolver(settings, "5", 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("4", rmr.getResolver().getName());
    List<DependencyDescriptor> ddAsList = Collections.<DependencyDescriptor>singletonList(dd);
    for (int i = 0; i < 4; i++) {
        assertEquals("invalid asked dependencies for " + resolvers[i], ddAsList, resolvers[i].askedDeps);
    }
    for (int i = 4; i < resolvers.length; i++) {
        assertTrue("invalid asked dependencies for " + resolvers[i], 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 9 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class DualResolverTest method testResolveFail.

@Test
public void testResolveFail() throws Exception {
    DualResolver dual = new DualResolver();
    MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false, new GregorianCalendar(2005, 1, 20).getTime());
    MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", false, new GregorianCalendar(2005, 1, 20).getTime());
    dual.setIvyResolver(ivyResolver);
    dual.setArtifactResolver(artifactResolver);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = dual.getDependency(dd, data);
    assertNull(rmr);
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), artifactResolver.askedDeps);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Example 10 with DefaultDependencyDescriptor

use of org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor in project ant-ivy by apache.

the class DualResolverTest method testResolveFromArtifact.

@Test
public void testResolveFromArtifact() throws Exception {
    DualResolver dual = new DualResolver();
    MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false, new GregorianCalendar(2005, 1, 20).getTime());
    MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", true, new GregorianCalendar(2005, 1, 20).getTime());
    dual.setIvyResolver(ivyResolver);
    dual.setArtifactResolver(artifactResolver);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = dual.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals(artifactResolver, rmr.getResolver());
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), ivyResolver.askedDeps);
    assertEquals(Collections.<DependencyDescriptor>singletonList(dd), artifactResolver.askedDeps);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) Test(org.junit.Test)

Aggregations

DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)80 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)61 Test (org.junit.Test)60 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)47 GregorianCalendar (java.util.GregorianCalendar)25 Date (java.util.Date)23 Artifact (org.apache.ivy.core.module.descriptor.Artifact)23 File (java.io.File)22 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)19 DownloadReport (org.apache.ivy.core.report.DownloadReport)18 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)16 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)12 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)9 DownloadOptions (org.apache.ivy.core.resolve.DownloadOptions)9 LatestRevisionStrategy (org.apache.ivy.plugins.latest.LatestRevisionStrategy)7 Configuration (org.apache.ivy.core.module.descriptor.Configuration)6 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 BufferedReader (java.io.BufferedReader)3 Locale (java.util.Locale)3