You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2008/01/15 23:55:42 UTC

svn commit: r612280 [2/3] - in /maven/plugins/trunk/maven-dependency-plugin/src: main/java/org/apache/maven/plugin/dependency/ main/java/org/apache/maven/plugin/dependency/utils/markers/ main/resources/ main/resources/META-INF/plexus/ site/apt/examples...

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java?rev=612280&r1=612279&r2=612280&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java Tue Jan 15 14:55:37 2008
@@ -1,286 +1,286 @@
-package org.apache.maven.plugin.dependency;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
-import org.apache.maven.plugin.dependency.fromConfiguration.UnpackMojo;
-import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
-import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
-import org.apache.maven.plugin.testing.stubs.StubArtifactCollector;
-import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
-
-public class TestIncludeExcludeUnpackMojo 
-	extends AbstractDependencyMojoTestCase
-{
-	private final String PACKED_FILE = "test.zip";
-	
-	private final String UNPACKED_FILE_PREFIX = "test";
-	private final String UNPACKED_FILE_SUFFIX = ".txt";
-	
-	private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE;
-	
-	UnpackMojo mojo;
-
-    protected void setUp()
-        throws Exception
-    {
-    	// required for mojo lookups to work
-        super.setUp( "unpack", true );
-
-        File testPom = new File( getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml" );
-        mojo = (UnpackMojo) lookupMojo( "unpack", testPom );
-        mojo.setOutputDirectory( new File( this.testDir, "outputDirectory" ) );
-        // mojo.silent = true;
-
-        // it needs to get the archivermanager
-        //stubFactory.setUnpackableFile( mojo.getArchiverManager() );
-        // i'm using one file repeatedly to archive so I can test the name
-        // programmatically.
-        stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar + PACKED_FILE_PATH ) );
-        Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
-        ArtifactItem item = stubFactory.getArtifactItem( artifact );
-        ArrayList list = new ArrayList( 1 );
-        list.add( item );
-        assertNotNull( mojo );
-        assertNotNull( mojo.getProject() );
-        
-        mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
-        mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
-        mojo.setMarkersDirectory( new File( this.testDir, "markers" ) );
-        mojo.setArtifactCollector( new StubArtifactCollector() );
-        mojo.setArtifactItems( list );
-    }
-    
-    protected void tearDown()
-    {
-        super.tearDown();
-        
-        mojo = null;
-        System.gc();
-    }
-    
-    public void assertMarkerFiles( Collection items, boolean exist )
-    {
-        Iterator iter = items.iterator();
-        while ( iter.hasNext() )
-        {
-            assertMarkerFile( exist, (ArtifactItem) iter.next() );
-        }
-    }
-
-    public void assertMarkerFile( boolean val, ArtifactItem item )
-    {
-        UnpackFileMarkerHandler handle = new UnpackFileMarkerHandler( item, mojo.getMarkersDirectory() );
-        try
-        {
-            assertEquals( val, handle.isMarkerSet() );
-        }
-        catch ( MojoExecutionException e )
-        {
-            fail( e.getLongMessage() );
-        }
-    }
-    
-    private void assertUnpacked(boolean unpacked, String fileName)
-    {
-    	File destFile = new File( mojo.getOutputDirectory().getAbsolutePath() , fileName );    	
-    	assertEquals(unpacked, destFile.exists());
-    }
-    
-    /**
-     * This test will validate that only the 1 and 11 files get unpacked
-     * @throws Exception
-     */
-    public void testUnpackIncludesManyFiles()
-		throws Exception
-	{
-    	mojo.setIncludes("**/*1" + UNPACKED_FILE_SUFFIX);
-    	mojo.execute();
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    /**
-     * This test will verify only the 2 file gets unpacked
-     * @throws Exception
-     */
-    public void testUnpackIncludesSingleFile()
-    	throws Exception
-	{
-    	mojo.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX);
-    	mojo.execute();
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    /**
-     * This test will verify all files get unpacked
-     * @throws Exception
-     */
-    public void testUnpackIncludesAllFiles()
-    	throws Exception
-	{
-    	mojo.setIncludes("**/*");
-    	mojo.execute();
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    /**
-     * This test will validate that only the 2 and 3 files get unpacked
-     * @throws Exception
-     */
-    public void testUnpackExcludesManyFiles()
-		throws Exception
-	{
-    	mojo.setExcludes("**/*1" + UNPACKED_FILE_SUFFIX);
-    	mojo.execute();
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    /**
-     * This test will verify only the 1, 11 & 3 files get unpacked
-     * @throws Exception
-     */
-    public void testUnpackExcludesSingleFile()
-    	throws Exception
-	{
-    	mojo.setExcludes("**/test2" + UNPACKED_FILE_SUFFIX);
-    	mojo.execute();
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    /**
-     * This test will verify no files get unpacked
-     * @throws Exception
-     */
-    public void testUnpackExcludesAllFiles()
-    	throws Exception
-	{
-    	mojo.setExcludes("**/*");
-    	mojo.execute();
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    public void testNoIncludeExcludes()
-    	throws Exception
-	{
-    	mojo.execute();
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
-    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
-	}
-    
-    public void testIncludeArtifactItemOverride()
-    	throws Exception
-    {
-    	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
-        ArtifactItem item = stubFactory.getArtifactItem( artifact );
-        item.setIncludes("**/*");
-        ArrayList list = new ArrayList( 1 );
-        list.add( item );
-        mojo.setArtifactItems( list ); 
-        mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX );
-    	mojo.execute();
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
-    }
-    
-    public void testExcludeArtifactItemOverride()
-	throws Exception
-	{
-		Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
-	    ArtifactItem item = stubFactory.getArtifactItem( artifact );
-	    item.setExcludes("**/*");
-	    ArrayList list = new ArrayList( 1 );
-	    list.add( item );
-	    mojo.setArtifactItems( list ); 
-	    mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX );
-		mojo.execute();
-		assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
-		assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
-		assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
-		assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
-	}
-    
-    public void testIncludeArtifactItemMultipleMarker()
-    	throws Exception
-	{
-    	ArrayList list = new ArrayList();
-    	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
-        ArtifactItem item = stubFactory.getArtifactItem( artifact );
-        item.setOverWrite("false");
-        item.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX);        
-        list.add( item );
-        item = stubFactory.getArtifactItem( artifact );
-        item.setOverWrite("false");
-        item.setIncludes("**/test3" + UNPACKED_FILE_SUFFIX);        
-        list.add( item );
-        mojo.setArtifactItems( list ); 
-    	mojo.execute();
-    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
-    	assertMarkerFiles( mojo.getArtifactItems(), true );
-	}
-    
-    public void testIncludeArtifactItemMultipleExecutions()
-    	throws Exception
-	{
-    	ArrayList list = new ArrayList();
-    	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
-        ArtifactItem item = stubFactory.getArtifactItem( artifact );
-        item.setOverWrite("false");
-        item.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX);        
-        list.add( item );
-        item = stubFactory.getArtifactItem( artifact );
-        item.setOverWrite("false");
-        item.setIncludes("**/test3" + UNPACKED_FILE_SUFFIX);        
-        list.add( item );
-        mojo.setArtifactItems( list ); 
-    	mojo.execute();
-    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
-    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
-    	assertMarkerFiles( mojo.getArtifactItems(), true );
-    	    	
-    	//Now run again and make sure the extracted files haven't gotten overwritten
-    	File destFile2 = new File( mojo.getOutputDirectory().getAbsolutePath() , UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
-    	File destFile3 = new File( mojo.getOutputDirectory().getAbsolutePath() , UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
-    	long time = System.currentTimeMillis();
-        time = time - ( time % 1000 );
-        destFile2.setLastModified( time );
-        destFile3.setLastModified( time );
-        assertEquals( time, destFile2.lastModified() );
-        assertEquals( time, destFile3.lastModified() );
-        Thread.sleep( 100 );
-    	mojo.execute();
-    	assertEquals( time, destFile2.lastModified() );
-        assertEquals( time, destFile3.lastModified() );
-	}
-}
+package org.apache.maven.plugin.dependency;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
+import org.apache.maven.plugin.dependency.fromConfiguration.UnpackMojo;
+import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
+import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
+import org.apache.maven.plugin.testing.stubs.StubArtifactCollector;
+import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
+
+public class TestIncludeExcludeUnpackMojo 
+	extends AbstractDependencyMojoTestCase
+{
+	private final String PACKED_FILE = "test.zip";
+	
+	private final String UNPACKED_FILE_PREFIX = "test";
+	private final String UNPACKED_FILE_SUFFIX = ".txt";
+	
+	private final String PACKED_FILE_PATH = "target/test-classes/unit/unpack-dependencies-test/" + PACKED_FILE;
+	
+	UnpackMojo mojo;
+
+    protected void setUp()
+        throws Exception
+    {
+    	// required for mojo lookups to work
+        super.setUp( "unpack", true );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml" );
+        mojo = (UnpackMojo) lookupMojo( "unpack", testPom );
+        mojo.setOutputDirectory( new File( this.testDir, "outputDirectory" ) );
+        // mojo.silent = true;
+
+        // it needs to get the archivermanager
+        //stubFactory.setUnpackableFile( mojo.getArchiverManager() );
+        // i'm using one file repeatedly to archive so I can test the name
+        // programmatically.
+        stubFactory.setSrcFile( new File( getBasedir() + File.separatorChar + PACKED_FILE_PATH ) );
+        Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
+        ArtifactItem item = stubFactory.getArtifactItem( artifact );
+        ArrayList list = new ArrayList( 1 );
+        list.add( item );
+        assertNotNull( mojo );
+        assertNotNull( mojo.getProject() );
+        
+        mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
+        mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
+        mojo.setMarkersDirectory( new File( this.testDir, "markers" ) );
+        mojo.setArtifactCollector( new StubArtifactCollector() );
+        mojo.setArtifactItems( list );
+    }
+    
+    protected void tearDown()
+    {
+        super.tearDown();
+        
+        mojo = null;
+        System.gc();
+    }
+    
+    public void assertMarkerFiles( Collection items, boolean exist )
+    {
+        Iterator iter = items.iterator();
+        while ( iter.hasNext() )
+        {
+            assertMarkerFile( exist, (ArtifactItem) iter.next() );
+        }
+    }
+
+    public void assertMarkerFile( boolean val, ArtifactItem item )
+    {
+        UnpackFileMarkerHandler handle = new UnpackFileMarkerHandler( item, mojo.getMarkersDirectory() );
+        try
+        {
+            assertEquals( val, handle.isMarkerSet() );
+        }
+        catch ( MojoExecutionException e )
+        {
+            fail( e.getLongMessage() );
+        }
+    }
+    
+    private void assertUnpacked(boolean unpacked, String fileName)
+    {
+    	File destFile = new File( mojo.getOutputDirectory().getAbsolutePath() , fileName );    	
+    	assertEquals(unpacked, destFile.exists());
+    }
+    
+    /**
+     * This test will validate that only the 1 and 11 files get unpacked
+     * @throws Exception
+     */
+    public void testUnpackIncludesManyFiles()
+		throws Exception
+	{
+    	mojo.setIncludes("**/*1" + UNPACKED_FILE_SUFFIX);
+    	mojo.execute();
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    /**
+     * This test will verify only the 2 file gets unpacked
+     * @throws Exception
+     */
+    public void testUnpackIncludesSingleFile()
+    	throws Exception
+	{
+    	mojo.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX);
+    	mojo.execute();
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    /**
+     * This test will verify all files get unpacked
+     * @throws Exception
+     */
+    public void testUnpackIncludesAllFiles()
+    	throws Exception
+	{
+    	mojo.setIncludes("**/*");
+    	mojo.execute();
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    /**
+     * This test will validate that only the 2 and 3 files get unpacked
+     * @throws Exception
+     */
+    public void testUnpackExcludesManyFiles()
+		throws Exception
+	{
+    	mojo.setExcludes("**/*1" + UNPACKED_FILE_SUFFIX);
+    	mojo.execute();
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    /**
+     * This test will verify only the 1, 11 & 3 files get unpacked
+     * @throws Exception
+     */
+    public void testUnpackExcludesSingleFile()
+    	throws Exception
+	{
+    	mojo.setExcludes("**/test2" + UNPACKED_FILE_SUFFIX);
+    	mojo.execute();
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    /**
+     * This test will verify no files get unpacked
+     * @throws Exception
+     */
+    public void testUnpackExcludesAllFiles()
+    	throws Exception
+	{
+    	mojo.setExcludes("**/*");
+    	mojo.execute();
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    public void testNoIncludeExcludes()
+    	throws Exception
+	{
+    	mojo.execute();
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX);
+    	assertUnpacked(true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX);
+	}
+    
+    public void testIncludeArtifactItemOverride()
+    	throws Exception
+    {
+    	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
+        ArtifactItem item = stubFactory.getArtifactItem( artifact );
+        item.setIncludes("**/*");
+        ArrayList list = new ArrayList( 1 );
+        list.add( item );
+        mojo.setArtifactItems( list ); 
+        mojo.setIncludes( "**/test2" + UNPACKED_FILE_SUFFIX );
+    	mojo.execute();
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
+    }
+    
+    public void testExcludeArtifactItemOverride()
+	throws Exception
+	{
+		Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
+	    ArtifactItem item = stubFactory.getArtifactItem( artifact );
+	    item.setExcludes("**/*");
+	    ArrayList list = new ArrayList( 1 );
+	    list.add( item );
+	    mojo.setArtifactItems( list ); 
+	    mojo.setExcludes( "**/test2" + UNPACKED_FILE_SUFFIX );
+		mojo.execute();
+		assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
+		assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
+		assertUnpacked( false, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
+		assertUnpacked( false, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
+	}
+    
+    public void testIncludeArtifactItemMultipleMarker()
+    	throws Exception
+	{
+    	ArrayList list = new ArrayList();
+    	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
+        ArtifactItem item = stubFactory.getArtifactItem( artifact );
+        item.setOverWrite("false");
+        item.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX);        
+        list.add( item );
+        item = stubFactory.getArtifactItem( artifact );
+        item.setOverWrite("false");
+        item.setIncludes("**/test3" + UNPACKED_FILE_SUFFIX);        
+        list.add( item );
+        mojo.setArtifactItems( list ); 
+    	mojo.execute();
+    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
+    	assertMarkerFiles( mojo.getArtifactItems(), true );
+	}
+    
+    public void testIncludeArtifactItemMultipleExecutions()
+    	throws Exception
+	{
+    	ArrayList list = new ArrayList();
+    	Artifact artifact = stubFactory.createArtifact( "test", "test", "1.0", Artifact.SCOPE_COMPILE, "jar", null );
+        ArtifactItem item = stubFactory.getArtifactItem( artifact );
+        item.setOverWrite("false");
+        item.setIncludes("**/test2" + UNPACKED_FILE_SUFFIX);        
+        list.add( item );
+        item = stubFactory.getArtifactItem( artifact );
+        item.setOverWrite("false");
+        item.setIncludes("**/test3" + UNPACKED_FILE_SUFFIX);        
+        list.add( item );
+        mojo.setArtifactItems( list ); 
+    	mojo.execute();
+    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 1 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( false, UNPACKED_FILE_PREFIX + 11 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
+    	assertUnpacked( true, UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
+    	assertMarkerFiles( mojo.getArtifactItems(), true );
+    	    	
+    	//Now run again and make sure the extracted files haven't gotten overwritten
+    	File destFile2 = new File( mojo.getOutputDirectory().getAbsolutePath() , UNPACKED_FILE_PREFIX + 2 + UNPACKED_FILE_SUFFIX );
+    	File destFile3 = new File( mojo.getOutputDirectory().getAbsolutePath() , UNPACKED_FILE_PREFIX + 3 + UNPACKED_FILE_SUFFIX );
+    	long time = System.currentTimeMillis();
+        time = time - ( time % 1000 );
+        destFile2.setLastModified( time );
+        destFile3.setLastModified( time );
+        assertEquals( time, destFile2.lastModified() );
+        assertEquals( time, destFile3.lastModified() );
+        Thread.sleep( 100 );
+    	mojo.execute();
+    	assertEquals( time, destFile2.lastModified() );
+        assertEquals( time, destFile3.lastModified() );
+	}
+}

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestIncludeExcludeUnpackMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Id

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java?rev=612280&r1=612279&r2=612280&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java Tue Jan 15 14:55:37 2008
@@ -1,337 +1,337 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugin.dependency.its;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.invoker.InvocationRequest;
-import org.apache.maven.shared.invoker.InvocationResult;
-import org.apache.maven.shared.test.plugin.BuildTool;
-import org.apache.maven.shared.test.plugin.PluginTestTool;
-import org.apache.maven.shared.test.plugin.ProjectTool;
-import org.apache.maven.shared.test.plugin.TestToolsException;
-import org.codehaus.classworlds.ClassRealm;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- *         Copied from the Eclipse
- *         AbstractEclipsePluginTestCase v2.4
- * @version $Id: AbstractDependencyPluginITCase.java 556442
- *          2007-07-15 20:20:23Z dantran $
- */
-public abstract class AbstractDependencyPluginITCase
-    extends PlexusTestCase
-{
-
-    private BuildTool buildTool;
-
-    private ProjectTool projectTool;
-
-    /**
-     * Test repository directory.
-     */
-    protected static File localRepositoryDirectory = getTestFile( "target/test-classes/m2repo" );
-
-    /**
-     * Pom File
-     */
-    protected static File PomFile = new File( getBasedir(), "pom.xml" );
-
-    /**
-     * Group-Id for running test builds.
-     */
-    protected static final String GROUP_ID = "org.apache.maven.plugins";
-
-    /**
-     * Artifact-Id for running test builds.
-     */
-    protected static final String ARTIFACT_ID = "maven-dependency-plugin";
-
-    /**
-     * Version under which the plugin was installed to the
-     * test-time local repository for running test builds.
-     */
-    protected static final String VERSION = "test";
-
-    private static final String BUILD_OUTPUT_DIRECTORY = "target/surefire-reports/build-output";
-
-    private static boolean installed = false;
-
-    /**
-     * @see org.codehaus.plexus.PlexusTestCase#setUp()
-     */
-    protected void setUp ()
-        throws Exception
-    {
-        if ( !installed )
-        {
-            System.out
-                .println( "*** Running test builds; output will be directed to: " + BUILD_OUTPUT_DIRECTORY + "\n" );
-        }
-
-        super.setUp();
-
-        buildTool = (BuildTool) lookup( BuildTool.ROLE, "default" );
-
-        projectTool = (ProjectTool) lookup( ProjectTool.ROLE, "default" );
-
-        String mavenHome = System.getProperty( "maven.home" );
-
-        // maven.home is set by surefire when the test is
-        // run with maven, but better make the test run in
-        // IDEs without
-        // the need of additional properties
-        if ( mavenHome == null )
-        {
-            String path = System.getProperty( "java.library.path" );
-            String[] paths = StringUtils.split( path, System.getProperty( "path.separator" ) );
-            for ( int j = 0; j < paths.length; j++ )
-            {
-                String pt = paths[j];
-                if ( new File( pt, "mvn" ).exists() )
-                {
-                    System.setProperty( "maven.home", new File( pt ).getAbsoluteFile().getParent() );
-                    break;
-                }
-
-            }
-        }
-
-        System.setProperty( "MAVEN_TERMINATE_CMD", "on" );
-
-        synchronized ( AbstractDependencyPluginITCase.class )
-        {
-            if ( !installed )
-            {
-                PluginTestTool pluginTestTool = (PluginTestTool) lookup( PluginTestTool.ROLE, "default" );
-
-                localRepositoryDirectory = pluginTestTool
-                    .preparePluginForUnitTestingWithMavenBuilds( PomFile, "test", localRepositoryDirectory );
-
-                System.out.println( "*** Installed test-version of the Dependency plugin to: "
-                    + localRepositoryDirectory + "\n" );
-
-                installed = true;
-            }
-        }
-
-    }
-
-    /**
-     * @see org.codehaus.plexus.PlexusTestCase#tearDown()
-     */
-    protected void tearDown ()
-        throws Exception
-    {
-        super.tearDown();
-
-        List containers = new ArrayList();
-
-        containers.add( getContainer() );
-
-        for ( Iterator iter = containers.iterator(); iter.hasNext(); )
-        {
-            PlexusContainer container = (PlexusContainer) iter.next();
-
-            if ( container != null )
-            {
-                container.dispose();
-
-                ClassRealm realm = container.getContainerRealm();
-
-                if ( realm != null )
-                {
-                    realm.getWorld().disposeRealm( realm.getId() );
-                }
-            }
-        }
-    }
-
-    /**
-     * Execute the plugin with no properties
-     * 
-     * @param projectName project directory
-     * @param goalList comma separated list of goals to
-     *            execute
-     * @throws Exception any exception generated during test
-     */
-    protected void testProject ( String projectName, String goalList )
-        throws Exception
-    {
-        Properties props = new Properties();
-        testProject( projectName, props, goalList );
-    }
-
-    /**
-     * Execute the plugin.
-     * 
-     * @param projectName project directory
-     * @param properties additional properties
-     * @param goalList comma separated list of goals to
-     *            execute
-     * @throws Exception any exception generated during test
-     */
-    protected void testProject ( String projectName, Properties properties, String goalList )
-        throws Exception
-    {
-        File theBasedir = getTestFile( "target/test-classes/its/" + projectName );
-
-        File pom = new File( theBasedir, "pom.xml" );
-
-        String[] goal = goalList.split( "," );
-
-        List goals = new ArrayList();
-
-        for ( int i = 0; i < goal.length; i++ )
-        {
-            goals.add( goal[i] );
-        }
-
-        executeMaven( pom, properties, goals );
-
-        // MavenProject project = readProject( pom );
-
-        /*
-         * String outputDirPath = IdeUtils.getPluginSetting(
-         * project, "maven-dependency-plugin", "outputDir",
-         * null ); File outputDir; File projectOutputDir =
-         * basedir;
-         * 
-         * if ( outputDirPath == null ) { outputDir =
-         * basedir; } else { outputDir = new File( basedir,
-         * outputDirPath ); outputDir.mkdirs();
-         * projectOutputDir = new File( outputDir,
-         * project.getArtifactId() ); }
-         */
-    }
-
-    protected File getOutputDirectory ( String projectName )
-    {
-        return getTestFile( "target/test-classes/projects/" + projectName );
-    }
-
-    protected void executeMaven ( File pom, Properties properties, List goals )
-        throws TestToolsException, ExecutionFailedException
-    {
-        executeMaven( pom, properties, goals, true );
-    }
-
-    protected void executeMaven ( File pom, Properties properties, List goals, boolean switchLocalRepo )
-        throws TestToolsException, ExecutionFailedException
-    {
-        // insert the test property to activate the test
-        // profile
-        properties.setProperty( "test", "true" );
-        new File( BUILD_OUTPUT_DIRECTORY ).mkdirs();
-
-        NullPointerException npe = new NullPointerException();
-        StackTraceElement[] trace = npe.getStackTrace();
-
-        File buildLog = null;
-
-        for ( int i = 0; i < trace.length; i++ )
-        {
-            StackTraceElement element = trace[i];
-
-            String methodName = element.getMethodName();
-
-            if ( methodName.startsWith( "test" ) && !methodName.equals( "testProject" ) )
-            {
-                String classname = element.getClassName();
-
-                buildLog = new File( BUILD_OUTPUT_DIRECTORY, classname + "_" + element.getMethodName() + ".build.log" );
-
-                break;
-            }
-        }
-
-        if ( buildLog == null )
-        {
-            buildLog = new File( BUILD_OUTPUT_DIRECTORY, "unknown.build.log" );
-        }
-
-        InvocationRequest request = buildTool.createBasicInvocationRequest( pom, properties, goals, buildLog );
-        request.setUpdateSnapshots( false );
-        request.setShowErrors( true );
-
-        request.setDebug( true );
-
-        if ( switchLocalRepo )
-        {
-            request.setLocalRepositoryDirectory( localRepositoryDirectory );
-        }
-
-        InvocationResult result = buildTool.executeMaven( request );
-
-        if ( result.getExitCode() != 0 )
-        {
-            String buildLogUrl = buildLog.getAbsolutePath();
-
-            try
-            {
-                
-                buildLogUrl = buildLog.toURI().toURL().toExternalForm();
-            }
-            catch ( MalformedURLException e )
-            {
-            }
-
-            throw new ExecutionFailedException( "Failed to execute build.\nPOM: " + pom + "\nGoals: "
-                + StringUtils.join( goals.iterator(), ", " ) + "\nExit Code: " + result.getExitCode() + "\nError: "
-                + result.getExecutionException() + "\nBuild Log: " + buildLogUrl + "\n", result );
-        }
-    }
-
-    protected MavenProject readProject ( File pom )
-        throws TestToolsException
-    {
-        return projectTool.readProject( pom, localRepositoryDirectory );
-    }
-
-    protected String getPluginCLISpecification ()
-    {
-        String pluginSpec = GROUP_ID + ":" + ARTIFACT_ID + ":";
-
-        // String pluginVersion = System.getProperty(
-        // "pluginVersion" );
-        //        
-        // if ( pluginVersion != null )
-        // {
-        // pluginSpec += pluginVersion + ":";
-        // }
-        //
-        // System.out.println( "\n\nUsing Eclipse plugin
-        // version: " + pluginVersion + "\n\n" );
-
-        // try using the test-version installed during
-        // setUp()
-        pluginSpec += VERSION + ":";
-
-        return pluginSpec;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugin.dependency.its;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.invoker.InvocationRequest;
+import org.apache.maven.shared.invoker.InvocationResult;
+import org.apache.maven.shared.test.plugin.BuildTool;
+import org.apache.maven.shared.test.plugin.PluginTestTool;
+import org.apache.maven.shared.test.plugin.ProjectTool;
+import org.apache.maven.shared.test.plugin.TestToolsException;
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
+ *         Copied from the Eclipse
+ *         AbstractEclipsePluginTestCase v2.4
+ * @version $Id: AbstractDependencyPluginITCase.java 556442
+ *          2007-07-15 20:20:23Z dantran $
+ */
+public abstract class AbstractDependencyPluginITCase
+    extends PlexusTestCase
+{
+
+    private BuildTool buildTool;
+
+    private ProjectTool projectTool;
+
+    /**
+     * Test repository directory.
+     */
+    protected static File localRepositoryDirectory = getTestFile( "target/test-classes/m2repo" );
+
+    /**
+     * Pom File
+     */
+    protected static File PomFile = new File( getBasedir(), "pom.xml" );
+
+    /**
+     * Group-Id for running test builds.
+     */
+    protected static final String GROUP_ID = "org.apache.maven.plugins";
+
+    /**
+     * Artifact-Id for running test builds.
+     */
+    protected static final String ARTIFACT_ID = "maven-dependency-plugin";
+
+    /**
+     * Version under which the plugin was installed to the
+     * test-time local repository for running test builds.
+     */
+    protected static final String VERSION = "test";
+
+    private static final String BUILD_OUTPUT_DIRECTORY = "target/surefire-reports/build-output";
+
+    private static boolean installed = false;
+
+    /**
+     * @see org.codehaus.plexus.PlexusTestCase#setUp()
+     */
+    protected void setUp ()
+        throws Exception
+    {
+        if ( !installed )
+        {
+            System.out
+                .println( "*** Running test builds; output will be directed to: " + BUILD_OUTPUT_DIRECTORY + "\n" );
+        }
+
+        super.setUp();
+
+        buildTool = (BuildTool) lookup( BuildTool.ROLE, "default" );
+
+        projectTool = (ProjectTool) lookup( ProjectTool.ROLE, "default" );
+
+        String mavenHome = System.getProperty( "maven.home" );
+
+        // maven.home is set by surefire when the test is
+        // run with maven, but better make the test run in
+        // IDEs without
+        // the need of additional properties
+        if ( mavenHome == null )
+        {
+            String path = System.getProperty( "java.library.path" );
+            String[] paths = StringUtils.split( path, System.getProperty( "path.separator" ) );
+            for ( int j = 0; j < paths.length; j++ )
+            {
+                String pt = paths[j];
+                if ( new File( pt, "mvn" ).exists() )
+                {
+                    System.setProperty( "maven.home", new File( pt ).getAbsoluteFile().getParent() );
+                    break;
+                }
+
+            }
+        }
+
+        System.setProperty( "MAVEN_TERMINATE_CMD", "on" );
+
+        synchronized ( AbstractDependencyPluginITCase.class )
+        {
+            if ( !installed )
+            {
+                PluginTestTool pluginTestTool = (PluginTestTool) lookup( PluginTestTool.ROLE, "default" );
+
+                localRepositoryDirectory = pluginTestTool
+                    .preparePluginForUnitTestingWithMavenBuilds( PomFile, "test", localRepositoryDirectory );
+
+                System.out.println( "*** Installed test-version of the Dependency plugin to: "
+                    + localRepositoryDirectory + "\n" );
+
+                installed = true;
+            }
+        }
+
+    }
+
+    /**
+     * @see org.codehaus.plexus.PlexusTestCase#tearDown()
+     */
+    protected void tearDown ()
+        throws Exception
+    {
+        super.tearDown();
+
+        List containers = new ArrayList();
+
+        containers.add( getContainer() );
+
+        for ( Iterator iter = containers.iterator(); iter.hasNext(); )
+        {
+            PlexusContainer container = (PlexusContainer) iter.next();
+
+            if ( container != null )
+            {
+                container.dispose();
+
+                ClassRealm realm = container.getContainerRealm();
+
+                if ( realm != null )
+                {
+                    realm.getWorld().disposeRealm( realm.getId() );
+                }
+            }
+        }
+    }
+
+    /**
+     * Execute the plugin with no properties
+     * 
+     * @param projectName project directory
+     * @param goalList comma separated list of goals to
+     *            execute
+     * @throws Exception any exception generated during test
+     */
+    protected void testProject ( String projectName, String goalList )
+        throws Exception
+    {
+        Properties props = new Properties();
+        testProject( projectName, props, goalList );
+    }
+
+    /**
+     * Execute the plugin.
+     * 
+     * @param projectName project directory
+     * @param properties additional properties
+     * @param goalList comma separated list of goals to
+     *            execute
+     * @throws Exception any exception generated during test
+     */
+    protected void testProject ( String projectName, Properties properties, String goalList )
+        throws Exception
+    {
+        File theBasedir = getTestFile( "target/test-classes/its/" + projectName );
+
+        File pom = new File( theBasedir, "pom.xml" );
+
+        String[] goal = goalList.split( "," );
+
+        List goals = new ArrayList();
+
+        for ( int i = 0; i < goal.length; i++ )
+        {
+            goals.add( goal[i] );
+        }
+
+        executeMaven( pom, properties, goals );
+
+        // MavenProject project = readProject( pom );
+
+        /*
+         * String outputDirPath = IdeUtils.getPluginSetting(
+         * project, "maven-dependency-plugin", "outputDir",
+         * null ); File outputDir; File projectOutputDir =
+         * basedir;
+         * 
+         * if ( outputDirPath == null ) { outputDir =
+         * basedir; } else { outputDir = new File( basedir,
+         * outputDirPath ); outputDir.mkdirs();
+         * projectOutputDir = new File( outputDir,
+         * project.getArtifactId() ); }
+         */
+    }
+
+    protected File getOutputDirectory ( String projectName )
+    {
+        return getTestFile( "target/test-classes/projects/" + projectName );
+    }
+
+    protected void executeMaven ( File pom, Properties properties, List goals )
+        throws TestToolsException, ExecutionFailedException
+    {
+        executeMaven( pom, properties, goals, true );
+    }
+
+    protected void executeMaven ( File pom, Properties properties, List goals, boolean switchLocalRepo )
+        throws TestToolsException, ExecutionFailedException
+    {
+        // insert the test property to activate the test
+        // profile
+        properties.setProperty( "test", "true" );
+        new File( BUILD_OUTPUT_DIRECTORY ).mkdirs();
+
+        NullPointerException npe = new NullPointerException();
+        StackTraceElement[] trace = npe.getStackTrace();
+
+        File buildLog = null;
+
+        for ( int i = 0; i < trace.length; i++ )
+        {
+            StackTraceElement element = trace[i];
+
+            String methodName = element.getMethodName();
+
+            if ( methodName.startsWith( "test" ) && !methodName.equals( "testProject" ) )
+            {
+                String classname = element.getClassName();
+
+                buildLog = new File( BUILD_OUTPUT_DIRECTORY, classname + "_" + element.getMethodName() + ".build.log" );
+
+                break;
+            }
+        }
+
+        if ( buildLog == null )
+        {
+            buildLog = new File( BUILD_OUTPUT_DIRECTORY, "unknown.build.log" );
+        }
+
+        InvocationRequest request = buildTool.createBasicInvocationRequest( pom, properties, goals, buildLog );
+        request.setUpdateSnapshots( false );
+        request.setShowErrors( true );
+
+        request.setDebug( true );
+
+        if ( switchLocalRepo )
+        {
+            request.setLocalRepositoryDirectory( localRepositoryDirectory );
+        }
+
+        InvocationResult result = buildTool.executeMaven( request );
+
+        if ( result.getExitCode() != 0 )
+        {
+            String buildLogUrl = buildLog.getAbsolutePath();
+
+            try
+            {
+                
+                buildLogUrl = buildLog.toURI().toURL().toExternalForm();
+            }
+            catch ( MalformedURLException e )
+            {
+            }
+
+            throw new ExecutionFailedException( "Failed to execute build.\nPOM: " + pom + "\nGoals: "
+                + StringUtils.join( goals.iterator(), ", " ) + "\nExit Code: " + result.getExitCode() + "\nError: "
+                + result.getExecutionException() + "\nBuild Log: " + buildLogUrl + "\n", result );
+        }
+    }
+
+    protected MavenProject readProject ( File pom )
+        throws TestToolsException
+    {
+        return projectTool.readProject( pom, localRepositoryDirectory );
+    }
+
+    protected String getPluginCLISpecification ()
+    {
+        String pluginSpec = GROUP_ID + ":" + ARTIFACT_ID + ":";
+
+        // String pluginVersion = System.getProperty(
+        // "pluginVersion" );
+        //        
+        // if ( pluginVersion != null )
+        // {
+        // pluginSpec += pluginVersion + ":";
+        // }
+        //
+        // System.out.println( "\n\nUsing Eclipse plugin
+        // version: " + pluginVersion + "\n\n" );
+
+        // try using the test-version installed during
+        // setUp()
+        pluginSpec += VERSION + ":";
+
+        return pluginSpec;
+    }
+}

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/AbstractDependencyPluginITCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Id

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java?rev=612280&r1=612279&r2=612280&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java Tue Jan 15 14:55:37 2008
@@ -1,77 +1,77 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugin.dependency.its;
-
-/**
- * This class executes the IT tests. The setup will create a pom-test.xml from the plugin pom. The version is changed to
- * "test" and the tests themselves turned off to avoid an infinite loop. The test version of the plugin is then built
- * and installed to a new temporary local repo used to execute the tests. This only occurs once for the suite of tests.
- * Each test below just uses the tools to execute Maven on the named project with the passed in goals.
- * 
- * @author <a href="mailto:brianf@apache.org">Brian Fox</a> Copied from the Eclipse AbstractEclipsePluginTestCase v2.4
- * @version $Id: DependencyPluginTest.java 554290 2007-07-08 01:25:12Z brianf $
- */
-public class DependencyPluginTest
-    extends AbstractDependencyPluginITCase
-{
-    protected void setUp()
-        throws Exception
-    {
-        // super.setUp();
-    }
-
-    protected void tearDown()
-        throws Exception
-    {
-
-    }
-
-    /**
-     * Test that build failures are reported. Simple Harness test essentially
-     */
-    public void testHarness()
-    {
-        /*
-         * try { testProject( "check-harness", "install" ); fail("Expected an exception reporting a build failure
-         * here"); } catch ( Exception e ) { //caught expected exceptions }
-         */
-    }
-
-    /**
-     * Test Resolve Mojo. Simple Harness test essentially
-     * 
-     * @throws Exception any exception thrown during test
-     */
-    public void testSibling()
-        throws Exception
-    {
-        // testProject( "siblingReference", "compile" );
-    }
-
-    /**
-     * Test Resolve Mojo. Simple Harness test essentially
-     * 
-     * @throws Exception any exception thrown during test
-     */
-    public void testResolve()
-        throws Exception
-    {
-        // testProject( "resolve", "dependency:resolve" );
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugin.dependency.its;
+
+/**
+ * This class executes the IT tests. The setup will create a pom-test.xml from the plugin pom. The version is changed to
+ * "test" and the tests themselves turned off to avoid an infinite loop. The test version of the plugin is then built
+ * and installed to a new temporary local repo used to execute the tests. This only occurs once for the suite of tests.
+ * Each test below just uses the tools to execute Maven on the named project with the passed in goals.
+ * 
+ * @author <a href="mailto:brianf@apache.org">Brian Fox</a> Copied from the Eclipse AbstractEclipsePluginTestCase v2.4
+ * @version $Id$
+ */
+public class DependencyPluginTest
+    extends AbstractDependencyPluginITCase
+{
+    protected void setUp()
+        throws Exception
+    {
+        // super.setUp();
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+
+    }
+
+    /**
+     * Test that build failures are reported. Simple Harness test essentially
+     */
+    public void testHarness()
+    {
+        /*
+         * try { testProject( "check-harness", "install" ); fail("Expected an exception reporting a build failure
+         * here"); } catch ( Exception e ) { //caught expected exceptions }
+         */
+    }
+
+    /**
+     * Test Resolve Mojo. Simple Harness test essentially
+     * 
+     * @throws Exception any exception thrown during test
+     */
+    public void testSibling()
+        throws Exception
+    {
+        // testProject( "siblingReference", "compile" );
+    }
+
+    /**
+     * Test Resolve Mojo. Simple Harness test essentially
+     * 
+     * @throws Exception any exception thrown during test
+     */
+    public void testResolve()
+        throws Exception
+    {
+        // testProject( "resolve", "dependency:resolve" );
+    }
+}

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/DependencyPluginTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Id

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java?rev=612280&r1=612279&r2=612280&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java Tue Jan 15 14:55:37 2008
@@ -1,49 +1,49 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugin.dependency.its;
-
-import org.apache.maven.shared.invoker.InvocationResult;
-import org.apache.maven.shared.invoker.MavenInvocationException;
-
-public class ExecutionFailedException
-    extends Exception
-{
-
-    private static final long serialVersionUID = 1L;
-
-    private InvocationResult result;
-
-    public ExecutionFailedException( String message, MavenInvocationException cause )
-    {
-        super( message + " (Maven invoker threw an exception.)", cause );
-    }
-
-    public ExecutionFailedException( String message, InvocationResult result )
-    {
-        super( message + " (Resulting exit code: " + result.getExitCode() + ")" );
-
-        this.result = result;
-    }
-
-    public InvocationResult getInvocationResult()
-    {
-        return result;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugin.dependency.its;
+
+import org.apache.maven.shared.invoker.InvocationResult;
+import org.apache.maven.shared.invoker.MavenInvocationException;
+
+public class ExecutionFailedException
+    extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private InvocationResult result;
+
+    public ExecutionFailedException( String message, MavenInvocationException cause )
+    {
+        super( message + " (Maven invoker threw an exception.)", cause );
+    }
+
+    public ExecutionFailedException( String message, InvocationResult result )
+    {
+        super( message + " (Resulting exit code: " + result.getExitCode() + ")" );
+
+        this.result = result;
+    }
+
+    public InvocationResult getInvocationResult()
+    {
+        return result;
+    }
+
+}

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/its/ExecutionFailedException.java
------------------------------------------------------------------------------
    svn:keywords = Date Id

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java?rev=612280&r1=612279&r2=612280&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java Tue Jan 15 14:55:37 2008
@@ -1,45 +1,45 @@
-package org.apache.maven.plugin.dependency.testUtils.stubs;
-
-import java.io.File;
-
-import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
-import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
-import org.codehaus.plexus.util.StringUtils;
-
-public class StubUnpackFileMarkerHandler
-	extends UnpackFileMarkerHandler
-{
-	public StubUnpackFileMarkerHandler( ArtifactItem artifactItem, File markerFilesDirectory )
-    {
-        super( artifactItem, markerFilesDirectory );
-    }
-	
-	protected File getMarkerFile()
-    {
-		File markerFile = null;
-		if ( this.artifactItem == null 
-			|| ( StringUtils.isEmpty( this.artifactItem.getIncludes() )
-			&&	StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) )
-		{
-			markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + ".marker" );
-		}
-		else
-		{
-			int includeExcludeHash = 0;
-			
-			if ( StringUtils.isNotEmpty( this.artifactItem.getIncludes() ) )
-			{
-				includeExcludeHash += this.artifactItem.getIncludes().hashCode();
-			}
-			
-			if ( StringUtils.isNotEmpty( this.artifactItem.getExcludes() ) )
-			{
-				includeExcludeHash += this.artifactItem.getExcludes().hashCode();
-			}
-			
-			markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash );
-		}
-		
-		return markerFile;
-    }
-}
+package org.apache.maven.plugin.dependency.testUtils.stubs;
+
+import java.io.File;
+
+import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
+import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
+import org.codehaus.plexus.util.StringUtils;
+
+public class StubUnpackFileMarkerHandler
+	extends UnpackFileMarkerHandler
+{
+	public StubUnpackFileMarkerHandler( ArtifactItem artifactItem, File markerFilesDirectory )
+    {
+        super( artifactItem, markerFilesDirectory );
+    }
+	
+	protected File getMarkerFile()
+    {
+		File markerFile = null;
+		if ( this.artifactItem == null 
+			|| ( StringUtils.isEmpty( this.artifactItem.getIncludes() )
+			&&	StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) )
+		{
+			markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + ".marker" );
+		}
+		else
+		{
+			int includeExcludeHash = 0;
+			
+			if ( StringUtils.isNotEmpty( this.artifactItem.getIncludes() ) )
+			{
+				includeExcludeHash += this.artifactItem.getIncludes().hashCode();
+			}
+			
+			if ( StringUtils.isNotEmpty( this.artifactItem.getExcludes() ) )
+			{
+				includeExcludeHash += this.artifactItem.getExcludes().hashCode();
+			}
+			
+			markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash );
+		}
+		
+		return markerFile;
+    }
+}

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/testUtils/stubs/StubUnpackFileMarkerHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Id

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java?rev=612280&r1=612279&r2=612280&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java Tue Jan 15 14:55:37 2008
@@ -1,264 +1,264 @@
-package org.apache.maven.plugin.dependency.utils.markers;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
-import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory;
-import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
-import org.apache.maven.plugin.dependency.testUtils.stubs.StubUnpackFileMarkerHandler;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugin.testing.SilentLog;
-
-public class TestUnpackMarkerFileHandler
-	extends AbstractMojoTestCase
-{
-	List artifactItems = new ArrayList();
-
-    Log log = new SilentLog();
-
-    File outputFolder;
-    
-    protected File testDir;
-    
-    protected DependencyArtifactStubFactory stubFactory;
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        
-        testDir = new File( getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar
-                + "unpack-markers" + File.separatorChar );
-        DependencyTestUtils.removeDirectory( testDir );
-        assertFalse( testDir.exists() );
-
-        stubFactory = new DependencyArtifactStubFactory( this.testDir, false );
-        Artifact artifact = stubFactory.createArtifact( "test", "test", "1" );
-        ArtifactItem artifactItem = stubFactory.getArtifactItem( artifact );
-        artifactItems.add( stubFactory.getArtifactItem( stubFactory.createArtifact( "test", "test", "1" ) ) );
-        artifact = stubFactory.createArtifact("test2", "test2", "2");
-        artifactItem = new ArtifactItem( artifact );
-        artifactItem.setIncludes( "**/*.xml" );
-        artifactItems.add( artifactItem );
-        artifact = stubFactory.createArtifact("test3", "test3", "3");
-        artifactItem = new ArtifactItem( artifact );
-        artifactItem.setExcludes( "**/*.class" );
-        artifactItems.add( artifactItem );
-        artifact = stubFactory.createArtifact("test4", "test4", "4");
-        artifactItem = new ArtifactItem( artifact );
-        artifactItem.setIncludes( "**/*.xml" );
-        artifactItem.setExcludes( "**/*.class" );
-        artifactItems.add( artifactItem );
-
-        outputFolder = new File( "target/markers/" );
-        DependencyTestUtils.removeDirectory( this.outputFolder );
-        assertFalse( outputFolder.exists() );
-    }
-
-    protected void tearDown()
-        throws IOException
-    {
-        DependencyTestUtils.removeDirectory( this.outputFolder );
-    }
-
-    /**
-     * 
-     * Assert that default functionallity still exists
-     * 
-     */
-    
-    public void testSetMarker()
-        throws MojoExecutionException
-    {
-        UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ),
-                                                                         this.outputFolder );
-        assertFalse( handler.isMarkerSet() );
-        handler.setMarker();
-        assertTrue( handler.isMarkerSet() );
-        handler.clearMarker();
-        assertFalse( handler.isMarkerSet() );
-
-        handler.setMarker();
-        assertTrue( handler.isMarkerSet() );
-        handler.setMarker();
-        assertTrue( handler.isMarkerSet() );
-
-        handler.clearMarker();
-        assertFalse( handler.isMarkerSet() );
-        handler.clearMarker();
-        assertFalse( handler.isMarkerSet() );
-    }
-
-    public void testMarkerFile()
-        throws MojoExecutionException, IOException
-    {
-    	UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ),
-                                                                         this.outputFolder );
-
-        File handle = handler.getMarkerFile();
-        assertFalse( handle.exists() );
-        assertFalse( handler.isMarkerSet() );
-
-        handler.setMarker();
-        assertTrue( handler.isMarkerSet() );
-        assertTrue( handle.exists() );
-
-        handle.delete();
-        assertFalse( handler.isMarkerSet() );
-
-        handle.createNewFile();
-        assertTrue( handler.isMarkerSet() );
-
-        handler.clearMarker();
-        assertFalse( handle.exists() );
-    }
-
-    public void testMarkerTimeStamp()
-        throws MojoExecutionException, IOException, InterruptedException
-    {
-        File theFile = new File( outputFolder, "theFile.jar" );
-        outputFolder.mkdirs();
-        theFile.createNewFile();
-        ArtifactItem theArtifactItem = (ArtifactItem) artifactItems.get( 0 );
-        Artifact theArtifact = theArtifactItem.getArtifact();
-        theArtifact.setFile( theFile );
-        UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( theArtifactItem, this.outputFolder );
-        assertFalse( handler.isMarkerSet() );
-        // if the marker is not set, assume it is infinately older than the
-        // artifact.
-        assertTrue( handler.isMarkerOlder( theArtifact ) );
-        handler.setMarker();
-        assertFalse( handler.isMarkerOlder( theArtifact ) );
-
-        theFile.setLastModified( theFile.lastModified() + 60000 );
-        assertTrue( handler.isMarkerOlder( theArtifact ) );
-
-        theFile.delete();
-        handler.clearMarker();
-        assertFalse( handler.isMarkerSet() );
-    }
-
-    public void testMarkerFileException()
-    {
-        // this stub wraps the file with an object to throw exceptions
-        StubUnpackFileMarkerHandler handler = new StubUnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ),
-                                                                                 this.outputFolder );
-        try
-        {
-            handler.setMarker();
-            fail( "Expected an Exception here" );
-        }
-        catch ( MojoExecutionException e )
-        {
-
-        }
-    }
-
-    public void testGetterSetter()
-    {
-        UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( null, null );
-        assertTrue( handler.getArtifactItem() == null );
-        assertTrue( handler.getArtifact() == null );
-        handler.setArtifactItem( (ArtifactItem) artifactItems.get( 0 ) );
-        assertSame( artifactItems.get( 0 ), handler.getArtifactItem() );
-        assertSame( ((ArtifactItem) artifactItems.get( 0 )).getArtifact(), handler.getArtifact() );
-
-        assertTrue( handler.getMarkerFilesDirectory() == null );
-        handler.setMarkerFilesDirectory( outputFolder );
-        assertSame( outputFolder, handler.getMarkerFilesDirectory() );
-    }
-
-    public void testNullParent()
-        throws MojoExecutionException
-    {
-        // the parent isn't set so this will create the marker in the local
-        // folder. We must clear the
-        // marker to avoid leaving test droppings in root.
-    	UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( null, null );
-        handler.setArtifactItem( (ArtifactItem) artifactItems.get( 0 ) );
-        handler.setMarker();
-        assertTrue( handler.isMarkerSet() );
-        handler.clearMarker();
-        assertFalse( handler.isMarkerSet() );
-    }
-    
-    public void testIncludesMarker()
-    	throws MojoExecutionException, IOException
-	{
-    	UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 1 ), outputFolder );
-    	File handle = handler.getMarkerFile();
-        assertFalse( handle.exists() );
-        assertFalse( handler.isMarkerSet() );
-
-        handler.setMarker();
-        assertTrue( handler.isMarkerSet() );
-        assertTrue( handle.exists() );
-        String hashCode = "" + ( 0 + "**/*.xml".hashCode() );
-        assertTrue( handle.getName().indexOf( hashCode ) > -1 );
-
-        handle.delete();
-        assertFalse( handler.isMarkerSet() );
-
-        handle.createNewFile();
-        assertTrue( handler.isMarkerSet() );
-
-        handler.clearMarker();
-        assertFalse( handle.exists() );
-	}
-    
-    public void testExcludesMarker()
-		throws MojoExecutionException, IOException
-	{
-		UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 2 ), outputFolder );
-		File handle = handler.getMarkerFile();
-	    assertFalse( handle.exists() );
-	    assertFalse( handler.isMarkerSet() );
-	
-	    handler.setMarker();
-	    assertTrue( handler.isMarkerSet() );
-	    assertTrue( handle.exists() );
-	    String hashCode = "" + ( 0 + "**/*.class".hashCode() );
-	    assertTrue( handle.getName().indexOf( hashCode ) > -1 );
-	
-	    handle.delete();
-	    assertFalse( handler.isMarkerSet() );
-	
-	    handle.createNewFile();
-	    assertTrue( handler.isMarkerSet() );
-	
-	    handler.clearMarker();
-	    assertFalse( handle.exists() );
-	}
-    
-    public void testIncludesExcludesMarker()
-		throws MojoExecutionException, IOException
-	{
-		UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 3 ), outputFolder );
-		File handle = handler.getMarkerFile();
-	    assertFalse( handle.exists() );
-	    assertFalse( handler.isMarkerSet() );
-	
-	    handler.setMarker();
-	    assertTrue( handler.isMarkerSet() );
-	    assertTrue( handle.exists() );
-	    String hashCode = "" + ( 0 + "**/*.class".hashCode() + "**/*.xml".hashCode() );
-	    assertTrue( handle.getName().indexOf( hashCode ) > -1 );
-	
-	    handle.delete();
-	    assertFalse( handler.isMarkerSet() );
-	
-	    handle.createNewFile();
-	    assertTrue( handler.isMarkerSet() );
-	
-	    handler.clearMarker();
-	    assertFalse( handle.exists() );
-	}
-}
-
-
+package org.apache.maven.plugin.dependency.utils.markers;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
+import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory;
+import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
+import org.apache.maven.plugin.dependency.testUtils.stubs.StubUnpackFileMarkerHandler;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.SilentLog;
+
+public class TestUnpackMarkerFileHandler
+	extends AbstractMojoTestCase
+{
+	List artifactItems = new ArrayList();
+
+    Log log = new SilentLog();
+
+    File outputFolder;
+    
+    protected File testDir;
+    
+    protected DependencyArtifactStubFactory stubFactory;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        
+        testDir = new File( getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar
+                + "unpack-markers" + File.separatorChar );
+        DependencyTestUtils.removeDirectory( testDir );
+        assertFalse( testDir.exists() );
+
+        stubFactory = new DependencyArtifactStubFactory( this.testDir, false );
+        Artifact artifact = stubFactory.createArtifact( "test", "test", "1" );
+        ArtifactItem artifactItem = stubFactory.getArtifactItem( artifact );
+        artifactItems.add( stubFactory.getArtifactItem( stubFactory.createArtifact( "test", "test", "1" ) ) );
+        artifact = stubFactory.createArtifact("test2", "test2", "2");
+        artifactItem = new ArtifactItem( artifact );
+        artifactItem.setIncludes( "**/*.xml" );
+        artifactItems.add( artifactItem );
+        artifact = stubFactory.createArtifact("test3", "test3", "3");
+        artifactItem = new ArtifactItem( artifact );
+        artifactItem.setExcludes( "**/*.class" );
+        artifactItems.add( artifactItem );
+        artifact = stubFactory.createArtifact("test4", "test4", "4");
+        artifactItem = new ArtifactItem( artifact );
+        artifactItem.setIncludes( "**/*.xml" );
+        artifactItem.setExcludes( "**/*.class" );
+        artifactItems.add( artifactItem );
+
+        outputFolder = new File( "target/markers/" );
+        DependencyTestUtils.removeDirectory( this.outputFolder );
+        assertFalse( outputFolder.exists() );
+    }
+
+    protected void tearDown()
+        throws IOException
+    {
+        DependencyTestUtils.removeDirectory( this.outputFolder );
+    }
+
+    /**
+     * 
+     * Assert that default functionallity still exists
+     * 
+     */
+    
+    public void testSetMarker()
+        throws MojoExecutionException
+    {
+        UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ),
+                                                                         this.outputFolder );
+        assertFalse( handler.isMarkerSet() );
+        handler.setMarker();
+        assertTrue( handler.isMarkerSet() );
+        handler.clearMarker();
+        assertFalse( handler.isMarkerSet() );
+
+        handler.setMarker();
+        assertTrue( handler.isMarkerSet() );
+        handler.setMarker();
+        assertTrue( handler.isMarkerSet() );
+
+        handler.clearMarker();
+        assertFalse( handler.isMarkerSet() );
+        handler.clearMarker();
+        assertFalse( handler.isMarkerSet() );
+    }
+
+    public void testMarkerFile()
+        throws MojoExecutionException, IOException
+    {
+    	UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ),
+                                                                         this.outputFolder );
+
+        File handle = handler.getMarkerFile();
+        assertFalse( handle.exists() );
+        assertFalse( handler.isMarkerSet() );
+
+        handler.setMarker();
+        assertTrue( handler.isMarkerSet() );
+        assertTrue( handle.exists() );
+
+        handle.delete();
+        assertFalse( handler.isMarkerSet() );
+
+        handle.createNewFile();
+        assertTrue( handler.isMarkerSet() );
+
+        handler.clearMarker();
+        assertFalse( handle.exists() );
+    }
+
+    public void testMarkerTimeStamp()
+        throws MojoExecutionException, IOException, InterruptedException
+    {
+        File theFile = new File( outputFolder, "theFile.jar" );
+        outputFolder.mkdirs();
+        theFile.createNewFile();
+        ArtifactItem theArtifactItem = (ArtifactItem) artifactItems.get( 0 );
+        Artifact theArtifact = theArtifactItem.getArtifact();
+        theArtifact.setFile( theFile );
+        UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( theArtifactItem, this.outputFolder );
+        assertFalse( handler.isMarkerSet() );
+        // if the marker is not set, assume it is infinately older than the
+        // artifact.
+        assertTrue( handler.isMarkerOlder( theArtifact ) );
+        handler.setMarker();
+        assertFalse( handler.isMarkerOlder( theArtifact ) );
+
+        theFile.setLastModified( theFile.lastModified() + 60000 );
+        assertTrue( handler.isMarkerOlder( theArtifact ) );
+
+        theFile.delete();
+        handler.clearMarker();
+        assertFalse( handler.isMarkerSet() );
+    }
+
+    public void testMarkerFileException()
+    {
+        // this stub wraps the file with an object to throw exceptions
+        StubUnpackFileMarkerHandler handler = new StubUnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 0 ),
+                                                                                 this.outputFolder );
+        try
+        {
+            handler.setMarker();
+            fail( "Expected an Exception here" );
+        }
+        catch ( MojoExecutionException e )
+        {
+
+        }
+    }
+
+    public void testGetterSetter()
+    {
+        UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( null, null );
+        assertTrue( handler.getArtifactItem() == null );
+        assertTrue( handler.getArtifact() == null );
+        handler.setArtifactItem( (ArtifactItem) artifactItems.get( 0 ) );
+        assertSame( artifactItems.get( 0 ), handler.getArtifactItem() );
+        assertSame( ((ArtifactItem) artifactItems.get( 0 )).getArtifact(), handler.getArtifact() );
+
+        assertTrue( handler.getMarkerFilesDirectory() == null );
+        handler.setMarkerFilesDirectory( outputFolder );
+        assertSame( outputFolder, handler.getMarkerFilesDirectory() );
+    }
+
+    public void testNullParent()
+        throws MojoExecutionException
+    {
+        // the parent isn't set so this will create the marker in the local
+        // folder. We must clear the
+        // marker to avoid leaving test droppings in root.
+    	UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( null, null );
+        handler.setArtifactItem( (ArtifactItem) artifactItems.get( 0 ) );
+        handler.setMarker();
+        assertTrue( handler.isMarkerSet() );
+        handler.clearMarker();
+        assertFalse( handler.isMarkerSet() );
+    }
+    
+    public void testIncludesMarker()
+    	throws MojoExecutionException, IOException
+	{
+    	UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 1 ), outputFolder );
+    	File handle = handler.getMarkerFile();
+        assertFalse( handle.exists() );
+        assertFalse( handler.isMarkerSet() );
+
+        handler.setMarker();
+        assertTrue( handler.isMarkerSet() );
+        assertTrue( handle.exists() );
+        String hashCode = "" + ( 0 + "**/*.xml".hashCode() );
+        assertTrue( handle.getName().indexOf( hashCode ) > -1 );
+
+        handle.delete();
+        assertFalse( handler.isMarkerSet() );
+
+        handle.createNewFile();
+        assertTrue( handler.isMarkerSet() );
+
+        handler.clearMarker();
+        assertFalse( handle.exists() );
+	}
+    
+    public void testExcludesMarker()
+		throws MojoExecutionException, IOException
+	{
+		UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 2 ), outputFolder );
+		File handle = handler.getMarkerFile();
+	    assertFalse( handle.exists() );
+	    assertFalse( handler.isMarkerSet() );
+	
+	    handler.setMarker();
+	    assertTrue( handler.isMarkerSet() );
+	    assertTrue( handle.exists() );
+	    String hashCode = "" + ( 0 + "**/*.class".hashCode() );
+	    assertTrue( handle.getName().indexOf( hashCode ) > -1 );
+	
+	    handle.delete();
+	    assertFalse( handler.isMarkerSet() );
+	
+	    handle.createNewFile();
+	    assertTrue( handler.isMarkerSet() );
+	
+	    handler.clearMarker();
+	    assertFalse( handle.exists() );
+	}
+    
+    public void testIncludesExcludesMarker()
+		throws MojoExecutionException, IOException
+	{
+		UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler( (ArtifactItem) artifactItems.get( 3 ), outputFolder );
+		File handle = handler.getMarkerFile();
+	    assertFalse( handle.exists() );
+	    assertFalse( handler.isMarkerSet() );
+	
+	    handler.setMarker();
+	    assertTrue( handler.isMarkerSet() );
+	    assertTrue( handle.exists() );
+	    String hashCode = "" + ( 0 + "**/*.class".hashCode() + "**/*.xml".hashCode() );
+	    assertTrue( handle.getName().indexOf( hashCode ) > -1 );
+	
+	    handle.delete();
+	    assertFalse( handler.isMarkerSet() );
+	
+	    handle.createNewFile();
+	    assertTrue( handler.isMarkerSet() );
+	
+	    handler.clearMarker();
+	    assertFalse( handle.exists() );
+	}
+}
+
+

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/markers/TestUnpackMarkerFileHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Id