Search in sources :

Example 6 with ChainResolver

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

the class XmlSettingsParserTest method testRef.

@Test
public void testRef() throws Exception {
    IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-ref.xml"));
    DependencyResolver internal = settings.getResolver("internal");
    assertNotNull(internal);
    assertTrue(internal instanceof ChainResolver);
    ChainResolver chain = (ChainResolver) internal;
    List<DependencyResolver> subresolvers = chain.getResolvers();
    assertNotNull(subresolvers);
    assertEquals(2, subresolvers.size());
    FileSystemResolver fsInt1 = (FileSystemResolver) subresolvers.get(0);
    assertEquals("fs", fsInt1.getName());
    List<String> ivyPatterns = fsInt1.getIvyPatterns();
    assertNotNull(ivyPatterns);
    assertEquals(1, ivyPatterns.size());
    assertLocationEquals("sharedrep/[organisation]/[module]/ivys/ivy-[revision].xml", ivyPatterns.get(0));
    DependencyResolver external = settings.getResolver("external");
    assertNotNull(external);
    assertTrue(external instanceof ChainResolver);
    chain = (ChainResolver) external;
    subresolvers = chain.getResolvers();
    assertNotNull(subresolvers);
    assertEquals(1, subresolvers.size());
    FileSystemResolver fsInt2 = (FileSystemResolver) subresolvers.get(0);
    assertEquals("fs", fsInt2.getName());
    ivyPatterns = fsInt2.getIvyPatterns();
    assertNotNull(ivyPatterns);
    assertEquals(1, ivyPatterns.size());
    assertLocationEquals("sharedrep/[organisation]/[module]/ivys/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)

Example 7 with ChainResolver

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

the class XmlSettingsParserTest method testIncludeSpecialCharInName.

@Test
public void testIncludeSpecialCharInName() throws Exception {
    IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-include-special.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));
    DependencyResolver inc = settings.getResolver("includeworks");
    assertNotNull(inc);
    assertTrue(inc instanceof ChainResolver);
    chain = (ChainResolver) inc;
    subresolvers = chain.getResolvers();
    assertNotNull(subresolvers);
    assertEquals(2, subresolvers.size());
    fsInt1 = (FileSystemResolver) subresolvers.get(0);
    assertEquals("includeworks-fs1", fsInt1.getName());
    ivyPatterns = fsInt1.getIvyPatterns();
    assertNotNull(ivyPatterns);
    assertEquals(1, ivyPatterns.size());
    assertLocationEquals("included/myrep/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]", ivyPatterns.get(0));
    // properties defined in included file should be available to including file (IVY-780)
    assertEquals("myvalue", settings.getVariable("ivy.test.prop"));
}
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 8 with ChainResolver

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

the class UpdateSiteAndIbiblioResolverTest method setUp.

@Before
public void setUp() throws Exception {
    settings = new IvySettings();
    chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    resolver = new UpdateSiteResolver();
    resolver.setName("ivyde-repo");
    resolver.setUrl(new File("test/test-p2/ivyde-repo").toURI().toURL().toExternalForm());
    resolver.setSettings(settings);
    resolver2 = new IBiblioResolver();
    resolver2.setName("maven2");
    settings.setVariable("ivy.ibiblio.default.artifact.root", DEFAULT_M2_ROOT);
    settings.setVariable("ivy.ibiblio.default.artifact.pattern", "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
    resolver2.setSettings(settings);
    chain.add(resolver);
    chain.add(resolver2);
    settings.addResolver(chain);
    settings.setDefaultResolver("chain");
    cache = new File("build/cache");
    cache.mkdirs();
    settings.setDefaultCache(cache);
    ivy = new Ivy();
    ivy.setSettings(settings);
    ivy.bind();
    ivy.getResolutionCacheManager().clean();
    RepositoryCacheManager[] caches = settings.getRepositoryCacheManagers();
    for (RepositoryCacheManager cache : caches) {
        cache.clean();
    }
    data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
}
Also used : ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) IBiblioResolver(org.apache.ivy.plugins.resolver.IBiblioResolver) ResolveData(org.apache.ivy.core.resolve.ResolveData) RepositoryCacheManager(org.apache.ivy.core.cache.RepositoryCacheManager) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) Ivy(org.apache.ivy.Ivy) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 9 with ChainResolver

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

the class OnlineXmlSettingsParserTest method testIncludeHttpAbsoluteFile.

@Test
public void testIncludeHttpAbsoluteFile() throws Exception {
    // Use a settings file via http that use an include with absolute file
    // WARNING : this test will only work if the test are launched from the project root
    // directory
    configureURLHandler();
    IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(new URL("http://ant.apache.org/ivy/test/ivysettings-include-http-absolute-file.xml"));
    DependencyResolver inc = settings.getResolver("includeworks");
    assertNotNull(inc);
    assertTrue(inc instanceof ChainResolver);
}
Also used : ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) URL(java.net.URL) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) Test(org.junit.Test)

Example 10 with ChainResolver

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

the class XmlSettingsParserTest method testIncludeAbsoluteFile.

@Test
public void testIncludeAbsoluteFile() throws Exception {
    // WARNING : this test will only work if the test are launched from the project root
    // directory
    IvySettings settings = new IvySettings();
    XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-include-absolute-file.xml"));
    DependencyResolver inc = settings.getResolver("includeworks");
    assertNotNull(inc);
    assertTrue(inc instanceof ChainResolver);
}
Also used : ChainResolver(org.apache.ivy.plugins.resolver.ChainResolver) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver) 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