Search in sources :

Example 6 with IBiblioResolver

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

Aggregations

IBiblioResolver (org.apache.ivy.plugins.resolver.IBiblioResolver)6 Test (org.junit.Test)5 File (java.io.File)3 Ivy (org.apache.ivy.Ivy)3 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)3 IvySettings (org.apache.ivy.core.settings.IvySettings)2 ModuleDescriptorParserRegistryTest (org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistryTest)2 ChainResolver (org.apache.ivy.plugins.resolver.ChainResolver)2 HashMap (java.util.HashMap)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 FileSystemResolver (org.apache.ivy.plugins.resolver.FileSystemResolver)1 URLResolver (org.apache.ivy.plugins.resolver.URLResolver)1 Before (org.junit.Before)1