maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r452307 - in /maven/plugins/trunk/maven-dependency-plugin: ./ src/main/java/org/apache/maven/plugin/dependency/ src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/ src/main/java/org/apache/maven/plugin/dependency/resolvers/ ...
Date Tue, 03 Oct 2006 04:03:07 GMT
Author: brianf
Date: Mon Oct  2 21:03:06 2006
New Revision: 452307

URL: http://svn.apache.org/viewvc?view=rev&rev=452307
Log:
more tests

Added:
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestFilterArtifacts.java
Modified:
    maven/plugins/trunk/maven-dependency-plugin/pom.xml
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/FilterArtifacts.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/site/fml/faq.fml
    maven/plugins/trunk/maven-dependency-plugin/src/site/site.xml
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTransitivityFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-dependencies-test/plugin-config.xml

Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Mon Oct  2 21:03:06 2006
@@ -10,7 +10,7 @@
     <artifactId>maven-dependency-plugin</artifactId>
     <packaging>maven-plugin</packaging>
     <name>Dependency Maven Plugin</name>
-    <version>2.0-ALPHA-1</version>
+    <version>2.0-ALPHA-1-SNAPSHOT</version>
     <prerequisites>
         <maven>2.0.3</maven>
     </prerequisites>

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
Mon Oct  2 21:03:06 2006
@@ -144,7 +144,7 @@
         Set artifacts = project.getArtifacts();
 
         //perform filtering
-        artifacts = filter.filter( artifacts, log );
+        artifacts = filter.filter( artifacts, getLog() );
 
         //transform artifacts if classifier is set
         DependencyStatusSets status = null;
@@ -172,7 +172,7 @@
         if ( StringUtils.isNotEmpty( classifier ) )
         {
             ArtifactTranslator translator = new ClassifierTypeTranslator( this.classifier,
this.type, this.factory );
-            artifacts = translator.translate( artifacts, log );
+            artifacts = translator.translate( artifacts, getLog() );
 
             status = filterMarkedDependencies( artifacts );
 
@@ -182,7 +182,7 @@
             //resolve the rest of the artifacts
             ArtifactsResolver artifactsResolver = new DefaultArtifactsResolver( this.resolver,
this.local,
                                                                                 this.remoteRepos,
stopOnFailure );
-            resolvedArtifacts = artifactsResolver.resolve( artifacts, log );
+            resolvedArtifacts = artifactsResolver.resolve( artifacts, getLog() );
 
             //calculate the artifacts not resolved.
             unResolvedArtifacts.addAll( artifacts );
@@ -205,7 +205,7 @@
         filter.addFilter( new MarkerFileFilter( this.overWriteReleases, this.overWriteSnapshots,
this.overWriteIfNewer,
                                                 this.markersDirectory ) );
 
-        Set unMarkedArtifacts = filter.filter( artifacts, log );
+        Set unMarkedArtifacts = filter.filter( artifacts, getLog() );
 
         //calculate the skipped artifacts
         Set skippedArtifacts = new HashSet();

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
Mon Oct  2 21:03:06 2006
@@ -93,25 +93,22 @@
      */
     protected boolean silent;
     
-    protected Log log;
-
-    public AbstractDependencyMojo ()
-    {
-      if (silent)
-      {
-          log = new SilentLog();
-      }
-      else
-      {
-          log = super.getLog();
-      }
-    }
+    private Log log;
 
     /**
      * @return Returns the log.
      */
     public Log getLog()
     {
+        if (silent)
+        {
+            log = new SilentLog();
+        }
+        else
+        {
+            log = super.getLog();
+        }
+        
         return this.log;
     }
 

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/UnpackMojo.java
Mon Oct  2 21:03:06 2006
@@ -30,7 +30,6 @@
  * Goal that retrieves a list of artifacts from the repository and unpacks them in a defined
location.
  *
  * @goal unpack
- *
  * @phase process-sources
  * @author brianf
  */

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolveDependenciesMojo.java
Mon Oct  2 21:03:06 2006
@@ -50,7 +50,7 @@
         //get sets of dependencies
         results = this.getDependencySets();
         
-        results.logStatus(log, outputArtifactFilename);
+        results.logStatus(getLog(), outputArtifactFilename);
     }
 
     /**

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/FilterArtifacts.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/FilterArtifacts.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/FilterArtifacts.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/FilterArtifacts.java
Mon Oct  2 21:03:06 2006
@@ -88,14 +88,19 @@
       return artifacts;
   }
   
-  private void log(Set artifacts, Log log)
-  {
-      log.debug("Artifacts:");
-      Iterator iter = artifacts.iterator();
-      while (iter.hasNext())
-      {
-          Artifact artifact = (Artifact) iter.next();
-          log.debug(""+artifact);
-      }
-  }
+/**
+ * @return Returns the filters.
+ */
+public ArrayList getFilters()
+{
+    return this.filters;
+}
+
+/**
+ * @param filters The filters to set.
+ */
+public void setFilters( ArrayList filters )
+{
+    this.filters = filters;
+}
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ScopeFilter.java
Mon Oct  2 21:03:06 2006
@@ -40,42 +40,71 @@
     }
 
     /**
-     * This function determines if filtering needs to be performed. Excludes are ignored
if Includes are used.
+     * This function determines if filtering needs to be performed. Excludes are
+     * ignored if Includes are used.
+     * 
      * @param dependencies
-     *          the set of dependencies to filter.
+     *            the set of dependencies to filter.
      * 
      * @return a Set of filtered dependencies.
-     * @throws MojoExecutionException 
+     * @throws MojoExecutionException
      */
-    public Set filter( Set artifacts, Log log ) throws MojoExecutionException
+    public Set filter( Set artifacts, Log log )
+        throws MojoExecutionException
     {
         Set results = artifacts;
 
         if ( StringUtils.isNotEmpty( includeScope ) )
         {
+            if (!Artifact.SCOPE_COMPILE.equals(includeScope)&&
+                !Artifact.SCOPE_TEST.equals(includeScope)&&
+                !Artifact.SCOPE_PROVIDED.equals(includeScope)&&
+                !Artifact.SCOPE_RUNTIME.equals(includeScope)&&
+                !Artifact.SCOPE_SYSTEM.equals(includeScope))
+            {
+                throw new MojoExecutionException("Invalid Scope in includeScope: "+ includeScope);
+            }
+            
             results = new HashSet();
-            ScopeArtifactFilter saf = new ScopeArtifactFilter( includeScope );
 
-            Iterator iter = artifacts.iterator();
-            while ( iter.hasNext() )
+            if ( Artifact.SCOPE_PROVIDED.equals( includeScope ) || Artifact.SCOPE_SYSTEM.equals(
includeScope ) )
+            {
+                results = includeSingleScope( artifacts, includeScope );
+            }
+            else
             {
-                Artifact artifact = (Artifact) iter.next();
-                if ( saf.include( artifact ) )
+                ScopeArtifactFilter saf = new ScopeArtifactFilter( includeScope );
+
+                Iterator iter = artifacts.iterator();
+                while ( iter.hasNext() )
                 {
-                    results.add( artifact );
+                    Artifact artifact = (Artifact) iter.next();
+                    if ( saf.include( artifact ) )
+                    {
+                        results.add( artifact );
+                    }
                 }
             }
         }
         else if ( StringUtils.isNotEmpty( excludeScope ) )
         {
+            if (!Artifact.SCOPE_COMPILE.equals(excludeScope)&&
+                !Artifact.SCOPE_TEST.equals(excludeScope)&&
+                !Artifact.SCOPE_PROVIDED.equals(excludeScope)&&
+                !Artifact.SCOPE_RUNTIME.equals(excludeScope)&&
+                !Artifact.SCOPE_SYSTEM.equals(excludeScope))
+            {
+                throw new MojoExecutionException("Invalid Scope in excludeScope: "+ excludeScope);
+            }
             results = new HashSet();
-            //plexus ScopeArtifactFilter doesn't handle the provided scope so we
-            //need special handling for it.
-            if ( Artifact.SCOPE_TEST.equals(excludeScope))
+            // plexus ScopeArtifactFilter doesn't handle the provided scope so
+            // we
+            // need special handling for it.
+            if ( Artifact.SCOPE_TEST.equals( excludeScope ) )
             {
-                throw new MojoExecutionException(" Can't exclude Test scope, this will exclude
everything.");
+                throw new MojoExecutionException( " Can't exclude Test scope, this will exclude
everything." );
             }
-            else if ( !Artifact.SCOPE_PROVIDED.equals( excludeScope ) )
+            else if ( !Artifact.SCOPE_PROVIDED.equals( excludeScope ) && !Artifact.SCOPE_SYSTEM.equals(
excludeScope ) )
             {
                 ScopeArtifactFilter saf = new ScopeArtifactFilter( excludeScope );
 
@@ -91,19 +120,40 @@
             }
             else
             {
-                Iterator iter = artifacts.iterator();
-                while ( iter.hasNext() )
-                {
-                    Artifact artifact = (Artifact) iter.next();
-                    if ( !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
-                    {
-                        results.add( artifact );
-                    }
-                }
+                excludeSingleScope( artifacts, excludeScope );
             }
+        }
 
+        return results;
+    }
+
+    private Set includeSingleScope( Set artifacts, String scope )
+    {
+        HashSet results = new HashSet();
+        Iterator iter = artifacts.iterator();
+        while ( iter.hasNext() )
+        {
+            Artifact artifact = (Artifact) iter.next();
+            if ( scope.equals( artifact.getScope() ) )
+            {
+                results.add( artifact );
+            }
         }
+        return results;
+    }
 
+    private Set excludeSingleScope( Set artifacts, String scope )
+    {
+        HashSet results = new HashSet();
+        Iterator iter = artifacts.iterator();
+        while ( iter.hasNext() )
+        {
+            Artifact artifact = (Artifact) iter.next();
+            if ( !scope.equals( artifact.getScope() ) )
+            {
+                results.add( artifact );
+            }
+        }
         return results;
     }
 
@@ -116,7 +166,8 @@
     }
 
     /**
-     * @param includeScope The includeScope to set.
+     * @param includeScope
+     *            The includeScope to set.
      */
     public void setIncludeScope( String scope )
     {
@@ -132,7 +183,8 @@
     }
 
     /**
-     * @param excludeScope The excludeScope to set.
+     * @param excludeScope
+     *            The excludeScope to set.
      */
     public void setExcludeScope( String excludeScope )
     {

Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/fml/faq.fml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/fml/faq.fml?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/site/fml/faq.fml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/site/fml/faq.fml Mon Oct  2 21:03:06 2006
@@ -7,7 +7,7 @@
         <p>
             Actually, they are the same, it's just that it was moved and renamed. The dependency-maven-plugin
             is hosted at Mojo while maven-dependency-plugin is hosted at Apache. The recommended
-            plugin to use is the maven-dependency-plugin.
+            plugin to use is the maven-dependency-plugin. 
         </p>
      </answer>
    </faq>

Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/site.xml?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/site/site.xml Mon Oct  2 21:03:06 2006
@@ -20,7 +20,7 @@
 
 <project name="Maven Dependency Plugin">
   <bannerLeft>
-    <name>Maven Rar Plugin</name>
+    <name>Maven Dependency Plugin</name>
     <src>http://maven.apache.org/images/apache-maven-project.png</src>
     <href>http://maven.apache.org/</href>
   </bannerLeft>

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
Mon Oct  2 21:03:06 2006
@@ -28,6 +28,8 @@
         File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"
);
         CopyDependenciesMojo mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies",
testPom );
         mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
+        // mojo.silent = true;
+
         assertNotNull( mojo );
         assertNotNull( mojo.project );
         MavenProject project = mojo.project;
@@ -53,7 +55,6 @@
     {
         CopyDependenciesMojo mojo = getNewMojo();
         mojo.execute();
-
         Iterator iter = mojo.project.getArtifacts().iterator();
         while ( iter.hasNext() )
         {
@@ -247,6 +248,7 @@
         mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
         mojo.project.setDependencyArtifacts( new HashSet() );
         mojo.includeScope = "test";
+
         mojo.execute();
         ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
 
@@ -289,17 +291,15 @@
         mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
         mojo.project.setDependencyArtifacts( new HashSet() );
         mojo.includeScope = "provided";
+        
         mojo.execute();
-        ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
-
         Iterator iter = mojo.project.getArtifacts().iterator();
         while ( iter.hasNext() )
         {
             Artifact artifact = (Artifact) iter.next();
             String fileName = DependencyUtil.getFormattedFileName( artifact, false );
             File file = new File( mojo.outputDirectory, fileName );
-
-            assertEquals( saf.include( artifact ), file.exists() );
+            assertEquals( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), file.exists()
);
         }
     }
 
@@ -310,8 +310,8 @@
         mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
         mojo.project.setDependencyArtifacts( new HashSet() );
         mojo.includeScope = "system";
+        
         mojo.execute();
-        ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.includeScope );
 
         Iterator iter = mojo.project.getArtifacts().iterator();
         while ( iter.hasNext() )
@@ -320,7 +320,7 @@
             String fileName = DependencyUtil.getFormattedFileName( artifact, false );
             File file = new File( mojo.outputDirectory, fileName );
 
-            assertEquals( saf.include( artifact ), file.exists() );
+            assertEquals( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ), file.exists()
);
         }
     }
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestResolveMojo.java
Mon Oct  2 21:03:06 2006
@@ -30,7 +30,7 @@
     {
         File testPom = new File( getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml"
);
         ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo( "resolve", testPom
);
-
+        mojo.silent = false;
         assertNotNull( mojo );
         assertNotNull(mojo.project);
         MavenProject project = mojo.project;

Added: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestFilterArtifacts.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestFilterArtifacts.java?view=auto&rev=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestFilterArtifacts.java
(added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestFilterArtifacts.java
Mon Oct  2 21:03:06 2006
@@ -0,0 +1,79 @@
+/*
+ *  Copyright 2005-2006 Brian Fox (brianefox@gmail.com)
+ *
+ * Licensed 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.maven.plugin.dependency.utils.filters;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.plugin.dependency.utils.SilentLog;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * @author brianf
+ *
+ */
+public class TestFilterArtifacts
+    extends TestCase
+{
+    Log log = new SilentLog();
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+    }
+    
+    public void testArtifactFilter()
+    {
+        Set a = new HashSet();
+        FilterArtifacts fa = new FilterArtifacts();
+        ArtifactsFilter scope = new ScopeFilter("compile","system");
+        ArtifactsFilter type = new TypeFilter("jar","war");
+        ArtifactsFilter trans = new TransitivityFilter(a,true);
+        
+        assertEquals(0,fa.getFilters().size());
+        fa.addFilter(scope);
+        assertEquals(1,fa.getFilters().size());
+        fa.addFilter(type);
+        assertEquals(2,fa.getFilters().size());
+        assertTrue(fa.getFilters().get(0) instanceof ScopeFilter );
+        assertTrue(fa.getFilters().get(1) instanceof TypeFilter );
+        fa.addFilter(1,trans);
+        assertEquals(3,fa.getFilters().size());
+        assertTrue(fa.getFilters().get(0) instanceof ScopeFilter );
+        assertTrue(fa.getFilters().get(1) instanceof TransitivityFilter );
+        assertTrue(fa.getFilters().get(2) instanceof TypeFilter );
+        
+        ArrayList list = new ArrayList();
+        list.addAll(fa.getFilters());
+        
+        fa.clearFilters();
+        assertEquals(0,fa.getFilters().size());
+        
+        fa.setFilters(list);
+        assertEquals(3,fa.getFilters().size());
+        assertTrue(fa.getFilters().get(0) instanceof ScopeFilter );
+        assertTrue(fa.getFilters().get(1) instanceof TransitivityFilter );
+        assertTrue(fa.getFilters().get(2) instanceof TypeFilter );
+        
+    }
+    
+  }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestMarkerFileFilter.java
Mon Oct  2 21:03:06 2006
@@ -144,5 +144,25 @@
         assertFalse(outputFolder.exists());    
     }
     
+    public void testGettersSetters()
+    {
+        MarkerFileFilter filter = new MarkerFileFilter(true,false,true,outputFolder);
+        assertEquals(true,filter.isOverWriteReleases());
+        assertEquals(false,filter.isOverWriteSnapshots());
+        assertEquals(true,filter.isOverWriteIfNewer());
+        assertEquals(outputFolder,filter.getMarkerFileDirectory());
+        
+        filter.setOverWriteReleases(false);
+        filter.setOverWriteSnapshots(true);
+        filter.setOverWriteIfNewer(false);
+        File file = new File(outputFolder,"child");
+        filter.setMarkerFileDirectory(file);
+        assertEquals(false,filter.isOverWriteReleases());
+        assertEquals(true,filter.isOverWriteSnapshots());
+        assertEquals(false,filter.isOverWriteIfNewer());
+        assertEquals(file,filter.getMarkerFileDirectory());
+        
+        
+    }
     
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestScopeFilter.java
Mon Oct  2 21:03:06 2006
@@ -19,23 +19,20 @@
 package org.apache.maven.plugin.dependency.utils.filters;
 
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import junit.framework.TestCase;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DefaultArtifact;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.dependency.utils.ArtifactStubFactory;
 import org.apache.maven.plugin.dependency.utils.SilentLog;
+import org.apache.maven.plugin.logging.Log;
 
 /**
  * @author brianf
- *
+ * 
  */
 public class TestScopeFilter
     extends TestCase
@@ -49,123 +46,166 @@
     {
         super.setUp();
 
-        ArtifactStubFactory factory = new ArtifactStubFactory (null,false);
+        ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
         artifacts = factory.getScopedArtifacts();
     }
 
-    public void testScopeFilter()
+    public void testScopeCompile()
+        throws MojoExecutionException
     {
         ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_COMPILE, null );
         Set result;
-        try
-        {
-            result = filter.filter( artifacts, log );
-            assertEquals( 3, result.size() );
-        }
-        catch ( MojoExecutionException e )
-        {
-            assertTrue( true );
-        }
+
+        result = filter.filter( artifacts, log );
+        assertEquals( 3, result.size() );
+
     }
 
-    public void testScopeFilter2()
+    public void testScopeRuntime()
+        throws MojoExecutionException
     {
         ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_RUNTIME, null );
         Set result;
-        try
-        {
-            result = filter.filter( artifacts, log );
-            assertEquals( 2, result.size() );
-        }
-        catch ( MojoExecutionException e )
-        {
-            assertTrue( false );
-        }
+        result = filter.filter( artifacts, log );
+        assertEquals( 2, result.size() );
+
     }
 
-    public void testScopeFilter3()
+    public void testScopeTest()
+        throws MojoExecutionException
     {
-        try
-        {
-            ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_TEST, null );
-            Set result = filter.filter( artifacts, log );
-            assertEquals( 5, result.size() );
-        }
-        catch ( MojoExecutionException e )
-        {
-            assertTrue( false );
-        }
+        ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_TEST, null );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 5, result.size() );
     }
 
-    public void testScopeFilterNull()
+    public void testScopeProvided()
+        throws MojoExecutionException
     {
-        try
+
+        ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_PROVIDED, null );
+        Set result = filter.filter( artifacts, log );
+        Iterator iter = result.iterator();
+        assertTrue( result.size() > 0 );
+        while ( iter.hasNext() )
         {
-            ScopeFilter filter = new ScopeFilter( null, null );
-            Set result = filter.filter( artifacts, log );
-            assertEquals( 5, result.size() );
+            Artifact artifact = (Artifact) iter.next();
+            assertEquals( Artifact.SCOPE_PROVIDED, artifact.getScope() );
         }
-        catch ( MojoExecutionException e )
+    }
+
+    public void testScopeSystem()
+        throws MojoExecutionException
+    {
+
+        ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_SYSTEM, null );
+        Set result = filter.filter( artifacts, log );
+        Iterator iter = result.iterator();
+        assertTrue( result.size() > 0 );
+        while ( iter.hasNext() )
         {
-            assertTrue( false );
+            Artifact artifact = (Artifact) iter.next();
+            assertEquals( Artifact.SCOPE_SYSTEM, artifact.getScope() );
         }
+    }
 
+    public void testScopeFilterNull()
+        throws MojoExecutionException
+    {
+        ScopeFilter filter = new ScopeFilter( null, null );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 5, result.size() );
     }
 
     public void testScopeFilterEmpty()
+        throws MojoExecutionException
     {
-        try
-        {
-            ScopeFilter filter = new ScopeFilter( "", "" );
-            Set result = filter.filter( artifacts, log );
-            assertEquals( 5, result.size() );
-        }
-        catch ( MojoExecutionException e )
-        {
-            assertTrue( false );
-        }
+        ScopeFilter filter = new ScopeFilter( "", "" );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 5, result.size() );
     }
 
     public void testExcludeProvided()
+        throws MojoExecutionException
     {
-        try
+        ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_PROVIDED );
+        Set result = filter.filter( artifacts, log );
+        Iterator iter = result.iterator();
+        while ( iter.hasNext() )
         {
-            ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_PROVIDED );
-            Set result = filter.filter( artifacts, log );
-            assertEquals( 4, result.size() );
+            Artifact artifact = (Artifact) iter.next();
+            assertFalse( Artifact.SCOPE_PROVIDED.equalsIgnoreCase( artifact.getScope() )
);
         }
-        catch ( MojoExecutionException e )
+    }
+
+    public void testExcludeSystem()
+        throws MojoExecutionException
+    {
+        ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_SYSTEM );
+        Set result = filter.filter( artifacts, log );
+        Iterator iter = result.iterator();
+        while ( iter.hasNext() )
         {
-            assertTrue( false );
+            Artifact artifact = (Artifact) iter.next();
+            assertFalse( Artifact.SCOPE_SYSTEM.equalsIgnoreCase( artifact.getScope() ) );
         }
     }
 
     public void testExcludeCompile()
+        throws MojoExecutionException
+    {
+        ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_COMPILE );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 2, result.size() );
+    }
+
+    public void testExcludeTest()
     {
         try
         {
-            ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_COMPILE );
-            Set result = filter.filter( artifacts, log );
-            assertEquals( 2, result.size() );
+            ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_TEST );
+            filter.filter( artifacts, log );
+            fail( "Expected an Exception" );
         }
         catch ( MojoExecutionException e )
         {
-            assertTrue( false );
+
         }
     }
 
-    public void testExcludeTest()
+    public void testBadScope()
     {
+        ScopeFilter filter = new ScopeFilter( "cOmpile", "" );
         try
+        { 
+            filter.filter( artifacts, log );
+            fail( "Expected an Exception" );
+        }
+        catch ( MojoExecutionException e )
         {
-            ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_TEST );
-            Set result = filter.filter( artifacts, log );
-            assertTrue(false);
+
+        }
+        try
+        {
+            filter = new ScopeFilter( "", "coMpile" );
+            filter.filter( artifacts, log );
+            fail( "Expected an Exception" );
         }
         catch ( MojoExecutionException e )
         {
-            //I expect an exception here.
-            assertTrue( true );
+
         }
+    }
+    
+    public void testSettersGetters()
+    {
+        ScopeFilter filter = new ScopeFilter("include","exclude");
+        assertEquals("include",filter.getIncludeScope());
+        assertEquals("exclude",filter.getExcludeScope());
+        
+        filter.setExcludeScope("a");
+        filter.setIncludeScope("b");
+        assertEquals("b",filter.getIncludeScope());
+        assertEquals("a",filter.getExcludeScope());  
     }
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTransitivityFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTransitivityFilter.java?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTransitivityFilter.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTransitivityFilter.java
Mon Oct  2 21:03:06 2006
@@ -66,8 +66,10 @@
 
     public void testExclude()
     {
-        TransitivityFilter filter = new TransitivityFilter( directArtifacts, true );
-
+        TransitivityFilter filter = new TransitivityFilter( directArtifacts, false );
+        assertFalse(filter.isExcludeTransitive());
+        filter.setExcludeTransitive(true);
+        assertTrue(filter.isExcludeTransitive());
         Set result = filter.filter( artifacts, log );
 
         assertEquals( 2, result.size() );

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-dependencies-test/plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-dependencies-test/plugin-config.xml?view=diff&rev=452307&r1=452306&r2=452307
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-dependencies-test/plugin-config.xml
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/resources/unit/copy-dependencies-test/plugin-config.xml
Mon Oct  2 21:03:06 2006
@@ -5,6 +5,7 @@
         <artifactId>maven-dependency-plugin</artifactId>
           <configuration>
               <project implementation="org.apache.maven.plugin.dependency.stubs.DependencyProjectStub"/>
+              <silent>true</silent>
           </configuration>
       </plugin>
     </plugins>



Mime
View raw message