maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r733063 - in /maven/components/trunk/maven-compat/src: main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
Date Fri, 09 Jan 2009 15:34:42 GMT
Author: brianf
Date: Fri Jan  9 07:34:41 2009
New Revision: 733063

URL: http://svn.apache.org/viewvc?rev=733063&view=rev
Log:
MNG-3974 - stop on first mirror pattern match

Modified:
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
    maven/components/trunk/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=733063&r1=733062&r2=733063&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Fri Jan  9 07:34:41 2009
@@ -897,9 +897,12 @@
             Set<String> keySet = mirrors.keySet();
             if ( keySet != null )
             {
-                for (String pattern : keySet) {
-                    if (matchPattern(originalRepository, pattern)) {
+                for (String pattern : keySet) 
+                {
+                    if (matchPattern(originalRepository, pattern)) 
+                    {
                         selectedMirror = mirrors.get(pattern);
+                        break;
                     }
                 }
             }

Modified: maven/components/trunk/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java?rev=733063&r1=733062&r2=733063&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
(original)
+++ maven/components/trunk/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java
Fri Jan  9 07:34:41 2009
@@ -578,6 +578,44 @@
     }
 
     /**
+     * Check that first match wins
+     */
+    public void testMirrorStopOnFirstMatch()
+    {
+        //exact matches win first
+        wagonManager.addMirror( "a2", "a,b", "http://a2" );
+        wagonManager.addMirror( "a", "a", "http://a" );
+        
+        wagonManager.addMirror( "b", "b", "http://b" );
+        wagonManager.addMirror( "c", "d,e", "http://de" );
+        wagonManager.addMirror( "c", "*", "http://wildcard" );
+        wagonManager.addMirror( "c", "e,f", "http://ef" );
+        
+    
+
+        ArtifactRepository repo = null;
+        repo = wagonManager.getMirrorRepository( getRepo( "a", "http://a.a" ) );
+        assertEquals( "http://a", repo.getUrl() );
+
+        repo = wagonManager.getMirrorRepository( getRepo( "b", "http://a.a" ) );
+        assertEquals( "http://b", repo.getUrl() );
+
+        repo = wagonManager.getMirrorRepository( getRepo( "c", "http://c.c" ) );
+        assertEquals( "http://wildcard", repo.getUrl() );
+        
+        repo = wagonManager.getMirrorRepository( getRepo( "d", "http://d" ) );
+        assertEquals( "http://de", repo.getUrl() );
+        
+        repo = wagonManager.getMirrorRepository( getRepo( "e", "http://e" ) );
+        assertEquals( "http://de", repo.getUrl() );
+        
+        repo = wagonManager.getMirrorRepository( getRepo( "f", "http://f" ) );
+        assertEquals( "http://wildcard", repo.getUrl() );
+
+    }
+
+    
+    /**
      * Check that patterns are processed correctly Valid patterns: * = everything external:*
= everything not on the
      * localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except
repo1
      */



Mime
View raw message