Search in sources :

Example 16 with FileSystemResolver

use of org.apache.ivy.plugins.resolver.FileSystemResolver 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 17 with FileSystemResolver

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

the class XmlSettingsParserTest method testResolverTimeoutConstraintRefs.

/**
 * Tests that timeout constraints referenced by resolvers, in an ivy settings file, are
 * processed correctly and the corresponding resolvers use the right timeout constraints
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testResolverTimeoutConstraintRefs() throws Exception {
    final IvySettings settings = new IvySettings();
    settings.setBaseDir(new File("test/base/dir"));
    final XmlSettingsParser parser = new XmlSettingsParser(settings);
    parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-timeout-constraints.xml"));
    final URLResolver resolver1 = (URLResolver) settings.getResolver("urlresolver-1");
    assertNotNull("Missing resolver urlresolver-1", resolver1);
    final TimeoutConstraint resolver1Timeouts = resolver1.getTimeoutConstraint();
    assertNotNull("Timeout constraint missing on resolver " + resolver1.getName(), resolver1Timeouts);
    assertEquals("Unexpected connection timeout " + resolver1Timeouts.getConnectionTimeout() + " on resolver " + resolver1.getName(), 400, resolver1Timeouts.getConnectionTimeout());
    assertEquals("Unexpected read timeout " + resolver1Timeouts.getReadTimeout() + " on resolver " + resolver1.getName(), -1, resolver1Timeouts.getReadTimeout());
    final IBiblioResolver resolver2 = (IBiblioResolver) settings.getResolver("ibiblio-resolver");
    assertNotNull("Missing resolver ibiblio-resolver", resolver2);
    final TimeoutConstraint resolver2Timeouts = resolver2.getTimeoutConstraint();
    assertNotNull("Timeout constraint missing on resolver " + resolver2.getName(), resolver2Timeouts);
    assertEquals("Unexpected connection timeout " + resolver2Timeouts.getConnectionTimeout() + " on resolver " + resolver2.getName(), 100, resolver2Timeouts.getConnectionTimeout());
    assertEquals("Unexpected read timeout " + resolver2Timeouts.getReadTimeout() + " on resolver " + resolver2.getName(), 500, resolver2Timeouts.getReadTimeout());
    final FileSystemResolver resolver3 = (FileSystemResolver) settings.getResolver("fs");
    assertNotNull("Missing resolver fs", resolver3);
    final TimeoutConstraint resolver3Timeouts = resolver3.getTimeoutConstraint();
    assertNull("No timeout was expected on resolver " + resolver3.getName(), resolver3Timeouts);
}
Also used : IBiblioResolver(org.apache.ivy.plugins.resolver.IBiblioResolver) File(java.io.File) URLResolver(org.apache.ivy.plugins.resolver.URLResolver) FileSystemResolver(org.apache.ivy.plugins.resolver.FileSystemResolver) Test(org.junit.Test) ModuleDescriptorParserRegistryTest(org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)

Example 18 with FileSystemResolver

use of org.apache.ivy.plugins.resolver.FileSystemResolver 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

FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)18 Test (org.junit.Test)14 File (java.io.File)11 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)7 ChainResolver (org.apache.ivy.plugins.resolver.ChainResolver)6 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)6 Ivy (org.apache.ivy.Ivy)5 JarFile (java.util.jar.JarFile)4 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)4 ResolveReport (org.apache.ivy.core.report.ResolveReport)4 IvySettings (org.apache.ivy.core.settings.IvySettings)3 Artifact (org.apache.ivy.core.module.descriptor.Artifact)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 DualResolver (org.apache.ivy.plugins.resolver.DualResolver)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)1