Search in sources :

Example 11 with ChainResolver

use of org.apache.ivy.plugins.resolver.ChainResolver in project ant-ivy by apache.

the class XmlSettingsParserTest method testMacroAndRef.

/**
 * Test case for IVY-319.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-319">IVY-319</a>
 */
@Test
public void testMacroAndRef() throws Exception {
    IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-macro+ref.xml"));
    DependencyResolver shared = settings.getResolver("shared");
    assertNotNull(shared);
    assertTrue(shared instanceof FileSystemResolver);
    DependencyResolver mychain = settings.getResolver("mychain");
    assertNotNull(mychain);
    assertTrue(mychain instanceof ChainResolver);
    ChainResolver chain = (ChainResolver) mychain;
    List<DependencyResolver> subresolvers = chain.getResolvers();
    assertNotNull(subresolvers);
    assertEquals(1, subresolvers.size());
    shared = subresolvers.get(0);
    assertEquals("shared", shared.getName());
    assertTrue(shared instanceof FileSystemResolver);
}
Also used : ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Example 12 with ChainResolver

use of org.apache.ivy.plugins.resolver.ChainResolver in project ant-ivy by apache.

the class XmlSettingsParserTest method testMacro.

@Test
public void testMacro() throws Exception {
    IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-macro.xml"));
    DependencyResolver def = settings.getResolver("default");
    assertNotNull(def);
    assertTrue(def instanceof ChainResolver);
    ChainResolver chain = (ChainResolver) def;
    List<DependencyResolver> subresolvers = chain.getResolvers();
    assertNotNull(subresolvers);
    assertEquals(2, subresolvers.size());
    FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers.get(0);
    assertEquals("default-fs1", fsInt1.getName());
    List<String> ivyPatterns = fsInt1.getIvyPatterns();
    assertNotNull(ivyPatterns);
    assertEquals(1, ivyPatterns.size());
    assertLocationEquals("path/to/myrep/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]", ivyPatterns.get(0));
    FileSystemResolver fsInt2 = (FileSystemResolver) subresolvers.get(1);
    assertEquals("default-fs2", fsInt2.getName());
    ivyPatterns = fsInt2.getIvyPatterns();
    assertNotNull(ivyPatterns);
    assertEquals(1, ivyPatterns.size());
    assertLocationEquals("path/to/secondrep/[organisation]/[module]/[type]s/ivy-[revision].xml", ivyPatterns.get(0));
    DependencyResolver other = settings.getResolver("other");
    assertNotNull(other);
    assertTrue(other instanceof ChainResolver);
    chain = (ChainResolver) other;
    subresolvers = chain.getResolvers();
    assertNotNull(subresolvers);
    assertEquals(2, subresolvers.size());
    fsInt2 = (FileSystemResolver) subresolvers.get(1);
    assertEquals("other-fs2", fsInt2.getName());
    ivyPatterns = fsInt2.getIvyPatterns();
    assertNotNull(ivyPatterns);
    assertEquals(1, ivyPatterns.size());
    assertLocationEquals("path/to/secondrep/[module]/[type]s/ivy-[revision].xml", ivyPatterns.get(0));
}
Also used : ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Aggregations

ChainResolver (org.apache.ivy.plugins.resolver.ChainResolver)12 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)11 Test (org.junit.Test)10 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)9 FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)6 File (java.io.File)2 IBiblioResolver (org.apache.ivy.plugins.resolver.IBiblioResolver)2 URL (java.net.URL)1 Ivy (org.apache.ivy.Ivy)1 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)1 ResolveData (org.apache.ivy.core.resolve.ResolveData)1 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)1 IvySettings (org.apache.ivy.core.settings.IvySettings)1 LatestRevisionStrategy (org.apache.ivy.plugins.latest.LatestRevisionStrategy)1 LatestStrategy (org.apache.ivy.plugins.latest.LatestStrategy)1 LatestTimeStrategy (org.apache.ivy.plugins.latest.LatestTimeStrategy)1 DualResolver (org.apache.ivy.plugins.resolver.DualResolver)1 MockResolver (org.apache.ivy.plugins.resolver.MockResolver)1 WorkspaceChainResolver (org.apache.ivy.plugins.resolver.WorkspaceChainResolver)1 Before (org.junit.Before)1