You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2009/08/04 22:51:54 UTC

svn commit: r800967 - in /maven/plugins/trunk/maven-repository-plugin: ./ src/main/java/org/apache/maven/plugins/repository/ src/test/java/org/apache/maven/plugins/repository/ src/test/java/org/apache/maven/plugins/repository/testutil/ src/test/resourc...

Author: jdcasey
Date: Tue Aug  4 20:51:54 2009
New Revision: 800967

URL: http://svn.apache.org/viewvc?rev=800967&view=rev
Log:
[MREPOSITORY-18] Scan for any files in the output directory and/or the local-repo directory with the correct finalName prefix. Then, allow users to select which ones to remove from this list; the remainder are added to the bundle along with the POM file. This is more inclusive than specifying the javadoc and sources jars alone. Also, warnings are still intact for missing javadoc/sources jars.

Added:
    maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleUtils.java   (with props)
    maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/
    maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/TestInputHandler.java   (with props)
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundleCreateMojoTest.xml   (with props)
    maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundlePackMojoTest.xml   (with props)
Modified:
    maven/plugins/trunk/maven-repository-plugin/pom.xml
    maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java
    maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundlePackMojo.java
    maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java
    maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundlePackMojoTest.java

Modified: maven/plugins/trunk/maven-repository-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/pom.xml?rev=800967&r1=800966&r2=800967&view=diff
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-repository-plugin/pom.xml Tue Aug  4 20:51:54 2009
@@ -143,4 +143,19 @@
       </build>
     </profile>
   </profiles>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+      	<plugin>
+      	  <artifactId>maven-surefire-plugin</artifactId>
+      	  <configuration>
+      	    <excludes>
+      	      <exclude>**/testutil/**</exclude>
+      	    </excludes>
+      	  </configuration>
+      	</plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
 </project>

Modified: maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java?rev=800967&r1=800966&r2=800967&view=diff
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java (original)
+++ maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleCreateMojo.java Tue Aug  4 20:51:54 2009
@@ -24,9 +24,12 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.components.interactivity.InputHandler;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * Goal which creates an upload bundle for a project built with Maven.
@@ -66,6 +69,11 @@
      */
     private ArtifactHandlerManager artifactHandlerManager;
 
+    /**
+     * @component
+     */
+    protected InputHandler inputHandler;
+    
     public void execute()
         throws MojoExecutionException
     {
@@ -113,41 +121,45 @@
 
         File pom = new File( basedir, POM );
 
-        String finalName = project.getBuild().getFinalName();
+        final String finalName = project.getBuild().getFinalName();
 
         String outputDirectory = project.getBuild().getDirectory();
+        
+        List files = BundleUtils.selectProjectFiles( new File( outputDirectory ), inputHandler, finalName, pom, getLog() );
 
         String extension = artifactHandlerManager.getArtifactHandler( project.getPackaging() ).getExtension();
 
-        File artifact = new File( outputDirectory, finalName + "." + extension );
-
-        File sourceArtifact = new File( outputDirectory, finalName + "-sources." + extension );
-
-        File javadocArtifact = new File( outputDirectory, finalName + "-javadoc." + extension );
-
         File bundle = new File( outputDirectory, finalName + "-bundle.jar" );
 
         try
         {
             jarArchiver.addFile( pom, POM );
 
-            jarArchiver.addFile( artifact, artifact.getName() );
-
-            if ( sourceArtifact.exists() )
+            boolean sourcesFound = false;
+            boolean javadocsFound = false;
+            
+            for ( Iterator it = files.iterator(); it.hasNext(); )
             {
-                jarArchiver.addFile( sourceArtifact, sourceArtifact.getName() );
+                File f = (File) it.next();
+                if ( f.getName().endsWith( finalName + "-sources." + extension ) )
+                {
+                    sourcesFound = true;
+                }
+                else if ( f.getName().equals( finalName + "-javadoc." + extension ) )
+                {
+                    javadocsFound = true;
+                }
+                
+                jarArchiver.addFile( f, f.getName() );
             }
-            else
+            
+            if ( !sourcesFound )
             {
                 getLog().warn( "Sources not included in upload bundle. In order to add sources please run"
                     + " \"mvn source:jar javadoc:jar repository:bundle-create\"" );
             }
 
-            if ( javadocArtifact.exists() )
-            {
-                jarArchiver.addFile( javadocArtifact, javadocArtifact.getName() );
-            }
-            else
+            if ( !javadocsFound )
             {
                 getLog().warn( "Javadoc not included in upload bundle. In order to add javadocs please run"
                     + " \"mvn source:jar javadoc:jar repository:bundle-create\"" );

Modified: maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundlePackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundlePackMojo.java?rev=800967&r1=800966&r2=800967&view=diff
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundlePackMojo.java (original)
+++ maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundlePackMojo.java Tue Aug  4 20:51:54 2009
@@ -42,6 +42,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -201,7 +202,6 @@
 
         try
         {
-
             if ( rewrite )
             {
                 new MavenXpp3Writer().write( WriterFactory.newXmlWriter( pom ), model );
@@ -217,30 +217,37 @@
             {
                 finalName = model.getArtifactId() + "-" + model.getVersion();
             }
+            
+            List files = BundleUtils.selectProjectFiles( dir, inputHandler, finalName, pom, getLog() );
 
-            File mainArtifact = new File( dir, finalName + "." + model.getPackaging() );
-            File sourceArtifact = new File( dir, finalName + "-sources.jar" );
-            File javadocArtifact = new File( dir, finalName + "-javadoc.jar" );
             File bundle = new File( basedir, finalName + "-bundle.jar" );
 
             jarArchiver.addFile( pom, POM );
 
-            jarArchiver.addFile( mainArtifact, mainArtifact.getName() );
-
-            if ( sourceArtifact.exists() )
+            boolean sourcesFound = false;
+            boolean javadocsFound = false;
+            
+            for ( Iterator it = files.iterator(); it.hasNext(); )
             {
-                jarArchiver.addFile( sourceArtifact, sourceArtifact.getName() );
+                File f = (File) it.next();
+                if ( f.getName().endsWith( finalName + "-sources.jar" ) )
+                {
+                    sourcesFound = true;
+                }
+                else if ( f.getName().equals( finalName + "-javadoc.jar" ) )
+                {
+                    javadocsFound = true;
+                }
+                
+                jarArchiver.addFile( f, f.getName() );
             }
-            else
+            
+            if ( !sourcesFound )
             {
                 getLog().warn( "Sources not included in upload bundle." );
             }
 
-            if ( javadocArtifact.exists() )
-            {
-                jarArchiver.addFile( javadocArtifact, javadocArtifact.getName() );
-            }
-            else
+            if ( !javadocsFound )
             {
                 getLog().warn( "Javadoc not included in upload bundle." );
             }

Added: maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleUtils.java?rev=800967&view=auto
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleUtils.java (added)
+++ maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleUtils.java Tue Aug  4 20:51:54 2009
@@ -0,0 +1,147 @@
+package org.apache.maven.plugins.repository;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.components.interactivity.InputHandler;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+final class BundleUtils
+{
+    private BundleUtils()
+    {
+    }
+    
+    public static List selectProjectFiles( final File dir, final InputHandler inputHandler, final String finalName,
+                                           final File pom, final Log log )
+        throws MojoExecutionException
+    {
+        File[] projectFiles = dir.listFiles( new FilenameFilter()
+        {
+            public boolean accept( File dir, String name )
+            {
+                return new File( dir, name ).isFile() && name.startsWith( finalName );
+            }
+        } );
+        
+        List result = new ArrayList();
+        
+        for ( int i = 0; i < projectFiles.length; i++ )
+        {
+            if ( projectFiles[i].getName().endsWith( ".pom" ) )
+            {
+                log.info( "Detected POM file will be excluded:\n" + projectFiles[i]
+                    + "\n\nInstead, the bundle will include the POM from:\n" + pom );
+            }
+            else if ( projectFiles[i].getName().endsWith( "-bundle.jar" ) )
+            {
+                log.warn( "Skipping project file which collides with repository bundle filename:\n" + projectFiles[i] );
+            }
+            else
+            {
+                result.add( projectFiles[i] );
+            }
+        }
+        
+        Collections.sort( result, new Comparator()
+        {
+            public int compare( Object first, Object second )
+            {
+                String f = ((File) first).getName();
+                String s = ((File) second).getName();
+                
+                if ( f.length() == s.length() )
+                {
+                    return f.compareTo( s );
+                }
+                
+                return f.length() < s.length() ? -1 : 1;
+            }
+        } );
+        
+        result = reviseFileList( result, inputHandler, log );
+        
+        return result;
+    }
+
+    public static List reviseFileList( List input, InputHandler inputHandler, Log log )
+        throws MojoExecutionException
+    {
+        List result = new ArrayList( input );
+        
+        while( true )
+        {
+            StringBuffer message = new StringBuffer();
+            message.append( "The following files are marked for inclusion in the repository bundle:\n" );
+            message.append( "\n0.) Done" );
+            
+            int i = 1;
+            for ( Iterator it = result.iterator(); it.hasNext(); )
+            {
+                File f = (File) it.next();
+                message.append( "\n" ).append( (i++) ).append( ".) " ).append( f.getName() );
+            }
+            
+            message.append( "\n\nPlease select the number(s) for any files you wish to exclude, " +
+                    "or '0' when you're done.\nSeparate the numbers for multiple files with a " +
+                    "comma (',').\n\nSelection: " );
+            
+            log.info( message );
+            String response = null;
+            try
+            {
+                response = inputHandler.readLine();
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( "Project file selection failed with an I/O exception: " + e.getMessage(), e );
+            }
+            
+            if ( response == null || "0".equals( response ) )
+            {
+                break;
+            }
+            
+            StringTokenizer st = new StringTokenizer( response, "," );
+            
+            if ( st.countTokens() > 0 )
+            {
+                int[] idxs = new int[st.countTokens()];
+                for ( int j = 0; j < idxs.length; j++ )
+                {
+                    idxs[j] = Integer.parseInt( st.nextToken().trim() );
+                }
+                
+                Arrays.sort( idxs );
+                
+                for( int k = idxs.length - 1; k > -1; k-- )
+                {
+                    if ( idxs[k] < 1 || idxs[k] > result.size() )
+                    {
+                        log.warn( "NOT removing: " + idxs[k] + "; no such file." );
+                        continue;
+                    }
+                    
+                    File removed = (File) result.remove( idxs[k] -1 );
+                    log.info( "Removed: " + removed.getName() );
+                }
+            }
+            else
+            {
+                break;
+            }
+        }
+        
+        return result;
+    }
+
+}

Propchange: maven/plugins/trunk/maven-repository-plugin/src/main/java/org/apache/maven/plugins/repository/BundleUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java?rev=800967&r1=800966&r2=800967&view=diff
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java (original)
+++ maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundleCreateMojoTest.java Tue Aug  4 20:51:54 2009
@@ -18,15 +18,20 @@
  */
 package org.apache.maven.plugins.repository;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.codehaus.plexus.archiver.zip.ZipEntry;
+import org.apache.maven.plugins.repository.testutil.TestInputHandler;
 import org.codehaus.plexus.archiver.zip.ZipFile;
+import org.codehaus.plexus.components.interactivity.InputHandler;
 import org.codehaus.plexus.util.FileUtils;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Stack;
+
 /**
  * @author <a href="mailto:oching@exist.com">Maria Odea Ching</a>
  */
@@ -43,7 +48,7 @@
 
     /**
      * Test for repository plugin default configuration
-     *
+     * 
      * @throws Exception
      */
     public void testDefaultconfiguration()
@@ -72,60 +77,147 @@
             e.printStackTrace();
         }
 
-        File bundleSource = new File( getBasedir(),
-                                      "target/test/unit/default-configuration/target/default-configuration-bundle.jar" );
+        File bundleSource =
+            new File( getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar" );
         assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
 
-        ZipFile jar = new ZipFile( bundleSource );
-        Enumeration entries = jar.getEntries();
-        assertTrue( entries.hasMoreElements() );
+        Set entryNames = new HashSet();
+        entryNames.add( "default-configuration-javadoc.jar" );
+        entryNames.add( "default-configuration-sources.jar" );
+        entryNames.add( "default-configuration.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
 
-        if ( entries.hasMoreElements() )
+        assertZipContents( entryNames, Collections.EMPTY_SET, bundleSource );
+    }
+
+    public void testDefaultconfiguration_RemoveOne()
+        throws Exception
+    {
+        try
         {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "default-configuration-javadoc.jar" );
+            createTestJars( "default-configuration", true, true, getBasedir()
+                + "/target/test/unit/default-configuration/target" );
+        }
+        catch ( IOException ie )
+        {
+            ie.printStackTrace();
+        }
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "default-configuration-sources.jar" );
+        File testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pom.xml" );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "default-configuration.jar" );
+        try
+        {
+            BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo( "bundle-create", testPom );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "pom.xml" );
+            // NOTE: This is sensitive to the lookupMojo method timing...
+            TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+            Stack responses = new Stack();
+            responses.push( "2" );
+            ih.setLineResponses( responses );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/" );
+            mojo.execute();
         }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        File bundleSource =
+            new File( getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar" );
+        assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
 
+        Set entryNames = new HashSet();
+        entryNames.add( "default-configuration-sources.jar" );
+        entryNames.add( "default-configuration.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        bannedNames.add( "default-configuration-javadoc.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
     }
 
-    /**
-     * Test repository plugin when there is no javadoc jar to be included in the bundle
-     *
-     * @throws Exception
-     */
-    public void testNoJavadocJar()
+    public void testDefaultconfiguration_RemoveTwo()
         throws Exception
     {
+        try
+        {
+            createTestJars( "default-configuration", true, true, getBasedir()
+                + "/target/test/unit/default-configuration/target" );
+        }
+        catch ( IOException ie )
+        {
+            ie.printStackTrace();
+        }
+
+        File testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pom.xml" );
 
         try
         {
-            createTestJars( "no-javadocjar", false, true, getBasedir() + "/target/test/unit/no-javadocjar/target" );
+            BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo( "bundle-create", testPom );
+
+            // NOTE: This is sensitive to the lookupMojo method timing...
+            TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
+
+            Stack responses = new Stack();
+            responses.push( "2,3" );
+            ih.setLineResponses( responses );
+
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        File bundleSource =
+            new File( getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar" );
+        assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
+
+        Set entryNames = new HashSet();
+        entryNames.add( "default-configuration.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        bannedNames.add( "default-configuration-javadoc.jar" );
+        bannedNames.add( "default-configuration-sources.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
+
+    public void testDefaultconfiguration_RemoveTwoUnordered()
+        throws Exception
+    {
+        try
+        {
+            createTestJars( "default-configuration", true, true, getBasedir()
+                + "/target/test/unit/default-configuration/target" );
         }
         catch ( IOException ie )
         {
             ie.printStackTrace();
         }
 
-        File testPom = new File( getBasedir(), "src/test/resources/unit/no-javadocjar/pom.xml" );
+        File testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pom.xml" );
 
         try
         {
             BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo( "bundle-create", testPom );
+
+            // NOTE: This is sensitive to the lookupMojo method timing...
+            TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
+
+            Stack responses = new Stack();
+            responses.push( "3,2" );
+            ih.setLineResponses( responses );
+
             mojo.execute();
         }
         catch ( Exception e )
@@ -133,52 +225,156 @@
             e.printStackTrace();
         }
 
-        File bundleSource = new File( getBasedir(), "target/test/unit/no-javadocjar/target/no-javadocjar-bundle.jar" );
+        File bundleSource =
+            new File( getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar" );
         assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
 
-        ZipFile jar = new ZipFile( bundleSource );
-        Enumeration entries = jar.getEntries();
-        assertTrue( entries.hasMoreElements() );
+        Set entryNames = new HashSet();
+        entryNames.add( "default-configuration.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        bannedNames.add( "default-configuration-javadoc.jar" );
+        bannedNames.add( "default-configuration-sources.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
 
-        if ( entries.hasMoreElements() )
+    public void testDefaultconfiguration_RemoveTwoWithSpace()
+        throws Exception
+    {
+        try
         {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "no-javadocjar-sources.jar" );
+            createTestJars( "default-configuration", true, true, getBasedir()
+                + "/target/test/unit/default-configuration/target" );
+        }
+        catch ( IOException ie )
+        {
+            ie.printStackTrace();
+        }
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "no-javadocjar.jar" );
+        File testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pom.xml" );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "pom.xml" );
+        try
+        {
+            BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo( "bundle-create", testPom );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+            // NOTE: This is sensitive to the lookupMojo method timing...
+            TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/" );
+            Stack responses = new Stack();
+            responses.push( "2, 3" );
+            ih.setLineResponses( responses );
+
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
         }
 
+        File bundleSource =
+            new File( getBasedir(), "target/test/unit/default-configuration/target/default-configuration-bundle.jar" );
+        assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
+
+        Set entryNames = new HashSet();
+        entryNames.add( "default-configuration.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        bannedNames.add( "default-configuration-javadoc.jar" );
+        bannedNames.add( "default-configuration-sources.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
+
+    private void assertZipContents( Set requiredNames, Set bannedNames, File bundleSource )
+        throws IOException
+    {
+        ZipFile zf = new ZipFile( bundleSource );
+
+        Set missing = new HashSet();
+        for ( Iterator it = requiredNames.iterator(); it.hasNext(); )
+        {
+            String name = (String) it.next();
+            if ( zf.getEntry( name ) == null )
+            {
+                missing.add( name );
+            }
+        }
+
+        Set banned = new HashSet();
+        for ( Iterator it = bannedNames.iterator(); it.hasNext(); )
+        {
+            String name = (String) it.next();
+            if ( zf.getEntry( name ) != null )
+            {
+                banned.add( name );
+            }
+        }
+
+        if ( !missing.isEmpty() || !banned.isEmpty() )
+        {
+            StringBuffer msg = new StringBuffer();
+            msg.append( "The following REQUIRED entries were missing from the bundle archive:\n" );
+
+            if ( missing.isEmpty() )
+            {
+                msg.append( "\nNone." );
+            }
+            else
+            {
+                for ( Iterator it = missing.iterator(); it.hasNext(); )
+                {
+                    String name = (String) it.next();
+
+                    msg.append( "\n" ).append( name );
+                }
+            }
+
+            msg.append( "\n\nThe following BANNED entries were present from the bundle archive:\n" );
+
+            if ( banned.isEmpty() )
+            {
+                msg.append( "\nNone.\n" );
+            }
+            else
+            {
+                for ( Iterator it = banned.iterator(); it.hasNext(); )
+                {
+                    String name = (String) it.next();
+
+                    msg.append( "\n" ).append( name );
+                }
+            }
+
+            fail( msg.toString() );
+        }
     }
 
     /**
-     * Test repository plugin when there is no sources jar to be included in the bundle
-     *
+     * Test repository plugin when there is no javadoc jar to be included in the bundle
+     * 
      * @throws Exception
      */
-    public void testNoSourcesJar()
+    public void testNoJavadocJar()
         throws Exception
     {
 
         try
         {
-            createTestJars( "no-sourcesjar", true, false, getBasedir() + "/target/test/unit/no-sourcesjar/target" );
+            createTestJars( "no-javadocjar", false, true, getBasedir() + "/target/test/unit/no-javadocjar/target" );
         }
         catch ( IOException ie )
         {
             ie.printStackTrace();
         }
 
-        File testPom = new File( getBasedir(), "src/test/resources/unit/no-sourcesjar/pom.xml" );
+        File testPom = new File( getBasedir(), "src/test/resources/unit/no-javadocjar/pom.xml" );
 
         try
         {
@@ -190,36 +386,65 @@
             e.printStackTrace();
         }
 
-        File bundleSource = new File( getBasedir(), "target/test/unit/no-sourcesjar/target/no-sourcesjar-bundle.jar" );
+        File bundleSource = new File( getBasedir(), "target/test/unit/no-javadocjar/target/no-javadocjar-bundle.jar" );
         assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
 
-        ZipFile jar = new ZipFile( bundleSource );
-        Enumeration entries = jar.getEntries();
-        assertTrue( entries.hasMoreElements() );
+        Set entryNames = new HashSet();
+        entryNames.add( "no-javadocjar-sources.jar" );
+        entryNames.add( "no-javadocjar.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
 
-        if ( entries.hasMoreElements() )
-        {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "no-sourcesjar-javadoc.jar" );
+        assertZipContents( entryNames, Collections.singleton( "no-javadocjar-javadoc.jar" ), bundleSource );
+    }
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "no-sourcesjar.jar" );
+    /**
+     * Test repository plugin when there is no sources jar to be included in the bundle
+     * 
+     * @throws Exception
+     */
+    public void testNoSourcesJar()
+        throws Exception
+    {
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "pom.xml" );
+        try
+        {
+            createTestJars( "no-sourcesjar", true, false, getBasedir() + "/target/test/unit/no-sourcesjar/target" );
+        }
+        catch ( IOException ie )
+        {
+            ie.printStackTrace();
+        }
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+        File testPom = new File( getBasedir(), "src/test/resources/unit/no-sourcesjar/pom.xml" );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/" );
+        try
+        {
+            BundleCreateMojo mojo = (BundleCreateMojo) lookupMojo( "bundle-create", testPom );
+            mojo.execute();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
         }
 
+        File bundleSource = new File( getBasedir(), "target/test/unit/no-sourcesjar/target/no-sourcesjar-bundle.jar" );
+        assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
+
+        Set entryNames = new HashSet();
+        entryNames.add( "no-sourcesjar-javadoc.jar" );
+        entryNames.add( "no-sourcesjar.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        assertZipContents( entryNames, Collections.singleton( "no-sourcesjar-sources.jar" ), bundleSource );
     }
 
     /**
      * Test repository plugin when there are no javadoc and sources jar files to be included in the bundle
-     *
+     * 
      * @throws Exception
      */
     public void testNoJavadocSourcesJars()
@@ -248,34 +473,26 @@
             e.printStackTrace();
         }
 
-        File bundleSource = new File( getBasedir(),
-                                      "target/test/unit/no-javadoc-sources/target/no-javadoc-sources-bundle.jar" );
+        File bundleSource =
+            new File( getBasedir(), "target/test/unit/no-javadoc-sources/target/no-javadoc-sources-bundle.jar" );
         assertTrue( FileUtils.fileExists( bundleSource.getAbsolutePath() ) );
 
-        ZipFile jar = new ZipFile( bundleSource );
-        Enumeration entries = jar.getEntries();
-        assertTrue( entries.hasMoreElements() );
-
-        if ( entries.hasMoreElements() )
-        {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "no-javadoc-sources.jar" );
-
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "pom.xml" );
-
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
-
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/" );
-        }
+        Set entryNames = new HashSet();
+        entryNames.add( "no-javadoc-sources.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        bannedNames.add( "no-javadoc-sources-sources.jar" );
+        bannedNames.add( "no-javadoc-sources-javadoc.jar" );
 
+        assertZipContents( entryNames, bannedNames, bundleSource );
     }
 
     /**
      * Test repository plugin when the packaging specified in the pom is invalid
-     *
+     * 
      * @throws Exception
      */
     public void testInvalidPackaging()
@@ -309,7 +526,7 @@
 
     /**
      * Test repository plugin when the scm element is null
-     *
+     * 
      * @throws Exception
      */
     public void testNullScm()
@@ -336,7 +553,7 @@
 
     /**
      * Test repository plugin when license file does not exist
-     *
+     * 
      * @throws Exception
      */
     public void testNoLicense()
@@ -369,7 +586,7 @@
 
     /**
      * Test repository plugin when there is no project name specified in the pom
-     *
+     * 
      * @throws Exception
      */
     public void testNoProjectName()
@@ -401,11 +618,15 @@
 
     /**
      * Method for creating the jar files that will be used in testing
-     *
-     * @param fileName         the file name of the jar file(s) to be created
-     * @param createJavadocJar specifies whether a javadoc jar file will be created or not
-     * @param createSourcesJar specifies whether a sources jar file will be created or not
-     * @param destDir          the destination directory where the jar file(s) are to be created
+     * 
+     * @param fileName
+     *            the file name of the jar file(s) to be created
+     * @param createJavadocJar
+     *            specifies whether a javadoc jar file will be created or not
+     * @param createSourcesJar
+     *            specifies whether a sources jar file will be created or not
+     * @param destDir
+     *            the destination directory where the jar file(s) are to be created
      * @throws IOException
      */
     private void createTestJars( String fileName, boolean createJavadocJar, boolean createSourcesJar, String destDir )

Modified: maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundlePackMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundlePackMojoTest.java?rev=800967&r1=800966&r2=800967&view=diff
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundlePackMojoTest.java (original)
+++ maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/BundlePackMojoTest.java Tue Aug  4 20:51:54 2009
@@ -18,15 +18,21 @@
  */
 package org.apache.maven.plugins.repository;
 
-import java.io.File;
-import java.net.URL;
-import java.util.Enumeration;
-
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.codehaus.plexus.archiver.zip.ZipEntry;
+import org.apache.maven.plugins.repository.testutil.TestInputHandler;
 import org.codehaus.plexus.archiver.zip.ZipFile;
+import org.codehaus.plexus.components.interactivity.InputHandler;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Stack;
 
 /**
  * @author Fabrizio Giustina
@@ -44,37 +50,231 @@
 
         BundlePackMojo mojo = (BundlePackMojo) lookupMojo( "bundle-pack", testPom );
         URL repoURL = new File( getBasedir(), "src/test/resources/repo" ).toURL();
-        mojo.localRepository = new DefaultArtifactRepository( "test", repoURL.toString(), new DefaultRepositoryLayout() );
+        mojo.localRepository =
+            new DefaultArtifactRepository( "test", repoURL.toString(), new DefaultRepositoryLayout() );
 
         File generatedFilesDir = new File( getBasedir(), "target/bundle-pack-tests" );
         mojo.basedir = generatedFilesDir.getAbsolutePath();
         mojo.execute();
 
-        ZipFile jar = new ZipFile( new File( generatedFilesDir, "testartifact-1.0-bundle.jar" ) );
-        Enumeration entries = jar.getEntries();
-        assertTrue( entries.hasMoreElements() );
+        File bundleSource = new File( generatedFilesDir, "testartifact-1.0-bundle.jar" );
+        Set entryNames = new HashSet();
+        entryNames.add( "testartifact-1.0-javadoc.jar" );
+        entryNames.add( "testartifact-1.0-sources.jar" );
+        entryNames.add( "testartifact-1.0.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
 
-        if ( entries.hasMoreElements() )
-        {
-            ZipEntry entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "testartifact-1.0-javadoc.jar" );
+        assertZipContents( entryNames, Collections.EMPTY_SET, bundleSource );
+    }
+
+    public void testPack_RemoveOne()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml" );
+
+        BundlePackMojo mojo = (BundlePackMojo) lookupMojo( "bundle-pack", testPom );
+        URL repoURL = new File( getBasedir(), "src/test/resources/repo" ).toURL();
+        mojo.localRepository =
+            new DefaultArtifactRepository( "test", repoURL.toString(), new DefaultRepositoryLayout() );
+
+        // NOTE: This is sensitive to the lookupMojo method timing...
+        TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
+
+        Stack responses = new Stack();
+        responses.push( "3" );
+        ih.setLineResponses( responses );
+
+        File generatedFilesDir = new File( getBasedir(), "target/bundle-pack-tests" );
+        mojo.basedir = generatedFilesDir.getAbsolutePath();
+        mojo.execute();
+
+        File bundleSource = new File( generatedFilesDir, "testartifact-1.0-bundle.jar" );
+        Set entryNames = new HashSet();
+        entryNames.add( "testartifact-1.0-javadoc.jar" );
+        entryNames.add( "testartifact-1.0.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        // determined experimentally, so this could change!
+        bannedNames.add( "testartifact-1.0-sources.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
+
+    public void testPack_RemoveTwo()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml" );
+
+        BundlePackMojo mojo = (BundlePackMojo) lookupMojo( "bundle-pack", testPom );
+        URL repoURL = new File( getBasedir(), "src/test/resources/repo" ).toURL();
+        mojo.localRepository =
+            new DefaultArtifactRepository( "test", repoURL.toString(), new DefaultRepositoryLayout() );
+
+        // NOTE: This is sensitive to the lookupMojo method timing...
+        TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
+
+        Stack responses = new Stack();
+        responses.push( "2,3" );
+        ih.setLineResponses( responses );
+
+        File generatedFilesDir = new File( getBasedir(), "target/bundle-pack-tests" );
+        mojo.basedir = generatedFilesDir.getAbsolutePath();
+        mojo.execute();
+
+        File bundleSource = new File( generatedFilesDir, "testartifact-1.0-bundle.jar" );
+        Set entryNames = new HashSet();
+        entryNames.add( "testartifact-1.0.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        // determined experimentally, so this could change!
+        bannedNames.add( "testartifact-1.0-sources.jar" );
+        bannedNames.add( "testartifact-1.0-javadoc.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
+
+    public void testPack_RemoveTwoUnordered()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml" );
+
+        BundlePackMojo mojo = (BundlePackMojo) lookupMojo( "bundle-pack", testPom );
+        URL repoURL = new File( getBasedir(), "src/test/resources/repo" ).toURL();
+        mojo.localRepository =
+            new DefaultArtifactRepository( "test", repoURL.toString(), new DefaultRepositoryLayout() );
+
+        // NOTE: This is sensitive to the lookupMojo method timing...
+        TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
+
+        Stack responses = new Stack();
+        responses.push( "3,2" );
+        ih.setLineResponses( responses );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "testartifact-1.0-sources.jar" );
+        File generatedFilesDir = new File( getBasedir(), "target/bundle-pack-tests" );
+        mojo.basedir = generatedFilesDir.getAbsolutePath();
+        mojo.execute();
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "testartifact-1.0.jar" );
+        File bundleSource = new File( generatedFilesDir, "testartifact-1.0-bundle.jar" );
+        Set entryNames = new HashSet();
+        entryNames.add( "testartifact-1.0.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        // determined experimentally, so this could change!
+        bannedNames.add( "testartifact-1.0-sources.jar" );
+        bannedNames.add( "testartifact-1.0-javadoc.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "pom.xml" );
+    public void testPack_RemoveTwoWithSpace()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), "src/test/resources/unit/bundle-pack/pom.xml" );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/MANIFEST.MF" );
+        BundlePackMojo mojo = (BundlePackMojo) lookupMojo( "bundle-pack", testPom );
+        URL repoURL = new File( getBasedir(), "src/test/resources/repo" ).toURL();
+        mojo.localRepository =
+            new DefaultArtifactRepository( "test", repoURL.toString(), new DefaultRepositoryLayout() );
 
-            entry = (ZipEntry) entries.nextElement();
-            assertEquals( entry.getName(), "META-INF/" );
+        // NOTE: This is sensitive to the lookupMojo method timing...
+        TestInputHandler ih = (TestInputHandler) lookup( InputHandler.ROLE, "default" );
+
+        Stack responses = new Stack();
+        responses.push( "2, 3" );
+        ih.setLineResponses( responses );
+
+        File generatedFilesDir = new File( getBasedir(), "target/bundle-pack-tests" );
+        mojo.basedir = generatedFilesDir.getAbsolutePath();
+        mojo.execute();
+
+        File bundleSource = new File( generatedFilesDir, "testartifact-1.0-bundle.jar" );
+        Set entryNames = new HashSet();
+        entryNames.add( "testartifact-1.0.jar" );
+        entryNames.add( "pom.xml" );
+        entryNames.add( "META-INF/MANIFEST.MF" );
+        entryNames.add( "META-INF/" );
+
+        Set bannedNames = new HashSet();
+        // determined experimentally, so this could change!
+        bannedNames.add( "testartifact-1.0-sources.jar" );
+        bannedNames.add( "testartifact-1.0-javadoc.jar" );
+
+        assertZipContents( entryNames, bannedNames, bundleSource );
+    }
+
+    private void assertZipContents( Set requiredNames, Set bannedNames, File bundleSource )
+        throws IOException
+    {
+        ZipFile zf = new ZipFile( bundleSource );
+
+        Set missing = new HashSet();
+        for ( Iterator it = requiredNames.iterator(); it.hasNext(); )
+        {
+            String name = (String) it.next();
+            if ( zf.getEntry( name ) == null )
+            {
+                missing.add( name );
+            }
+        }
+
+        Set banned = new HashSet();
+        for ( Iterator it = bannedNames.iterator(); it.hasNext(); )
+        {
+            String name = (String) it.next();
+            if ( zf.getEntry( name ) != null )
+            {
+                banned.add( name );
+            }
         }
 
+        if ( !missing.isEmpty() || !banned.isEmpty() )
+        {
+            StringBuffer msg = new StringBuffer();
+            msg.append( "The following REQUIRED entries were missing from the bundle archive:\n" );
+
+            if ( missing.isEmpty() )
+            {
+                msg.append( "\nNone." );
+            }
+            else
+            {
+                for ( Iterator it = missing.iterator(); it.hasNext(); )
+                {
+                    String name = (String) it.next();
+
+                    msg.append( "\n" ).append( name );
+                }
+            }
+
+            msg.append( "\n\nThe following BANNED entries were present from the bundle archive:\n" );
+
+            if ( banned.isEmpty() )
+            {
+                msg.append( "\nNone.\n" );
+            }
+            else
+            {
+                for ( Iterator it = banned.iterator(); it.hasNext(); )
+                {
+                    String name = (String) it.next();
+
+                    msg.append( "\n" ).append( name );
+                }
+            }
+
+            fail( msg.toString() );
+        }
     }
 
 }

Added: maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/TestInputHandler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/TestInputHandler.java?rev=800967&view=auto
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/TestInputHandler.java (added)
+++ maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/TestInputHandler.java Tue Aug  4 20:51:54 2009
@@ -0,0 +1,52 @@
+package org.apache.maven.plugins.repository.testutil;
+
+import org.codehaus.plexus.components.interactivity.InputHandler;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Stack;
+
+public class TestInputHandler
+    implements InputHandler
+{
+    
+    private Stack lineResponses;
+    
+    private Stack lineListResponses;
+    
+    private Stack passwordResponses;
+
+    public String readLine()
+        throws IOException
+    {
+        return (String) ( lineResponses == null || lineResponses.isEmpty() ? null : lineResponses.pop() );
+    }
+
+    public List readMultipleLines()
+        throws IOException
+    {
+        return (List) ( lineListResponses == null || lineListResponses.isEmpty() ? null : lineListResponses.pop() );
+    }
+
+    public String readPassword()
+        throws IOException
+    {
+        return (String) ( passwordResponses == null || passwordResponses.isEmpty() ? null : passwordResponses.pop() );
+    }
+
+    public void setLineResponses( Stack responses )
+    {
+        this.lineResponses = responses;
+    }
+
+    public void setLineListResponses( Stack lineLists )
+    {
+        this.lineListResponses = lineLists;
+    }
+
+    public void setPasswordResponses( Stack responses )
+    {
+        this.passwordResponses = responses;
+    }
+
+}

Propchange: maven/plugins/trunk/maven-repository-plugin/src/test/java/org/apache/maven/plugins/repository/testutil/TestInputHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundleCreateMojoTest.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundleCreateMojoTest.xml?rev=800967&view=auto
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundleCreateMojoTest.xml (added)
+++ maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundleCreateMojoTest.xml Tue Aug  4 20:51:54 2009
@@ -0,0 +1,10 @@
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.components.interactivity.InputHandler</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.plugins.repository.testutil.TestInputHandler</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+    </component>
+  </components>
+</component-set>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundleCreateMojoTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundlePackMojoTest.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundlePackMojoTest.xml?rev=800967&view=auto
==============================================================================
--- maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundlePackMojoTest.xml (added)
+++ maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundlePackMojoTest.xml Tue Aug  4 20:51:54 2009
@@ -0,0 +1,9 @@
+<component-set>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.components.interactivity.InputHandler</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.plugins.repository.testutil.TestInputHandler</implementation>
+    </component>
+  </components>
+</component-set>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-repository-plugin/src/test/resources/org/apache/maven/plugins/repository/BundlePackMojoTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native