maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r349600 - in /maven/repository-manager/trunk/maven-repository-discovery/src: main/java/org/apache/maven/repository/discovery/ test/java/org/apache/maven/repository/discovery/ test/repository/javax/ test/repository/javax/sql/ test/repository...
Date Tue, 29 Nov 2005 03:11:36 GMT
Author: brett
Date: Mon Nov 28 19:11:23 2005
New Revision: 349600

URL: http://svn.apache.org/viewcvs?rev=349600&view=rev
Log:
add some more tests
PR: MRM-9

Added:
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/sql/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/sql/jdbc/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/sql/jdbc/2.0/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/maven/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/maven/test/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/maven-test-1.0-20050611.112233-1.jar
Modified:
    maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
    maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
    maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java?rev=349600&r1=349599&r2=349600&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
Mon Nov 28 19:11:23 2005
@@ -18,6 +18,7 @@
 
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -55,24 +56,18 @@
      */
     protected String[] scanForArtifactPaths( File repositoryBase, String blacklistedPatterns
)
     {
-        String[] blacklisted;
+        List allExcludes = new ArrayList();
+        allExcludes.addAll( FileUtils.getDefaultExcludesAsList() );
+        allExcludes.addAll( Arrays.asList( STANDARD_DISCOVERY_EXCLUDES ) );
+
         if ( blacklistedPatterns != null && blacklistedPatterns.length() > 0 )
         {
-            blacklisted = blacklistedPatterns.split( "," );
-        }
-        else
-        {
-            blacklisted = EMPTY_STRING_ARRAY;
+            allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( "," ) ) );
         }
 
-        String[] allExcludes = new String[STANDARD_DISCOVERY_EXCLUDES.length + blacklisted.length];
-
-        System.arraycopy( STANDARD_DISCOVERY_EXCLUDES, 0, allExcludes, 0, STANDARD_DISCOVERY_EXCLUDES.length
);
-        System.arraycopy( blacklisted, 0, allExcludes, STANDARD_DISCOVERY_EXCLUDES.length,
blacklisted.length );
-
         DirectoryScanner scanner = new DirectoryScanner();
         scanner.setBasedir( repositoryBase );
-        scanner.setExcludes( allExcludes );
+        scanner.setExcludes( (String[]) allExcludes.toArray( EMPTY_STRING_ARRAY ) );
 
         scanner.scan();
 

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java?rev=349600&r1=349599&r2=349600&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
Mon Nov 28 19:11:23 2005
@@ -18,11 +18,11 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -93,27 +93,12 @@
         pathParts.remove( 0 );
 
         // the remaining are the groupId.
-        StringBuffer groupBuffer = new StringBuffer();
-
-        boolean firstPart = true;
-        for ( Iterator it = pathParts.iterator(); it.hasNext(); )
-        {
-            String part = (String) it.next();
-
-            groupBuffer.append( part );
+        Collections.reverse( pathParts );
+        String groupId = StringUtils.join( pathParts.iterator(), "." );
 
-            if ( firstPart )
-            {
-                firstPart = false;
-            }
-            else if ( it.hasNext() )
-            {
-                groupBuffer.append( "." );
-            }
-        }
+        result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
"jar" );
 
-        result = artifactFactory.createArtifact( groupBuffer.toString(), artifactId, version,
Artifact.SCOPE_RUNTIME,
-                                                 "jar" );
+        result.setFile( new File( path ) );
 
         return result;
     }

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java?rev=349600&r1=349599&r2=349600&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
Mon Nov 28 19:11:23 2005
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.codehaus.plexus.PlexusTestCase;
 
 import java.io.File;
@@ -33,6 +35,8 @@
 {
     private ArtifactDiscoverer discoverer;
 
+    private ArtifactFactory factory;
+
     private File repositoryLocation;
 
     protected void setUp()
@@ -42,29 +46,90 @@
 
         discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, "default" );
 
+        factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
         repositoryLocation = getTestFile( "src/test/repository" );
     }
 
     public void testDefaultExcludes()
     {
         List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
-        assertNotNull( "Check artifacts returned", artifacts );
-        assertTrue( "Check no artifacts returned", artifacts.isEmpty() );
+        assertNotNull( "Check artifacts not null", artifacts );
         boolean found = false;
-        for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext(); )
+        for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() &&
!found; )
         {
             String path = (String) i.next();
 
-            if ( !path.startsWith( ".svn" ) )
-            {
-                assertEquals( "Check the excluded path", "KEYS", path );
-                if ( found )
-                {
-                    fail( "KEYS entry found twice" );
-                }
-                found = true;
-            }
+            found = path.indexOf( ".svn" ) >= 0;
         }
         assertTrue( "Check exclusion was found", found );
+
+        for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+        {
+            Artifact a = (Artifact) i.next();
+            assertFalse( "Check not .svn", a.getFile().getPath().indexOf( ".svn" ) >=
0 );
+        }
     }
+
+    public void testStandardExcludes()
+    {
+        List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
+        assertNotNull( "Check artifacts not null", artifacts );
+        boolean found = false;
+        for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() &&
!found; )
+        {
+            String path = (String) i.next();
+
+            found = path.equals( "KEYS" );
+        }
+        assertTrue( "Check exclusion was found", found );
+
+        for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+        {
+            Artifact a = (Artifact) i.next();
+            assertFalse( "Check not KEYS", a.getFile().getName().equals( "KEYS" ) );
+        }
+    }
+
+    public void testBlacklistedExclude()
+    {
+        List artifacts = discoverer.discoverArtifacts( repositoryLocation, "javax/**", false
);
+        assertNotNull( "Check artifacts not null", artifacts );
+        boolean found = false;
+        for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() &&
!found; )
+        {
+            String path = (String) i.next();
+
+            found = path.replace( '\\', '/' ).equals( "javax/sql/jdbc/2.0/jdbc-2.0.jar" );
+        }
+        assertTrue( "Check exclusion was found", found );
+
+        assertFalse( "Check jdbc not included", artifacts.contains( createArtifact( "javax.sql",
"jdbc", "2.0" ) ) );
+    }
+
+    public void testSnapshotInclusion()
+    {
+        List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
+        assertNotNull( "Check artifacts not null", artifacts );
+
+        assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql",
"jdbc", "2.0" ) ) );
+        assertTrue( "Check snapshot included",
+                    artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT"
) ) );
+    }
+
+    public void testSnapshotExclusion()
+    {
+        List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
+        assertNotNull( "Check artifacts not null", artifacts );
+
+        assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql",
"jdbc", "2.0" ) ) );
+        assertFalse( "Check snapshot included",
+                     artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT"
) ) );
+    }
+
+    private Artifact createArtifact( String groupId, String artifactId, String version )
+    {
+        return factory.createArtifact( groupId, artifactId, version, null, "jar" );
+    }
+
 }

Added: maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar?rev=349600&view=auto
==============================================================================
    (empty)

Added: maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/maven-test-1.0-20050611.112233-1.jar
URL: http://svn.apache.org/viewcvs/maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/maven-test-1.0-20050611.112233-1.jar?rev=349600&view=auto
==============================================================================
    (empty)



Mime
View raw message