maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r496210 [1/2] - in /maven/plugins/trunk/maven-dependency-plugin/src: main/java/org/apache/maven/plugin/dependency/ main/java/org/apache/maven/plugin/dependency/utils/filters/ site/apt/ test/java/org/apache/maven/plugin/dependency/ test/java...
Date Mon, 15 Jan 2007 02:31:37 GMT
Author: brianf
Date: Sun Jan 14 18:31:36 2007
New Revision: 496210

URL: http://svn.apache.org/viewvc?view=rev&rev=496210
Log:
MDEP-54: include, exclude by artifactId or groupId. Patch from Chris Love.

Added:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/GroupIdFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/AbstractArtifactFeatureFilterTestCase.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestArtifactFilter.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestGroupIdFilter.java
Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt
    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/TestUnpackDependenciesMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java

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=496210&r1=496209&r2=496210
==============================================================================
--- 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 Sun Jan 14 18:31:36 2007
@@ -25,9 +25,11 @@
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
+import org.apache.maven.plugin.dependency.utils.filters.ArtifactIdFilter;
 import org.apache.maven.plugin.dependency.utils.filters.ArtifactsFilter;
 import org.apache.maven.plugin.dependency.utils.filters.ClassifierFilter;
 import org.apache.maven.plugin.dependency.utils.filters.FilterArtifacts;
+import org.apache.maven.plugin.dependency.utils.filters.GroupIdFilter;
 import org.apache.maven.plugin.dependency.utils.filters.ScopeFilter;
 import org.apache.maven.plugin.dependency.utils.filters.TransitivityFilter;
 import org.apache.maven.plugin.dependency.utils.filters.TypeFilter;
@@ -38,8 +40,11 @@
 import org.codehaus.plexus.util.StringUtils;
 
 /**
- * @author brianf
+ * Class that excapusulates the plugin parameters, and contains methods that
+ * handle dependency filtering
  * 
+ * @author brianf
+ * @see org.apache.maven.plugin.dependency.AbstractDependencyMojo
  */
 public abstract class AbstractDependencyFilterMojo
     extends AbstractDependencyMojo
@@ -83,7 +88,8 @@
     protected String includeScope;
 
     /**
-     * Scope to exclude. An Empty string indicates no scopes (default). Ignored if includeScope is used.
+     * Scope to exclude. An Empty string indicates no scopes (default). Ignored
+     * if includeScope is used.
      * 
      * @since 2.0
      * @parameter expression="${excludeScope}" default-value=""
@@ -131,12 +137,50 @@
     protected String type;
 
     /**
+     * Comma Seperated list of Artifact names too exclude. Ignored if
+     * includeArtifacts is used.
+     * 
+     * @since 2.0
+     * @optional
+     * @parameter expression="${excludeArtifactIds}" default-value=""
+     */
+    protected String excludeArtifactIds;
+
+    /**
+     * Comma Seperated list of Artifact names to include.
+     * 
+     * @since 2.0
+     * @optional
+     * @parameter expression="${includeArtifactIds}" default-value=""
+     */
+    protected String includeArtifactIds;
+
+    /**
+     * Comma Seperated list of GroupId Names to exclude. Ignored if
+     * includeGroupsIds is used.
+     * 
+     * @since 2.0
+     * @optional
+     * @parameter expression="${excludeGroupIds}" default-value=""
+     */
+    protected String excludeGroupIds;
+
+    /**
+     * Comma Seperated list of GroupIds to include.
+     * 
+     * @since 2.0
+     * @optional
+     * @parameter expression="${includeGroupIds}" default-value=""
+     */
+    protected String includeGroupIds;
+
+    /**
      * Directory to store flag files
      * 
      * @parameter expression="${markersDirectory}"
      *            default-value="${project.build.directory}/dependency-maven-plugin-markers"
      * @optional
-     * @since 1.0
+     * @since 2.0
      */
     protected File markersDirectory;
 
@@ -184,6 +228,17 @@
         return status.getResolvedDependencies();
     }
 
+    /**
+     * 
+     * Method creates filters and filters the projects dependencies. This method
+     * also transforms the dependencies if classifier is set. The dependencies
+     * are filtered in least specific to most specific order
+     * 
+     * @param stopOnFailure
+     * @return DependencyStatusSets - Bean of TreeSets that contains information
+     *         on the projects dependencies
+     * @throws MojoExecutionException
+     */
     protected DependencyStatusSets getDependencySets( boolean stopOnFailure )
         throws MojoExecutionException
     {
@@ -194,6 +249,8 @@
         filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) );
         filter.addFilter( new TypeFilter( this.includeTypes, this.excludeTypes ) );
         filter.addFilter( new ClassifierFilter( this.includeClassifiers, this.excludeClassifiers ) );
+        filter.addFilter( new GroupIdFilter( this.includeGroupIds, this.excludeGroupIds ) );
+        filter.addFilter( new ArtifactIdFilter( this.includeArtifactIds, this.excludeArtifactIds ) );
 
         // start with all artifacts.
         Set artifacts = project.getArtifacts();
@@ -215,6 +272,16 @@
         return status;
     }
 
+    /**
+     * 
+     * Transform artifacts
+     * 
+     * @param artifacts
+     * @param stopOnFailure
+     * @return DependencyStatusSets - Bean of TreeSets that contains information
+     *         on the projects dependencies
+     * @throws MojoExecutionException
+     */
     protected DependencyStatusSets getClassifierTranslatedDependencies( Set artifacts, boolean stopOnFailure )
         throws MojoExecutionException
     {
@@ -252,6 +319,13 @@
         return status;
     }
 
+    /**
+     * Filter the marked dependencies
+     * 
+     * @param artifacts
+     * @return
+     * @throws MojoExecutionException
+     */
     protected DependencyStatusSets filterMarkedDependencies( Set artifacts )
         throws MojoExecutionException
     {
@@ -279,7 +353,8 @@
     }
 
     /**
-     * @param theMarkersDirectory The markersDirectory to set.
+     * @param theMarkersDirectory
+     *            The markersDirectory to set.
      */
     public void setMarkersDirectory( File theMarkersDirectory )
     {

Added: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java?view=auto&rev=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ArtifactIdFilter.java Sun Jan 14 18:31:36 2007
@@ -0,0 +1,78 @@
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/* 
+ * 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.    
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * Filter on ArtifactId name
+ * 
+ * @author clove
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter
+ * @since 2.0-alpha-2
+ */
+public class ArtifactIdFilter
+    extends AbstractArtifactFeatureFilter
+{
+
+    private String includeScope;
+
+    private String excludeScope;
+
+    /**
+     * Will setup super with 'ArtifactId' as the filterType
+     * 
+     * @param include
+     * @param exclude
+     */
+    public ArtifactIdFilter( String include, String exclude )
+    {
+        super( include, exclude, "ArtifactId" );
+        this.includeScope = include;
+        this.excludeScope = exclude;
+    }
+
+    /**
+     * @return Returns the excludeScope.
+     */
+    public String getExcludeScope()
+    {
+        return excludeScope;
+    }
+
+    /**
+     * @return Returns the includeScope.
+     */
+    public String getIncludeScope()
+    {
+        return includeScope;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
+     */
+    protected String getArtifactFeature( Artifact artifact )
+    {
+        return artifact.getArtifactId();
+    }
+
+}

Added: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/GroupIdFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/GroupIdFilter.java?view=auto&rev=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/GroupIdFilter.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/GroupIdFilter.java Sun Jan 14 18:31:36 2007
@@ -0,0 +1,78 @@
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/* 
+ * 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.    
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * Filter on GroupId Name.
+ * 
+ * @author clove
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter
+ * @since 2.0
+ * 
+ */
+public class GroupIdFilter
+    extends AbstractArtifactFeatureFilter
+{
+
+    private String includeScope;
+
+    private String excludeScope;
+
+    /**
+     * Construction will setup the super call with a filtertype of 'GroupId'
+     * 
+     * @param include
+     * @param exclude
+     */
+    public GroupIdFilter( String include, String exclude )
+    {
+        super( include, exclude, "GroupId" );
+        this.includeScope = include;
+        this.excludeScope = exclude;
+    }
+
+    /**
+     * @return Returns the excludeScope.
+     */
+    public String getExcludeScope()
+    {
+        return excludeScope;
+    }
+
+    /**
+     * @return Returns the includeScope.
+     */
+    public String getIncludeScope()
+    {
+        return includeScope;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
+     */
+    protected String getArtifactFeature( Artifact artifact )
+    {
+        return artifact.getGroupId();
+    }
+}

Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt?view=diff&rev=496210&r1=496209&r2=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt Sun Jan 14 18:31:36 2007
@@ -120,7 +120,7 @@
    <<<mvn dependency:copy-dependencies -Dclassifer=sources>>> will try to find
    the sources for all dependencies and copy them.
 
-   	Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc) or a combination of all three.
+   	Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. NOTE: If you mix includes and excludes of the same category (ie scope), then only the includes will be used.
 
    See the {{#Overwrite Rules}} section for rules about how overwriting is handled.
 
@@ -228,7 +228,7 @@
    <<<mvn dependency:unpack-dependencies -Dclassifer=sources>>> will try to find
    the sources for all dependencies and unpack them.
    
-   Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc) or a combination of all three.
+      	Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc), groupId, artifactId, or a combination of them. NOTE: If you mix includes and excludes of the same category (ie scope), then only the includes will be used.
 
    See the {{#Overwrite Rules}} section for rules about how overwriting is handled.
                                       

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=496210&r1=496209&r2=496210
==============================================================================
--- 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 Sun Jan 14 18:31:36 2007
@@ -36,731 +36,772 @@
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
 
-public class TestCopyDependenciesMojo
-    extends AbstractDependencyMojoTestCase
-{
-
-    CopyDependenciesMojo mojo;
-
-    protected void setUp()
-        throws Exception
-    {
-        // required for mojo lookups to work
-        super.setUp( "copy-dependencies", true );
-
-        File testPom = new File( getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml" );
-        mojo = (CopyDependenciesMojo) lookupMojo( "copy-dependencies", testPom );
-        mojo.outputDirectory = new File( this.testDir, "outputDirectory" );
-        // mojo.silent = true;
-
-        assertNotNull( mojo );
-        assertNotNull( mojo.getProject() );
-        MavenProject project = mojo.getProject();
-
-        Set artifacts = this.stubFactory.getScopedArtifacts();
-        Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
-        artifacts.addAll( directArtifacts );
-
-        project.setArtifacts( artifacts );
-        project.setDependencyArtifacts( directArtifacts );
-        mojo.markersDirectory = new File( this.testDir, "markers" );
-
-    }
-
-    public void assertNoMarkerFile( Artifact artifact )
-    {
-        DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler( artifact, mojo.markersDirectory );
-        try
-        {
-            assertFalse( handle.isMarkerSet() );
-        }
-        catch ( MojoExecutionException e )
-        {
-            fail( e.getLongMessage() );
-        }
-
-    }
-
-    public void testCopyFile()
-        throws MojoExecutionException, IOException
-    {
-        File src = File.createTempFile( "copy", null );
-
-        File dest = new File( mojo.outputDirectory, "toMe.jar" );
-
-        assertFalse( dest.exists() );
-
-        mojo.copyFile( src, dest );
-        assertTrue( dest.exists() );
-    }
-
-    /**
-     * tests the proper discovery and configuration of the mojo
-     * 
-     * @throws Exception
-     */
-    public void testCopyDependenciesMojo()
-        throws Exception
-    {
-        mojo.execute();
-        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 );
-            assertTrue( file.exists() );
-
-            // there should be no markers for the copy mojo
-            assertNoMarkerFile( artifact );
-        }
-    }
-
-    public void testCopyDependenciesMojoStripVersion()
-        throws Exception
-    {
-        mojo.stripVersion = true;
-        mojo.execute();
-
-        Iterator iter = mojo.project.getArtifacts().iterator();
-        while ( iter.hasNext() )
-        {
-            Artifact artifact = (Artifact) iter.next();
-            String fileName = DependencyUtil.getFormattedFileName( artifact, true );
-            File file = new File( mojo.outputDirectory, fileName );
-            assertTrue( file.exists() );
-        }
-    }
-
-    public void testCopyDependenciesMojoNoTransitive()
-        throws Exception
-    {
-        mojo.excludeTransitive = true;
-        mojo.execute();
-        Iterator iter = mojo.project.getDependencyArtifacts().iterator();
-
-        // test - get all direct dependencies and verify that they exist
-        // then delete the file and at the end, verify the folder is empty.
-        while ( iter.hasNext() )
-        {
-            Artifact artifact = (Artifact) iter.next();
-            String fileName = DependencyUtil.getFormattedFileName( artifact, false );
-            File file = new File( mojo.outputDirectory, fileName );
-            assertTrue( file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-        // assumes you can't delete a folder that has files.
-        assertTrue( mojo.outputDirectory.delete() );
-    }
-
-    public void testCopyDependenciesMojoExcludeType()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.excludeTypes = "jar";
-        mojo.execute();
-
-        // test - get all direct dependencies and verify that they exist if they
-        // are not a jar
-        // then delete the file and at the end, verify the folder is empty.
-        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( artifact.getType().equalsIgnoreCase( "jar" ), !file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-        // assumes you can't delete a folder that has files.
-        assertTrue( mojo.outputDirectory.delete() );
-    }
-
-    public void testCopyDependenciesMojoIncludeType()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-
-        mojo.includeTypes = "jar";
-        // if include is used, exclude should be ignored.
-        mojo.excludeTypes = "jar";
-
-        mojo.execute();
-
-        // test - get all direct dependencies and verify that they exist only if
-        // they are a jar
-        // then delete the file and at the end, verify the folder is empty.
-        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( artifact.getType().equalsIgnoreCase( "jar" ), file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-        // assumes you can't delete a folder that has files.
-        assertTrue( mojo.outputDirectory.delete() );
-    }
-
-    public void testCopyDependenciesMojoExcludeClassifier()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.excludeClassifiers = "one";
-        mojo.execute();
-
-        // test - get all direct dependencies and verify that they exist if they
-        // do not have a classifier of "one"
-        // then delete the file and at the end, verify the folder is empty.
-        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( artifact.getClassifier().equals( "one" ), !file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-        // assumes you can't delete a folder that has files.
-        assertTrue( mojo.outputDirectory.delete() );
-    }
-
-    public void testCopyDependenciesMojoIncludeClassifier()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-
-        mojo.includeClassifiers = "one";
-        // if include is used, exclude should be ignored.
-        mojo.excludeClassifiers = "one";
-
-        mojo.execute();
-
-        // test - get all direct dependencies and verify that they exist only if
-        // they are a jar
-        // then delete the file and at the end, verify the folder is empty.
-        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( artifact.getClassifier().equals( "one" ), file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-        // assumes you can't delete a folder that has files.
-        assertTrue( mojo.outputDirectory.delete() );
-    }
-
-    public void testCopyDependenciesMojoSubPerType()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.useSubDirectoryPerType = true;
-        mojo.execute();
-
-        Iterator iter = mojo.project.getArtifacts().iterator();
-        while ( iter.hasNext() )
-        {
-            Artifact artifact = (Artifact) iter.next();
-            String fileName = DependencyUtil.getFormattedFileName( artifact, false );
-            File folder = DependencyUtil.getFormattedOutputDirectory( true, false, mojo.outputDirectory, artifact );
-            File file = new File( folder, fileName );
-            assertTrue( file.exists() );
-        }
-    }
-
-    public void testCopyDependenciesMojoSubPerArtifact()
-        throws Exception
-    {
-        mojo.useSubDirectoryPerArtifact = true;
-        mojo.execute();
-
-        Iterator iter = mojo.project.getArtifacts().iterator();
-        while ( iter.hasNext() )
-        {
-            Artifact artifact = (Artifact) iter.next();
-            String fileName = DependencyUtil.getFormattedFileName( artifact, false );
-            File folder = DependencyUtil.getFormattedOutputDirectory( false, true, mojo.outputDirectory, artifact );
-            File file = new File( folder, fileName );
-            assertTrue( file.exists() );
-        }
-    }
-
-    public void testCopyDependenciesMojoSubPerArtifactAndType()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getTypedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.useSubDirectoryPerArtifact = true;
-        mojo.useSubDirectoryPerType = true;
-        mojo.execute();
-
-        Iterator iter = mojo.project.getArtifacts().iterator();
-        while ( iter.hasNext() )
-        {
-            Artifact artifact = (Artifact) iter.next();
-            String fileName = DependencyUtil.getFormattedFileName( artifact, false );
-            File folder = DependencyUtil.getFormattedOutputDirectory( true, true, mojo.outputDirectory, artifact );
-            File file = new File( folder, fileName );
-            assertTrue( file.exists() );
-        }
-    }
-
-    public void testCopyDependenciesMojoIncludeCompileScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.includeScope = "compile";
-        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() );
-        }
-    }
-
-    public void testCopyDependenciesMojoIncludeTestScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.includeScope = "test";
-
-        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() );
-        }
-    }
-
-    public void testCopyDependenciesMojoIncludeRuntimeScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.includeScope = "runtime";
-        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() );
-        }
-    }
-
-    public void testCopyDependenciesMojoIncludeprovidedScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.includeScope = "provided";
-
-        mojo.execute();
-        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( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ), file.exists() );
-        }
-    }
-
-    public void testCopyDependenciesMojoIncludesystemScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.includeScope = "system";
-
-        mojo.execute();
-
-        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( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ), file.exists() );
-        }
-    }
-
-    public void testCDMClassifier()
-        throws Exception
-    {
-        dotestCopyDependenciesMojoClassifierType( "jdk14", null );
-    }
-
-    public void testCDMType()
-        throws Exception
-    {
-        dotestCopyDependenciesMojoClassifierType( null, "sources" );
-    }
-
-    public void testCDMClassifierType()
-        throws Exception
-    {
-        dotestCopyDependenciesMojoClassifierType( "jdk14", "sources" );
-    }
-
-    public void dotestCopyDependenciesMojoClassifierType( String testClassifier, String testType )
-        throws Exception
-    {
-        mojo.classifier = testClassifier;
-        mojo.type = testType;
-
-        // init classifier things
-        mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
-        mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
-        mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) );
-
-        mojo.execute();
-
-        Iterator iter = mojo.project.getArtifacts().iterator();
-        while ( iter.hasNext() )
-        {
-            Artifact artifact = (Artifact) iter.next();
-
-            String useClassifier = artifact.getClassifier();
-            String useType = artifact.getType();
-
-            if ( StringUtils.isNotEmpty( testClassifier ) )
-            {
-                useClassifier = "-" + testClassifier;
-                // type is only used if classifier is used.
-                if ( StringUtils.isNotEmpty( testType ) )
-                {
-                    useType = testType;
-                }
-            }
-            String fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + useClassifier + "." + useType;
-            File file = new File( mojo.outputDirectory, fileName );
-
-            if ( !file.exists() )
-            {
-                fail( "Can't find:" + file.getAbsolutePath() );
-            }
-
-            // there should be no markers for the copy mojo
-            assertNoMarkerFile( artifact );
-        }
-    }
-
-    public void testArtifactNotFound()
-        throws Exception
-    {
-        dotestArtifactExceptions( false, true );
-    }
-
-    public void testArtifactResolutionException()
-        throws Exception
-    {
-        dotestArtifactExceptions( true, false );
-    }
-
-    public void dotestArtifactExceptions( boolean are, boolean anfe )
-        throws Exception
-    {
-        mojo.classifier = "jdk";
-        mojo.type = "java-sources";
-
-        // init classifier things
-        mojo.factory = DependencyTestUtils.getArtifactFactory();
-        mojo.resolver = new StubArtifactResolver( null, are, anfe );
-        mojo.local = new StubArtifactRepository( this.testDir.getAbsolutePath() );
-
-        try
-        {
-            mojo.execute();
-            fail( "ExpectedException" );
-        }
-        catch ( MojoExecutionException e )
-        {
-
-        }
-    }
-
-    /*
-     * public void testOverwrite() { stubFactory.setCreateFiles( false );
-     * Artifact artifact = stubFactory.createArtifact( "test", "artifact", "1.0" );
-     * 
-     * File testFile = new File( getBasedir() + File.separatorChar +
-     * "target/test-classes/unit/copy-dependencies-test/test.zip" ); }
-     */
-
-    public void testDontOverWriteRelease()
-        throws MojoExecutionException, InterruptedException, IOException
-    {
-
-        Set artifacts = new HashSet();
-        Artifact release = stubFactory.getReleaseArtifact();
-        release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
-        artifacts.add( release );
-
-        mojo.project.setArtifacts( artifacts );
-        mojo.project.setDependencyArtifacts( artifacts );
-
-        mojo.overWriteIfNewer = false;
-
-        mojo.execute();
-
-        File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
-
-        Thread.sleep( 100 );
-        // round up to the next second
-        long time = System.currentTimeMillis() + 1000;
-        time = time - ( time % 1000 );
-        copiedFile.setLastModified( time );
-        Thread.sleep( 100 );
-
-        mojo.execute();
-
-        assertEquals( time, copiedFile.lastModified() );
-    }
-
-    public void testOverWriteRelease()
-        throws MojoExecutionException, InterruptedException, IOException
-    {
-
-        Set artifacts = new HashSet();
-        Artifact release = stubFactory.getReleaseArtifact();
-        release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
-        artifacts.add( release );
-
-        mojo.project.setArtifacts( artifacts );
-        mojo.project.setDependencyArtifacts( artifacts );
-
-        mojo.overWriteReleases = true;
-        mojo.overWriteIfNewer = false;
-
-        mojo.execute();
-
-        File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( release, false ) );
-
-        Thread.sleep( 100 );
-        // round down to the last second
-        long time = System.currentTimeMillis();
-        time = time - ( time % 1000 );
-        copiedFile.setLastModified( time );
-        // wait at least a second for filesystems that only record to the
-        // nearest second.
-        Thread.sleep( 1000 );
-
-        mojo.execute();
-
-        assertTrue( time < copiedFile.lastModified() );
-    }
-
-    public void testDontOverWriteSnap()
-        throws MojoExecutionException, InterruptedException, IOException
-    {
-
-        Set artifacts = new HashSet();
-        Artifact snap = stubFactory.getSnapshotArtifact();
-        snap.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
-        artifacts.add( snap );
-
-        mojo.project.setArtifacts( artifacts );
-        mojo.project.setDependencyArtifacts( artifacts );
-
-        mojo.overWriteReleases = false;
-        mojo.overWriteSnapshots = false;
-        mojo.overWriteIfNewer = false;
-
-        mojo.execute();
-
-        File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
-
-        Thread.sleep( 100 );
-        // round up to the next second
-        long time = System.currentTimeMillis() + 1000;
-        time = time - ( time % 1000 );
-        copiedFile.setLastModified( time );
-        Thread.sleep( 100 );
-
-        mojo.execute();
-
-        assertEquals( time, copiedFile.lastModified() );
-    }
-
-    public void testOverWriteSnap()
-        throws MojoExecutionException, InterruptedException, IOException
-    {
-
-        Set artifacts = new HashSet();
-        Artifact snap = stubFactory.getSnapshotArtifact();
-        snap.getFile().setLastModified( System.currentTimeMillis() - 2000 );
-
-        artifacts.add( snap );
-
-        mojo.project.setArtifacts( artifacts );
-        mojo.project.setDependencyArtifacts( artifacts );
-
-        mojo.overWriteReleases = false;
-        mojo.overWriteSnapshots = true;
-        mojo.overWriteIfNewer = false;
-
-        mojo.execute();
-
-        File copiedFile = new File( mojo.outputDirectory, DependencyUtil.getFormattedFileName( snap, false ) );
-
-        Thread.sleep( 100 );
-        // round down to the last second
-        long time = System.currentTimeMillis();
-        time = time - ( time % 1000 );
-        copiedFile.setLastModified( time );
-        // wait at least a second for filesystems that only record to the
-        // nearest second.
-        Thread.sleep( 1000 );
-
-        mojo.execute();
-
-        assertTrue( time < copiedFile.lastModified() );
-    }
-
-    public void testGetDependencies()
-        throws MojoExecutionException
-    {
-        assertEquals( mojo.getResolvedDependencies( true ).toString(), mojo.getDependencySets( true )
-            .getResolvedDependencies().toString() );
-    }
-
-    public void testCopyDependenciesMojoExcludeProvidedScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.excludeScope = "provided";
-        // mojo.silent = false;
-
-        mojo.execute();
-
-        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( artifact.getScope().equals( "provided" ), !file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-
-    }
-
-    public void testCopyDependenciesMojoExcludeSystemScope()
-        throws Exception
-    {
-        mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-        mojo.project.setDependencyArtifacts( new HashSet() );
-        mojo.excludeScope = "system";
-        // mojo.silent = false;
-
-        mojo.execute();
-
-        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( artifact.getScope().equals( "system" ), !file.exists() );
-            file.delete();
-            assertFalse( file.exists() );
-        }
-
-    }
-
-    public void testCopyDependenciesMojoExcludeCompileScope()
-    throws Exception
-{
-    mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-    mojo.project.setDependencyArtifacts( new HashSet() );
-    mojo.excludeScope = "compile";
-    mojo.execute();
-    ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
-
-    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() );
-    }
-}
-
-public void testCopyDependenciesMojoExcludeTestScope() throws IOException
-{
-    mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-    mojo.project.setDependencyArtifacts( new HashSet() );
-    mojo.excludeScope = "test";
-
-    try
-    {
-        mojo.execute();
-        fail("expected an exception");
-    }
-    catch ( MojoExecutionException e )
-    {
-     
-    }
-    
-}
-
-public void testCopyDependenciesMojoExcludeRuntimeScope()
-    throws Exception
-{
-    mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
-    mojo.project.setDependencyArtifacts( new HashSet() );
-    mojo.excludeScope = "runtime";
-    mojo.execute();
-    ScopeArtifactFilter saf = new ScopeArtifactFilter( mojo.excludeScope );
-
-    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() );
-    }
-}
+public class TestCopyDependenciesMojo extends AbstractDependencyMojoTestCase {
+
+	CopyDependenciesMojo mojo;
+
+	protected void setUp() throws Exception {
+		// required for mojo lookups to work
+		super.setUp("copy-dependencies", true);
+
+		File testPom = new File(getBasedir(),
+				"target/test-classes/unit/copy-dependencies-test/plugin-config.xml");
+		mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom);
+		mojo.outputDirectory = new File(this.testDir, "outputDirectory");
+		// mojo.silent = true;
+
+		assertNotNull(mojo);
+		assertNotNull(mojo.getProject());
+		MavenProject project = mojo.getProject();
+
+		Set artifacts = this.stubFactory.getScopedArtifacts();
+		Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
+		artifacts.addAll(directArtifacts);
+
+		project.setArtifacts(artifacts);
+		project.setDependencyArtifacts(directArtifacts);
+		mojo.markersDirectory = new File(this.testDir, "markers");
+
+	}
+
+	public void assertNoMarkerFile(Artifact artifact) {
+		DefaultFileMarkerHandler handle = new DefaultFileMarkerHandler(
+				artifact, mojo.markersDirectory);
+		try {
+			assertFalse(handle.isMarkerSet());
+		} catch (MojoExecutionException e) {
+			fail(e.getLongMessage());
+		}
+
+	}
+
+	public void testCopyFile() throws MojoExecutionException, IOException {
+		File src = File.createTempFile("copy", null);
+
+		File dest = new File(mojo.outputDirectory, "toMe.jar");
+
+		assertFalse(dest.exists());
+
+		mojo.copyFile(src, dest);
+		assertTrue(dest.exists());
+	}
+
+	/**
+	 * tests the proper discovery and configuration of the mojo
+	 * 
+	 * @throws Exception
+	 */
+	public void testCopyDependenciesMojo() throws Exception {
+		mojo.execute();
+		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);
+			assertTrue(file.exists());
+
+			// there should be no markers for the copy mojo
+			assertNoMarkerFile(artifact);
+		}
+	}
+
+	public void testCopyDependenciesMojoStripVersion() throws Exception {
+		mojo.stripVersion = true;
+		mojo.execute();
+
+		Iterator iter = mojo.project.getArtifacts().iterator();
+		while (iter.hasNext()) {
+			Artifact artifact = (Artifact) iter.next();
+			String fileName = DependencyUtil.getFormattedFileName(artifact,
+					true);
+			File file = new File(mojo.outputDirectory, fileName);
+			assertTrue(file.exists());
+		}
+	}
+
+	public void testCopyDependenciesMojoNoTransitive() throws Exception {
+		mojo.excludeTransitive = true;
+		mojo.execute();
+		Iterator iter = mojo.project.getDependencyArtifacts().iterator();
+
+		// test - get all direct dependencies and verify that they exist
+		// then delete the file and at the end, verify the folder is empty.
+		while (iter.hasNext()) {
+			Artifact artifact = (Artifact) iter.next();
+			String fileName = DependencyUtil.getFormattedFileName(artifact,
+					false);
+			File file = new File(mojo.outputDirectory, fileName);
+			assertTrue(file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoExcludeType() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getTypedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeTypes = "jar";
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist if they
+		// are not a jar
+		// then delete the file and at the end, verify the folder is empty.
+		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(artifact.getType().equalsIgnoreCase("jar"), !file
+					.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoIncludeType() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getTypedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+
+		mojo.includeTypes = "jar";
+		// if include is used, exclude should be ignored.
+		mojo.excludeTypes = "jar";
+
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist only if
+		// they are a jar
+		// then delete the file and at the end, verify the folder is empty.
+		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(artifact.getType().equalsIgnoreCase("jar"), file
+					.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoExcludeArtifactId() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getArtifactArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeArtifactIds = "one";
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist if they
+		// do not have a classifier of "one"
+		// then delete the file and at the end, verify the folder is empty.
+		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(artifact.getArtifactId().equals("one"), !file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoIncludeArtifactId() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getArtifactArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+
+		mojo.includeArtifactIds = "one";
+		// if include is used, exclude should be ignored.
+		mojo.excludeArtifactIds = "one";
+
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist only if
+		// they are a jar
+		// then delete the file and at the end, verify the folder is empty.
+		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(artifact.getArtifactId().equals("one"), file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoIncludeGroupId() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getGroupIdArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.includeGroupIds = "one";
+		// if include is used, exclude should be ignored.
+		mojo.excludeGroupIds = "one";
+
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist only if
+		// they are a jar
+		// then delete the file and at the end, verify the folder is empty.
+		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);
+			// Testing with artifact id because group id is not in filename
+			assertEquals(artifact.getArtifactId().equals("group-one"), file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoExcludeGroupId() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getGroupIdArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeGroupIds = "one";
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist if they
+		// do not have a classifier of "one"
+		// then delete the file and at the end, verify the folder is empty.
+		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);
+			// Testing with artifact id because group id is not in filename
+			assertEquals(artifact.getArtifactId().equals("group-one"), !file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoExcludeClassifier() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getClassifiedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeClassifiers = "one";
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist if they
+		// do not have a classifier of "one"
+		// then delete the file and at the end, verify the folder is empty.
+		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(artifact.getClassifier().equals("one"), !file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoIncludeClassifier() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getClassifiedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+
+		mojo.includeClassifiers = "one";
+		// if include is used, exclude should be ignored.
+		mojo.excludeClassifiers = "one";
+
+		mojo.execute();
+
+		// test - get all direct dependencies and verify that they exist only if
+		// they are a jar
+		// then delete the file and at the end, verify the folder is empty.
+		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(artifact.getClassifier().equals("one"), file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+		// assumes you can't delete a folder that has files.
+		assertTrue(mojo.outputDirectory.delete());
+	}
+
+	public void testCopyDependenciesMojoSubPerType() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getTypedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.useSubDirectoryPerType = true;
+		mojo.execute();
+
+		Iterator iter = mojo.project.getArtifacts().iterator();
+		while (iter.hasNext()) {
+			Artifact artifact = (Artifact) iter.next();
+			String fileName = DependencyUtil.getFormattedFileName(artifact,
+					false);
+			File folder = DependencyUtil.getFormattedOutputDirectory(true,
+					false, mojo.outputDirectory, artifact);
+			File file = new File(folder, fileName);
+			assertTrue(file.exists());
+		}
+	}
+
+	public void testCopyDependenciesMojoSubPerArtifact() throws Exception {
+		mojo.useSubDirectoryPerArtifact = true;
+		mojo.execute();
+
+		Iterator iter = mojo.project.getArtifacts().iterator();
+		while (iter.hasNext()) {
+			Artifact artifact = (Artifact) iter.next();
+			String fileName = DependencyUtil.getFormattedFileName(artifact,
+					false);
+			File folder = DependencyUtil.getFormattedOutputDirectory(false,
+					true, mojo.outputDirectory, artifact);
+			File file = new File(folder, fileName);
+			assertTrue(file.exists());
+		}
+	}
+
+	public void testCopyDependenciesMojoSubPerArtifactAndType()
+			throws Exception {
+		mojo.project.setArtifacts(stubFactory.getTypedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.useSubDirectoryPerArtifact = true;
+		mojo.useSubDirectoryPerType = true;
+		mojo.execute();
+
+		Iterator iter = mojo.project.getArtifacts().iterator();
+		while (iter.hasNext()) {
+			Artifact artifact = (Artifact) iter.next();
+			String fileName = DependencyUtil.getFormattedFileName(artifact,
+					false);
+			File folder = DependencyUtil.getFormattedOutputDirectory(true,
+					true, mojo.outputDirectory, artifact);
+			File file = new File(folder, fileName);
+			assertTrue(file.exists());
+		}
+	}
+
+	public void testCopyDependenciesMojoIncludeCompileScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.includeScope = "compile";
+		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());
+		}
+	}
+
+	public void testCopyDependenciesMojoIncludeTestScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.includeScope = "test";
+
+		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());
+		}
+	}
+
+	public void testCopyDependenciesMojoIncludeRuntimeScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.includeScope = "runtime";
+		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());
+		}
+	}
+
+	public void testCopyDependenciesMojoIncludeprovidedScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.includeScope = "provided";
+
+		mojo.execute();
+		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(Artifact.SCOPE_PROVIDED.equals(artifact.getScope()),
+					file.exists());
+		}
+	}
+
+	public void testCopyDependenciesMojoIncludesystemScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.includeScope = "system";
+
+		mojo.execute();
+
+		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(Artifact.SCOPE_SYSTEM.equals(artifact.getScope()),
+					file.exists());
+		}
+	}
+
+	public void testCDMClassifier() throws Exception {
+		dotestCopyDependenciesMojoClassifierType("jdk14", null);
+	}
+
+	public void testCDMType() throws Exception {
+		dotestCopyDependenciesMojoClassifierType(null, "sources");
+	}
+
+	public void testCDMClassifierType() throws Exception {
+		dotestCopyDependenciesMojoClassifierType("jdk14", "sources");
+	}
+
+	public void dotestCopyDependenciesMojoClassifierType(String testClassifier,
+			String testType) throws Exception {
+		mojo.classifier = testClassifier;
+		mojo.type = testType;
+
+		// init classifier things
+		mojo.setFactory(DependencyTestUtils.getArtifactFactory());
+		mojo.setResolver(new StubArtifactResolver(stubFactory, false, false));
+		mojo
+				.setLocal(new StubArtifactRepository(this.testDir
+						.getAbsolutePath()));
+
+		mojo.execute();
+
+		Iterator iter = mojo.project.getArtifacts().iterator();
+		while (iter.hasNext()) {
+			Artifact artifact = (Artifact) iter.next();
+
+			String useClassifier = artifact.getClassifier();
+			String useType = artifact.getType();
+
+			if (StringUtils.isNotEmpty(testClassifier)) {
+				useClassifier = "-" + testClassifier;
+				// type is only used if classifier is used.
+				if (StringUtils.isNotEmpty(testType)) {
+					useType = testType;
+				}
+			}
+			String fileName = artifact.getArtifactId() + "-"
+					+ artifact.getVersion() + useClassifier + "." + useType;
+			File file = new File(mojo.outputDirectory, fileName);
+
+			if (!file.exists()) {
+				fail("Can't find:" + file.getAbsolutePath());
+			}
+
+			// there should be no markers for the copy mojo
+			assertNoMarkerFile(artifact);
+		}
+	}
+
+	public void testArtifactNotFound() throws Exception {
+		dotestArtifactExceptions(false, true);
+	}
+
+	public void testArtifactResolutionException() throws Exception {
+		dotestArtifactExceptions(true, false);
+	}
+
+	public void dotestArtifactExceptions(boolean are, boolean anfe)
+			throws Exception {
+		mojo.classifier = "jdk";
+		mojo.type = "java-sources";
+
+		// init classifier things
+		mojo.factory = DependencyTestUtils.getArtifactFactory();
+		mojo.resolver = new StubArtifactResolver(null, are, anfe);
+		mojo.local = new StubArtifactRepository(this.testDir.getAbsolutePath());
+
+		try {
+			mojo.execute();
+			fail("ExpectedException");
+		} catch (MojoExecutionException e) {
+
+		}
+	}
+
+	/*
+	 * public void testOverwrite() { stubFactory.setCreateFiles( false );
+	 * Artifact artifact = stubFactory.createArtifact( "test", "artifact", "1.0" );
+	 * 
+	 * File testFile = new File( getBasedir() + File.separatorChar +
+	 * "target/test-classes/unit/copy-dependencies-test/test.zip" ); }
+	 */
+
+	public void testDontOverWriteRelease() throws MojoExecutionException,
+			InterruptedException, IOException {
+
+		Set artifacts = new HashSet();
+		Artifact release = stubFactory.getReleaseArtifact();
+		release.getFile().setLastModified(System.currentTimeMillis() - 2000);
+
+		artifacts.add(release);
+
+		mojo.project.setArtifacts(artifacts);
+		mojo.project.setDependencyArtifacts(artifacts);
+
+		mojo.overWriteIfNewer = false;
+
+		mojo.execute();
+
+		File copiedFile = new File(mojo.outputDirectory, DependencyUtil
+				.getFormattedFileName(release, false));
+
+		Thread.sleep(100);
+		// round up to the next second
+		long time = System.currentTimeMillis() + 1000;
+		time = time - (time % 1000);
+		copiedFile.setLastModified(time);
+		Thread.sleep(100);
+
+		mojo.execute();
+
+		assertEquals(time, copiedFile.lastModified());
+	}
+
+	public void testOverWriteRelease() throws MojoExecutionException,
+			InterruptedException, IOException {
+
+		Set artifacts = new HashSet();
+		Artifact release = stubFactory.getReleaseArtifact();
+		release.getFile().setLastModified(System.currentTimeMillis() - 2000);
+
+		artifacts.add(release);
+
+		mojo.project.setArtifacts(artifacts);
+		mojo.project.setDependencyArtifacts(artifacts);
+
+		mojo.overWriteReleases = true;
+		mojo.overWriteIfNewer = false;
+
+		mojo.execute();
+
+		File copiedFile = new File(mojo.outputDirectory, DependencyUtil
+				.getFormattedFileName(release, false));
+
+		Thread.sleep(100);
+		// round down to the last second
+		long time = System.currentTimeMillis();
+		time = time - (time % 1000);
+		copiedFile.setLastModified(time);
+		// wait at least a second for filesystems that only record to the
+		// nearest second.
+		Thread.sleep(1000);
+
+		mojo.execute();
+
+		assertTrue(time < copiedFile.lastModified());
+	}
+
+	public void testDontOverWriteSnap() throws MojoExecutionException,
+			InterruptedException, IOException {
+
+		Set artifacts = new HashSet();
+		Artifact snap = stubFactory.getSnapshotArtifact();
+		snap.getFile().setLastModified(System.currentTimeMillis() - 2000);
+
+		artifacts.add(snap);
+
+		mojo.project.setArtifacts(artifacts);
+		mojo.project.setDependencyArtifacts(artifacts);
+
+		mojo.overWriteReleases = false;
+		mojo.overWriteSnapshots = false;
+		mojo.overWriteIfNewer = false;
+
+		mojo.execute();
+
+		File copiedFile = new File(mojo.outputDirectory, DependencyUtil
+				.getFormattedFileName(snap, false));
+
+		Thread.sleep(100);
+		// round up to the next second
+		long time = System.currentTimeMillis() + 1000;
+		time = time - (time % 1000);
+		copiedFile.setLastModified(time);
+		Thread.sleep(100);
+
+		mojo.execute();
+
+		assertEquals(time, copiedFile.lastModified());
+	}
+
+	public void testOverWriteSnap() throws MojoExecutionException,
+			InterruptedException, IOException {
+
+		Set artifacts = new HashSet();
+		Artifact snap = stubFactory.getSnapshotArtifact();
+		snap.getFile().setLastModified(System.currentTimeMillis() - 2000);
+
+		artifacts.add(snap);
+
+		mojo.project.setArtifacts(artifacts);
+		mojo.project.setDependencyArtifacts(artifacts);
+
+		mojo.overWriteReleases = false;
+		mojo.overWriteSnapshots = true;
+		mojo.overWriteIfNewer = false;
+
+		mojo.execute();
+
+		File copiedFile = new File(mojo.outputDirectory, DependencyUtil
+				.getFormattedFileName(snap, false));
+
+		Thread.sleep(100);
+		// round down to the last second
+		long time = System.currentTimeMillis();
+		time = time - (time % 1000);
+		copiedFile.setLastModified(time);
+		// wait at least a second for filesystems that only record to the
+		// nearest second.
+		Thread.sleep(1000);
+
+		mojo.execute();
+
+		assertTrue(time < copiedFile.lastModified());
+	}
+
+	public void testGetDependencies() throws MojoExecutionException {
+		assertEquals(mojo.getResolvedDependencies(true).toString(), mojo
+				.getDependencySets(true).getResolvedDependencies().toString());
+	}
+
+	public void testCopyDependenciesMojoExcludeProvidedScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeScope = "provided";
+		// mojo.silent = false;
+
+		mojo.execute();
+
+		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(artifact.getScope().equals("provided"), !file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+
+	}
+
+	public void testCopyDependenciesMojoExcludeSystemScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeScope = "system";
+		// mojo.silent = false;
+
+		mojo.execute();
+
+		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(artifact.getScope().equals("system"), !file.exists());
+			file.delete();
+			assertFalse(file.exists());
+		}
+
+	}
+
+	public void testCopyDependenciesMojoExcludeCompileScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeScope = "compile";
+		mojo.execute();
+		ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope);
+
+		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());
+		}
+	}
+
+	public void testCopyDependenciesMojoExcludeTestScope() throws IOException {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeScope = "test";
+
+		try {
+			mojo.execute();
+			fail("expected an exception");
+		} catch (MojoExecutionException e) {
+
+		}
+
+	}
+
+	public void testCopyDependenciesMojoExcludeRuntimeScope() throws Exception {
+		mojo.project.setArtifacts(stubFactory.getScopedArtifacts());
+		mojo.project.setDependencyArtifacts(new HashSet());
+		mojo.excludeScope = "runtime";
+		mojo.execute();
+		ScopeArtifactFilter saf = new ScopeArtifactFilter(mojo.excludeScope);
+
+		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());
+		}
+	}
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java?view=diff&rev=496210&r1=496209&r2=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestUnpackDependenciesMojo.java Sun Jan 14 18:31:36 2007
@@ -205,7 +205,8 @@
         }
     }
 
-    public void testUnpackDependenciesMojoExcludeTestScope() throws IOException
+    public void testUnpackDependenciesMojoExcludeTestScope()
+        throws IOException
     {
         mojo.project.setArtifacts( stubFactory.getScopedArtifacts() );
         mojo.project.setDependencyArtifacts( new HashSet() );
@@ -214,13 +215,13 @@
         try
         {
             mojo.execute();
-            fail("expected an exception");
+            fail( "expected an exception" );
         }
         catch ( MojoExecutionException e )
         {
-           
+
         }
-        
+
     }
 
     public void testUnpackDependenciesMojoExcludeRuntimeScope()

Added: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/AbstractArtifactFeatureFilterTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/AbstractArtifactFeatureFilterTestCase.java?view=auto&rev=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/AbstractArtifactFeatureFilterTestCase.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/AbstractArtifactFeatureFilterTestCase.java Sun Jan 14 18:31:36 2007
@@ -0,0 +1,139 @@
+package org.apache.maven.plugin.dependency.testUtils;
+
+/* 
+ * 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.    
+ */
+
+/**
+ * 
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.plugin.dependency.utils.SilentLog;
+import org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * Abstract test case for subclasses of AbstractArtifactFeatureFilter
+ * 
+ * @author clove
+ * @see junit.framework.TestCase
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter
+ * @since 2.0
+ */
+public abstract class AbstractArtifactFeatureFilterTestCase
+    extends TestCase
+{
+    protected Set artifacts = new HashSet();
+
+    Log log = new SilentLog();
+
+    protected Class filterClass;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+    }
+
+    private Object createObjectViaReflection( Class clazz, Object[] conArgs )
+        throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+        IllegalAccessException, InvocationTargetException
+    {
+        Class[] argslist = new Class[2];
+        argslist[0] = String.class;
+        argslist[1] = String.class;
+        Constructor ct = clazz.getConstructor( argslist );
+        return ct.newInstance( conArgs );
+    }
+
+    public abstract void testParsing()
+        throws Exception;
+
+    public void parsing()
+        throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+        IllegalAccessException, InvocationTargetException
+    {
+        Object[] conArgs = new Object[] { "one,two", "three,four," };
+
+        AbstractArtifactFeatureFilter filter = (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass,
+                                                                                                          conArgs );
+        List includes = filter.getIncludes();
+        List excludes = filter.getExcludes();
+
+        assertEquals( 2, includes.size() );
+        assertEquals( 2, excludes.size() );
+        assertEquals( "one", includes.get( 0 ).toString() );
+        assertEquals( "two", includes.get( 1 ).toString() );
+        assertEquals( "three", excludes.get( 0 ).toString() );
+        assertEquals( "four", excludes.get( 1 ).toString() );
+    }
+
+    public abstract void testFiltering()
+        throws Exception;
+
+    public Set filtering()
+        throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
+        IllegalAccessException, InvocationTargetException
+    {
+        Object[] conArgs = new Object[] { "one,two", "one,three," };
+        AbstractArtifactFeatureFilter filter = (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass,
+                                                                                                          conArgs );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 2, result.size() );
+        return result;
+    }
+
+    public abstract void testFiltering2()
+        throws Exception;
+
+    public Set filtering2()
+        throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
+        IllegalAccessException, InvocationTargetException
+    {
+        Object[] conArgs = new Object[] { null, "one,three," };
+        AbstractArtifactFeatureFilter filter = (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass,
+                                                                                                          conArgs );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 2, result.size() );
+        return result;
+
+    }
+
+    public abstract void testFiltering3()
+        throws Exception;
+
+    public void filtering3()
+        throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
+        IllegalAccessException, InvocationTargetException
+    {
+        Object[] conArgs = new Object[] { null, null };
+        AbstractArtifactFeatureFilter filter = (AbstractArtifactFeatureFilter) createObjectViaReflection( filterClass,
+                                                                                                          conArgs );
+        Set result = filter.filter( artifacts, log );
+        assertEquals( 4, result.size() );
+    }
+}

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java?view=diff&rev=496210&r1=496209&r2=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/ArtifactStubFactory.java Sun Jan 14 18:31:36 2007
@@ -1,4 +1,5 @@
 package org.apache.maven.plugin.dependency.testUtils;
+
 /* 
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -243,6 +244,28 @@
         return set;
     }
 
+    public Set getArtifactArtifacts()
+        throws IOException
+    {
+        Set set = new HashSet();
+        set.add( createArtifact( "g", "one", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        set.add( createArtifact( "g", "two", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        set.add( createArtifact( "g", "three", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        set.add( createArtifact( "g", "four", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        return set;
+    }
+
+    public Set getGroupIdArtifacts()
+        throws IOException
+    {
+        Set set = new HashSet();
+        set.add( createArtifact( "one", "group-one", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        set.add( createArtifact( "two", "group-two", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        set.add( createArtifact( "three", "group-three", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        set.add( createArtifact( "four", "group-four", "1.0", Artifact.SCOPE_COMPILE, "jar", "a" ) );
+        return set;
+    }
+
     public Set getMixedArtifacts()
         throws IOException
     {
@@ -320,4 +343,5 @@
         }
         return list;
     }
+
 }

Added: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestArtifactFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestArtifactFilter.java?view=auto&rev=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestArtifactFilter.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestArtifactFilter.java Sun Jan 14 18:31:36 2007
@@ -0,0 +1,85 @@
+package org.apache.maven.plugin.dependency.utils.filters;
+
+/* 
+ * 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.    
+ */
+
+/**
+ * 
+ */
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.dependency.testUtils.AbstractArtifactFeatureFilterTestCase;
+import org.apache.maven.plugin.dependency.testUtils.ArtifactStubFactory;
+
+/**
+ * @author clove TestCases for ArtifactFilter
+ * @see org.apache.maven.plugin.dependency.testUtils.AbstractArtifactFeatureFilterTestCase
+ */
+public class TestArtifactFilter
+    extends AbstractArtifactFeatureFilterTestCase
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        filterClass = ArtifactIdFilter.class;
+        ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+        artifacts = factory.getArtifactArtifacts();
+    }
+
+    public void testParsing()
+        throws Exception
+    {
+        parsing();
+    }
+
+    public void testFiltering()
+        throws Exception
+    {
+        Set result = filtering();
+        Iterator iter = result.iterator();
+        while ( iter.hasNext() )
+        {
+            Artifact artifact = (Artifact) iter.next();
+            assertTrue( artifact.getArtifactId().equals( "one" ) || artifact.getArtifactId().equals( "two" ) );
+        }
+    }
+
+    public void testFiltering2()
+        throws Exception
+    {
+        Set result = filtering2();
+        Iterator iter = result.iterator();
+        while ( iter.hasNext() )
+        {
+            Artifact artifact = (Artifact) iter.next();
+            assertTrue( artifact.getArtifactId().equals( "two" ) || artifact.getArtifactId().equals( "four" ) );
+        }
+    }
+
+    public void testFiltering3()
+        throws Exception
+    {
+        filtering3();
+    }
+}

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java?view=diff&rev=496210&r1=496209&r2=496210
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java Sun Jan 14 18:31:36 2007
@@ -1,4 +1,5 @@
 package org.apache.maven.plugin.dependency.utils.filters;
+
 /* 
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -22,58 +23,43 @@
  * 
  */
 
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
-import junit.framework.TestCase;
-
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.dependency.testUtils.AbstractArtifactFeatureFilterTestCase;
 import org.apache.maven.plugin.dependency.testUtils.ArtifactStubFactory;
-import org.apache.maven.plugin.dependency.utils.SilentLog;
-import org.apache.maven.plugin.logging.Log;
 
 /**
- * @author brianf
+ * @author brianf Test case for ClassifierFilter
+ * @see org.apache.maven.plugin.dependency.testUtils.AbstractArtifactFeatureFilterTestCase
  * 
  */
 public class TestClassifierFilter
-    extends TestCase
+    extends AbstractArtifactFeatureFilterTestCase
 {
-    Set artifacts = new HashSet();
-
-    Log log = new SilentLog();
 
     protected void setUp()
         throws Exception
     {
         super.setUp();
-
+        filterClass = ClassifierFilter.class;
         ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
         artifacts = factory.getClassifiedArtifacts();
+
     }
 
-    public void testClassifierParsing()
+    public void testParsing()
+        throws Exception
     {
-        ClassifierFilter filter = new ClassifierFilter( "one,two", "three,four," );
-        List includes = filter.getIncludes();
-        List excludes = filter.getExcludes();
-
-        assertEquals( 2, includes.size() );
-        assertEquals( 2, excludes.size() );
-        assertEquals( "one", includes.get( 0 ).toString() );
-        assertEquals( "two", includes.get( 1 ).toString() );
-        assertEquals( "three", excludes.get( 0 ).toString() );
-        assertEquals( "four", excludes.get( 1 ).toString() );
+        parsing();
+
     }
 
     public void testFiltering()
+        throws Exception
     {
-        ClassifierFilter filter = new ClassifierFilter( "one,two", "one,three," );
-        Set result = filter.filter( artifacts, log );
-        assertEquals( 2, result.size() );
-
+        Set result = filtering();
         Iterator iter = result.iterator();
         while ( iter.hasNext() )
         {
@@ -83,11 +69,9 @@
     }
 
     public void testFiltering2()
+        throws Exception
     {
-        ClassifierFilter filter = new ClassifierFilter( null, "one,three," );
-        Set result = filter.filter( artifacts, log );
-        assertEquals( 2, result.size() );
-
+        Set result = filtering2();
         Iterator iter = result.iterator();
         while ( iter.hasNext() )
         {
@@ -97,9 +81,8 @@
     }
 
     public void testFiltering3()
+        throws Exception
     {
-        ClassifierFilter filter = new ClassifierFilter( null, null );
-        Set result = filter.filter( artifacts, log );
-        assertEquals( 4, result.size() );
+        filtering3();
     }
 }



Mime
View raw message