ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1087396 - in /ant/ivy/core/trunk: ./ doc/ doc/resolver/ src/java/org/apache/ivy/core/settings/ src/java/org/apache/ivy/plugins/repository/url/ src/java/org/apache/ivy/plugins/resolver/ test/java/org/apache/ivy/plugins/resolver/
Date Thu, 31 Mar 2011 18:19:25 GMT
Author: hibou
Date: Thu Mar 31 18:19:24 2011
New Revision: 1087396

URL: http://svn.apache.org/viewvc?rev=1087396&view=rev
Log:
Add a mirror capable url resolver. Far from perfect but a nice first working version.

Added:
    ant/ivy/core/trunk/doc/resolver/mirrored.html   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
  (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java 
 (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
  (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
  (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt   (with
props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt 
 (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt   (with
props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/doc/toc.json
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1087396&r1=1087395&r2=1087396&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Mar 31 18:19:24 2011
@@ -117,6 +117,7 @@ for detailed view of each issue, please 
 - NEW: New Ant datatype ivy:resources, an Ant resource collection like ivy:cachepath or ivy:cachefileset
(IVY-334)
 - NEW: ivy:resolve and post resole task can now have inlined dependencies declaration.
 - NEW: Import Bushel into Ivy core (IVY-1241)
+- NEW: An new resolver 'mirroredurl' which can handle a list of mirrored URL repositories
 
 - IMPROVEMENT: ivy:makepom child element dependency should support the type and classifier
attributes (IVY-1262)
 - IMPROVEMENT: ivy:retrieve can now create a path or fileset containing the retrieved artifacts
(IVY-1235)

Added: ant/ivy/core/trunk/doc/resolver/mirrored.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/resolver/mirrored.html?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/doc/resolver/mirrored.html (added)
+++ ant/ivy/core/trunk/doc/resolver/mirrored.html Thu Mar 31 18:19:24 2011
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<html>
+<head>
+	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+	<script type="text/javascript">var xookiConfig = {level: 0};</script>	
+	<script type="text/javascript" src="xooki/xooki.js"></script>
+</head>
+<body>
+	<textarea id="xooki-source">
+<table class="resolver">
+<tr><td class="title">Tag</td><td class="value">mirroredurl</td></tr>
+<tr><td class="title">Handle latest</td><td class="value">yes with
http urls (and apache server) and with file urls, no with other urls</td></tr>
+<tr><td class="title">Handle publish</td><td class="value">no</td></tr>
+</table>
+
+<span class="since">since 2.3</span>
+
+<br/>
+<span class="tagdoc" id="ivysettings.resolvers.mirroredurl">This resolver can resolve
dependencies against sevrail mirror of the same repository. From a list of mirror urls, it
will iteratively try to resolve the dependencies against each one.
+
+<h1>Attributes</h1>
+This resolver shares the <a href="../settings/resolvers.html#common">common attributes</a>
of standard resolvers.
+<table class="ivy-attributes">
+<thead>
+    <tr><th class="ivy-att">Attribute</th><th class="ivy-att-desc">Description</th><th
class="ivy-att-req">Required</th></tr>
+</thead>
+<tbody>
+    <tr><td>m2compatible</td><td>True if this resolver should be
maven2 compatible, false otherwise</td>
+        <td>No, defaults to false</td></tr>
+    <tr><td>mirrorListUrl</td><td>The url where to retrive the list
of mirror urls.</td>
+        <td>Yes</td></tr>
+</tbody>
+</table>
+<h1>Child elements</h1>
+<table class="ivy-children">
+<thead>
+    <tr><th class="ivy-chld">Element</th><th class="ivy-chld-desc">Description</th><th
class="ivy-chld-card">Cardinality</th></tr>
+</thead>
+<tbody>
+    <tr><td>ivy</td><td>defines a pattern for ivy files, using the
pattern attribute</td>
+        <td>0..n</td></tr>
+    <tr><td>artifact</td><td>defines a pattern for artifacts, using
the pattern attribute</td>
+        <td>1..n</td></tr>
+</tbody>
+</table>
+
+<h1>Example</h1>
+
+Having the file mavenrepolist.txt content:
+<code>
+http://repo1.maven.org/maven2/
+http://repo2.maven.org/maven2/
+</code>
+And the piece of settings:
+<code type="xml">
+<mirroredurl name="mirrored-maven" m2compatible="true" mirrorListUrl="file:///Users/me/dev/repo/mavenrepolist.txt">
+      <artifact pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
/>
+</mirroredurl>
+</code>
+It will resolve first on the repo1 and if failing it will fall back on repo2.
+
+<hr />
+
+The mirror list can be retrieved from a geo-location aware url:
+<code type="xml">
+<mirroredurl name="mirrored-asf" mirrorListUrl="http://www.apache.org/dyn/closer.cgi">
+  <ivy pattern="repo/[organisation]/[module]/[revision]/ivy.xml" />
+  <artifact pattern="repo/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
/>
+</mirroredurl>
+</code>
+</textarea>
+<script type="text/javascript">xooki.postProcess();</script>
+</body>
+</html>

Propchange: ant/ivy/core/trunk/doc/resolver/mirrored.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/doc/resolver/mirrored.html
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/doc/resolver/mirrored.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Modified: ant/ivy/core/trunk/doc/toc.json
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/toc.json?rev=1087396&r1=1087395&r2=1087396&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/toc.json (original)
+++ ant/ivy/core/trunk/doc/toc.json Thu Mar 31 18:19:24 2011
@@ -370,6 +370,13 @@
                                 "children": [
 
                                   ]
+                              },
+                              {
+                                "id":"resolver/mirrored",
+                                "title":"Mirrored Resolver",
+                                "children": [
+
+                                  ]
                               }
                             ]
                         },

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties?rev=1087396&r1=1087395&r2=1087396&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties Thu Mar 31
18:19:24 2011
@@ -29,6 +29,7 @@ vfs         = org.apache.ivy.plugins.res
 cache		= org.apache.ivy.plugins.resolver.CacheResolver
 packager	= org.apache.ivy.plugins.resolver.packager.PackagerResolver
 obr         = org.apache.ivy.osgi.obr.OBRResolver
+mirroredurl = org.apache.ivy.plugins.resolver.MirroredURLResolver
 
 latest-revision = org.apache.ivy.plugins.latest.LatestRevisionStrategy
 latest-lexico   = org.apache.ivy.plugins.latest.LatestLexicographicStrategy

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
(added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
Thu Mar 31 18:19:24 2011
@@ -0,0 +1,114 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.plugins.repository.url;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivy.plugins.repository.AbstractRepository;
+import org.apache.ivy.plugins.repository.BasicResource;
+import org.apache.ivy.plugins.repository.Repository;
+import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.util.Message;
+
+public class ChainedRepository extends AbstractRepository {
+
+    private List/* Repository */repositories;
+
+    public void setRepositories(List/* Repository */repositories) {
+        this.repositories = repositories;
+    }
+
+    public Resource getResource(String source) throws IOException {
+        Iterator it = repositories.iterator();
+        while (it.hasNext()) {
+            Repository repository = (Repository) it.next();
+            logTry(repository);
+            try {
+                Resource r = repository.getResource(source);
+                if (r != null && r.exists()) {
+                    logSuccess(repository);
+                    return r;
+                }
+            } catch (Exception e) {
+                logFailed(repository);
+            }
+        }
+        // resource that basically doesn't exists
+        return new BasicResource(source, false, 0, 0, true);
+    }
+
+    public void get(String source, File destination) throws IOException {
+        Iterator it = repositories.iterator();
+        while (it.hasNext()) {
+            Repository repository = (Repository) it.next();
+            logTry(repository);
+            boolean ok = false;
+            try {
+                repository.get(source, destination);
+                ok = true;
+            } catch (Exception e) {
+                logFailed(repository);
+            }
+            if (ok) {
+                logSuccess(repository);
+                return;
+            }
+        }
+        throw newIOEFail("copy " + source + " into " + destination);
+    }
+
+    public List list(String parent) throws IOException {
+        Iterator it = repositories.iterator();
+        while (it.hasNext()) {
+            Repository repository = (Repository) it.next();
+            logTry(repository);
+            try {
+                List list = repository.list(parent);
+                if (list != null) {
+                    logSuccess(repository);
+                    return list;
+                }
+            } catch (Exception e) {
+                logFailed(repository);
+            }
+        }
+        throw newIOEFail("list contents in " + parent);
+    }
+
+    private void logTry(Repository repository) {
+        Message.debug("Mirrored repository " + getName() + ": trying " + repository.getName());
+    }
+
+    private void logFailed(Repository repository) {
+        Message.warn("Mirrored repository " + getName() + ": " + repository
+                + " is not available. Trying the next one in the mirror list...");
+    }
+
+    private void logSuccess(Repository repository) {
+        Message.debug("Mirrored repository " + getName() + ": success with " + repository.getName());
+    }
+
+    private IOException newIOEFail(String action) {
+        return new IOException("Mirrored repository " + getName() + ": fail to " + action
+                + " with every listed mirror");
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java Thu
Mar 31 18:19:24 2011
@@ -0,0 +1,139 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.plugins.resolver;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.CacheDownloadOptions;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.osgi.repo.RelativeURLRepository;
+import org.apache.ivy.plugins.repository.ArtifactResourceResolver;
+import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.ResourceDownloader;
+import org.apache.ivy.plugins.repository.url.ChainedRepository;
+import org.apache.ivy.plugins.repository.url.URLResource;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
+import org.apache.ivy.util.FileUtil;
+import org.apache.ivy.util.Message;
+
+public class MirroredURLResolver extends RepositoryResolver {
+
+    private URL mirrorListUrl;
+
+    public MirroredURLResolver() {
+        setRepository(new ChainedRepository());
+    }
+
+    public void setMirrorListUrl(URL mirrorListUrl) {
+        this.mirrorListUrl = mirrorListUrl;
+    }
+
+    private void setupMirrors() {
+        File mirrorListFile = downloadMirrorList();
+        List mirrorBaseUrls;
+        try {
+            mirrorBaseUrls = readMirrorList(mirrorListFile);
+        } catch (IOException e) {
+            throw new IllegalStateException("The mirror list could not be read from "
+                    + mirrorListUrl + " (" + e.getMessage() + ")");
+        }
+        List/* <Repository> */repositories = new ArrayList();
+        Iterator it = mirrorBaseUrls.iterator();
+        while (it.hasNext()) {
+            String baseUrl = (String) it.next();
+            URL url = null;
+            try {
+                url = new URL(baseUrl);
+            } catch (MalformedURLException e) {
+                Message.warn("In the mirror list from " + mirrorListUrl
+                        + ", an incorrect url has been found and will then not be used: "
+ baseUrl);
+            }
+            if (url != null) {
+                RelativeURLRepository repo = new RelativeURLRepository(url);
+                repositories.add(repo);
+            }
+        }
+        ((ChainedRepository) getRepository()).setRepositories(repositories);
+    }
+
+    private File downloadMirrorList() {
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("_mirror_list_cache_", getName(),
+            Ivy.getWorkingRevision());
+        Artifact artifact = new DefaultArtifact(mrid, null, "mirrorlist", "text", "txt");
+        CacheDownloadOptions options = new CacheDownloadOptions();
+        ArtifactDownloadReport report = getRepositoryCacheManager().download(artifact,
+            new ArtifactResourceResolver() {
+                public ResolvedResource resolve(Artifact artifact) {
+                    return new ResolvedResource(new URLResource(mirrorListUrl), Ivy
+                            .getWorkingRevision());
+                }
+            }, new ResourceDownloader() {
+                public void download(Artifact artifact, Resource resource, File dest)
+                        throws IOException {
+                    if (dest.exists()) {
+                        dest.delete();
+                    }
+                    File part = new File(dest.getAbsolutePath() + ".part");
+                    FileUtil.copy(mirrorListUrl, part, null);
+                    if (!part.renameTo(dest)) {
+                        throw new IOException("impossible to move part file to definitive
one: "
+                                + part + " -> " + dest);
+                    }
+                }
+            }, options);
+        return report.getLocalFile();
+    }
+
+    private List/* <String> */readMirrorList(File mirrorListFile) throws IOException
{
+        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(
+                mirrorListFile)));
+        List/* <String> */list = new ArrayList();
+        try {
+            String line = in.readLine();
+            while (line != null) {
+                list.add(line);
+                line = in.readLine();
+            }
+        } finally {
+            in.close();
+        }
+        return list;
+    }
+
+    public String getTypeName() {
+        return "mirroredurl";
+    }
+
+    public void validate() {
+        super.validate();
+        setupMirrors();
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
(added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
Thu Mar 31 18:19:24 2011
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.plugins.resolver;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.resolve.ResolveData;
+import org.apache.ivy.core.resolve.ResolveEngine;
+import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.core.settings.XmlSettingsParser;
+import org.apache.ivy.core.sort.SortEngine;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Delete;
+
+public class MirroredURLResolverTest extends TestCase {
+
+    private IvySettings settings;
+
+    private ResolveEngine engine;
+
+    private ResolveData data;
+
+    private File cache;
+
+    protected void setUp() throws Exception {
+        settings = new IvySettings();
+        engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
+        cache = new File("build/cache");
+        data = new ResolveData(engine, new ResolveOptions());
+        cache.mkdirs();
+        settings.setDefaultCache(cache);
+        settings.setVariable("test.mirroredurl.mirrorlist-solo.url",
+            this.getClass().getResource("mirrorlist-solo.txt").toExternalForm());
+        settings.setVariable("test.mirroredurl.mirrorlist-failover.url",
+            this.getClass().getResource("mirrorlist-failover.txt").toExternalForm());
+        settings.setVariable("test.mirroredurl.mirrorlist-fail.url",
+            this.getClass().getResource("mirrorlist-fail.txt").toExternalForm());
+        new XmlSettingsParser(settings).parse(MirroredURLResolverTest.class
+                .getResource("mirror-resolver-settings.xml"));
+    }
+
+    protected void tearDown() throws Exception {
+        Delete del = new Delete();
+        del.setProject(new Project());
+        del.setDir(cache);
+        del.execute();
+    }
+
+    public void testSolo() throws Exception {
+        DependencyResolver resolver = settings.getResolver("solo");
+        assertNotNull(resolver);
+        assertTrue(resolver instanceof MirroredURLResolver);
+        MirroredURLResolver mirrored = (MirroredURLResolver) resolver;
+
+        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
+                ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
+        ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
+        assertNotNull(rmr);
+    }
+
+    public void testFailover() throws Exception {
+        DependencyResolver resolver = settings.getResolver("failover");
+        assertNotNull(resolver);
+        assertTrue(resolver instanceof MirroredURLResolver);
+        MirroredURLResolver mirrored = (MirroredURLResolver) resolver;
+
+        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
+                ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
+        ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
+        assertNotNull(rmr);
+    }
+
+    public void testFail() throws Exception {
+        DependencyResolver resolver = settings.getResolver("fail");
+        assertNotNull(resolver);
+        assertTrue(resolver instanceof MirroredURLResolver);
+        MirroredURLResolver mirrored = (MirroredURLResolver) resolver;
+
+        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
+                ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
+        ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
+        assertNull(rmr);
+    }
+
+}

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MirroredURLResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
(added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
Thu Mar 31 18:19:24 2011
@@ -0,0 +1,31 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivysettings>
+  <resolvers>
+    <mirroredurl name="solo" m2compatible="true" mirrorListUrl="${test.mirroredurl.mirrorlist-solo.url}">
+      <artifact pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
/>
+    </mirroredurl>
+    <mirroredurl name="failover" m2compatible="true" mirrorListUrl="${test.mirroredurl.mirrorlist-failover.url}">
+      <artifact pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
/>
+    </mirroredurl>
+    <mirroredurl name="fail" m2compatible="true" mirrorListUrl="${test.mirroredurl.mirrorlist-fail.url}">
+      <artifact pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
/>
+    </mirroredurl>
+  </resolvers>
+</ivysettings>

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirror-resolver-settings.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt Thu Mar
31 18:19:24 2011
@@ -0,0 +1,2 @@
+http://repo1.maven.org/_this_should_not_exist/
+http://repo1.maven.org/_this_should_not_exist_either/
\ No newline at end of file

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-fail.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt Thu
Mar 31 18:19:24 2011
@@ -0,0 +1,2 @@
+http://repo1.maven.org/_this_should_not_exist/
+http://repo1.maven.org/maven2/
\ No newline at end of file

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-failover.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt?rev=1087396&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt Thu Mar
31 18:19:24 2011
@@ -0,0 +1 @@
+http://repo1.maven.org/maven2/
\ No newline at end of file

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/mirrorlist-solo.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message