maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r427819 [2/2] - in /maven/plugins/branches/MASSEMBLY-124/src: main/java/org/apache/maven/plugin/assembly/ main/java/org/apache/maven/plugin/assembly/archive/phase/ main/java/org/apache/maven/plugin/assembly/archive/task/ main/java/org/apach...
Date Wed, 02 Aug 2006 00:28:08 GMT
Added: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/RepositoryAssemblyPhaseTest.java?rev=427819&view=auto
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
(added)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
Tue Aug  1 17:28:06 2006
@@ -0,0 +1,262 @@
+package org.apache.maven.plugin.assembly.archive.phase;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
+import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
+import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
+import org.apache.maven.plugin.assembly.repository.RepositoryAssembler;
+import org.apache.maven.plugin.assembly.repository.RepositoryAssemblyException;
+import org.apache.maven.plugin.assembly.testutils.MockManager;
+import org.apache.maven.plugin.assembly.testutils.TestFileManager;
+import org.apache.maven.plugins.assembly.model.Assembly;
+import org.apache.maven.plugins.assembly.model.Repository;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.Archiver;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.logging.Logger;
+import org.easymock.MockControl;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class RepositoryAssemblyPhaseTest
+    extends TestCase
+{
+
+    private TestFileManager fileManager = new TestFileManager( "repository-phase.test.",
"" );
+
+    public void tearDown()
+        throws IOException
+    {
+        fileManager.cleanUp();
+    }
+
+    public void testExecute_ShouldNotIncludeRepositoryIfNonSpecifiedInAssembly()
+        throws ArchiveCreationException, AssemblyFormattingException
+    {
+        MockManager mm = new MockManager();
+
+        MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(
mm );
+        MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
+        MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+
+        File tempRoot = fileManager.createTempDir();
+
+        macCS.expectGetTemporaryRootDirectory( tempRoot );
+
+        Assembly assembly = new Assembly();
+
+        assembly.setId( "test" );
+
+        mm.replayAll();
+
+        createPhase( macRepo.repositoryAssembler, macLogger.logger ).execute( assembly, macArchiver.archiver,
+                                                                              macCS.configSource
);
+
+        mm.verifyAll();
+    }
+
+    public void testExecute_ShouldIncludeOneRepository()
+        throws ArchiveCreationException, AssemblyFormattingException
+    {
+        MockManager mm = new MockManager();
+
+        MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(
mm );
+        MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
+        MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+
+        File tempRoot = fileManager.createTempDir();
+
+        macCS.expectGetTemporaryRootDirectory( tempRoot );
+        macCS.expectGetProject( new MavenProject( new Model() ) );
+        macCS.expectGetFinalName( "final-name" );
+
+        Assembly assembly = new Assembly();
+
+        assembly.setId( "test" );
+        
+        Repository repo = new Repository();
+        
+        repo.setOutputDirectory( "/out" );
+        repo.setDirectoryMode( "777" );
+        repo.setFileMode( "777" );
+        
+        int mode = Integer.parseInt( "777", 8 );
+        
+        File outDir = new File( tempRoot, "repositories/out" );
+        
+        macArchiver.expectModeChange( -1, -1, mode, mode, true );
+        macArchiver.expectAddDirectory( outDir, "final-name/out/", null, new String[0] );
+        
+        macRepo.expectAssemble( outDir, repo, macCS.configSource );
+        
+        assembly.addRepository( repo );
+
+        mm.replayAll();
+
+        createPhase( macRepo.repositoryAssembler, macLogger.logger ).execute( assembly, macArchiver.archiver,
+                                                                              macCS.configSource
);
+
+        mm.verifyAll();
+    }
+
+    private RepositoryAssemblyPhase createPhase( RepositoryAssembler repositoryAssembler,
Logger logger )
+    {
+        RepositoryAssemblyPhase phase = new RepositoryAssemblyPhase( repositoryAssembler
);
+        phase.enableLogging( logger );
+
+        return phase;
+    }
+
+    private final class MockAndControlForArchiver
+    {
+        Archiver archiver;
+
+        MockControl control;
+
+        public MockAndControlForArchiver( MockManager mockManager )
+        {
+            control = MockControl.createControl( Archiver.class );
+            mockManager.add( control );
+
+            archiver = ( Archiver ) control.getMock();
+        }
+        
+        public void expectAddDirectory( File outDir, String location, String[] includes,
String[] excludes )
+        {
+            try
+            {
+                archiver.addDirectory( outDir, location, includes, excludes );
+            }
+            catch ( ArchiverException e )
+            {
+                Assert.fail( "Should never happen." );
+            }
+            
+            control.setMatcher( MockControl.ARRAY_MATCHER );
+            control.setVoidCallable( MockControl.ONE_OR_MORE );
+        }
+
+        void expectModeChange( int defaultDirMode, int defaultFileMode, int dirMode, int
fileMode,
+                                                boolean expectTwoSets )
+        {
+            archiver.getDefaultDirectoryMode();
+            control.setReturnValue( defaultDirMode );
+
+            archiver.getDefaultFileMode();
+            control.setReturnValue( defaultFileMode );
+
+            if ( expectTwoSets )
+            {
+                archiver.setDefaultDirectoryMode( dirMode );
+                archiver.setDefaultFileMode( fileMode );
+            }
+
+            archiver.setDefaultDirectoryMode( defaultDirMode );
+            archiver.setDefaultFileMode( defaultFileMode );
+        }
+
+
+        // public void expectAddFile( File file, String outputLocation, int fileMode )
+        // {
+        // try
+        // {
+        // archiver.addFile( file, outputLocation, fileMode );
+        // }
+        // catch ( ArchiverException e )
+        // {
+        // Assert.fail( "Should never happen." );
+        // }
+        // }
+    }
+
+    private final class MockAndControlForConfigSource
+    {
+        AssemblerConfigurationSource configSource;
+
+        MockControl control;
+
+        public MockAndControlForConfigSource( MockManager mockManager )
+        {
+            control = MockControl.createControl( AssemblerConfigurationSource.class );
+            mockManager.add( control );
+
+            configSource = ( AssemblerConfigurationSource ) control.getMock();
+        }
+
+        public void expectGetProject( MavenProject project )
+        {
+            configSource.getProject();
+            control.setReturnValue( project, MockControl.ONE_OR_MORE );
+        }
+        
+        public void expectGetFinalName( String finalName )
+        {
+            configSource.getFinalName();
+            control.setReturnValue( finalName, MockControl.ONE_OR_MORE );
+        }
+
+        public void expectGetTemporaryRootDirectory( File tempRoot )
+        {
+            configSource.getTemporaryRootDirectory();
+            control.setReturnValue( tempRoot, MockControl.ONE_OR_MORE );
+        }
+
+        //
+        // public void expectGetBasedir( File basedir )
+        // {
+        // configSource.getBasedir();
+        // control.setReturnValue( basedir, MockControl.ONE_OR_MORE );
+        // }
+    }
+
+    private final class MockAndControlForRepositoryAssembler
+    {
+        RepositoryAssembler repositoryAssembler;
+
+        MockControl control;
+
+        MockAndControlForRepositoryAssembler( MockManager mockManager )
+        {
+            control = MockControl.createControl( RepositoryAssembler.class );
+            mockManager.add( control );
+
+            repositoryAssembler = ( RepositoryAssembler ) control.getMock();
+        }
+
+        public void expectAssemble( File dir, Repository repo, AssemblerConfigurationSource
configSource )
+        {
+            try
+            {
+                repositoryAssembler.assemble( dir, repo, configSource );
+            }
+            catch ( RepositoryAssemblyException e )
+            {
+                Assert.fail( "Should never happen" );
+            }
+            
+            control.setVoidCallable( MockControl.ONE_OR_MORE );
+        }
+    }
+
+    private final class MockAndControlForLogger
+    {
+        Logger logger;
+
+        MockControl control;
+
+        public MockAndControlForLogger( MockManager mockManager )
+        {
+            control = MockControl.createControl( Logger.class );
+            mockManager.add( control );
+
+            logger = ( Logger ) control.getMock();
+        }
+    }
+
+}

Propchange: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddArtifactTaskTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddArtifactTaskTest.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddArtifactTaskTest.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddArtifactTaskTest.java
Tue Aug  1 17:28:06 2006
@@ -1,7 +1,9 @@
 package org.apache.maven.plugin.assembly.archive.task;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
 import org.apache.maven.plugin.assembly.archive.task.testutils.MockAndControlForAddArtifactTask;
+import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
 import org.apache.maven.plugin.assembly.testutils.MockManager;
 import org.codehaus.plexus.archiver.ArchiverException;
 
@@ -16,42 +18,54 @@
 
     private MockManager mockManager;
     
-    private MockAndControlForAddArtifactTask macForAddArtifact;
+    private MockAndControlForAddArtifactTask mac;
 
     public void setUp()
         throws IOException
     {
         mockManager = new MockManager();
         
-        macForAddArtifact = new MockAndControlForAddArtifactTask( mockManager );
-        macForAddArtifact.expectArtifactGetFile();
+        mac = new MockAndControlForAddArtifactTask( mockManager );
+        mac.expectArtifactGetFile();
+        mac.expectGetFinalName( "final-name" );
+        mac.expectGetClassifier( null );
+        mac.expectGetArtifactHandler();
     }
 
     public void testShouldAddArchiveFileWithoutUnpacking()
-        throws ArchiveCreationException
+        throws ArchiveCreationException, AssemblyFormattingException
     {
         String outputLocation = "artifact";
 
-        macForAddArtifact.expectAddFile( outputLocation );
+        mac.expectAddFile( outputLocation );
         mockManager.replayAll();
 
-        AddArtifactTask task = new AddArtifactTask( macForAddArtifact.artifact, outputLocation
);
+        AddArtifactTask task = createTask( mac.artifact );
 
-        task.execute( macForAddArtifact.archiver, null );
+        task.execute( mac.archiver, mac.configSource );
 
         mockManager.verifyAll();
     }
 
+    private AddArtifactTask createTask( Artifact artifact )
+    {
+        AddArtifactTask task = new AddArtifactTask( artifact );
+
+        task.setFileNameMapping( "artifact" );
+
+        return task;
+    }
+
     public void testShouldAddArchiveFileWithUnpack()
-        throws ArchiveCreationException
+        throws ArchiveCreationException, AssemblyFormattingException
     {
-        macForAddArtifact.expectModeChange( -1, -1, -1, -1, 1 );
+        mac.expectModeChange( -1, -1, -1, -1, 1 );
 
         String outputLocation = "artifact";
 
         try
         {
-            macForAddArtifact.archiver.addArchivedFileSet( macForAddArtifact.artifactFile,
outputLocation, null, null );
+            mac.archiver.addArchivedFileSet( mac.artifactFile, outputLocation, null, null
);
         }
         catch ( ArchiverException e )
         {
@@ -60,28 +74,28 @@
 
         mockManager.replayAll();
 
-        AddArtifactTask task = new AddArtifactTask( macForAddArtifact.artifact, outputLocation
);
+        AddArtifactTask task = createTask( mac.artifact );
 
         task.setUnpack( true );
 
-        task.execute( macForAddArtifact.archiver, null );
+        task.execute( mac.archiver, mac.configSource );
 
         mockManager.verifyAll();
     }
 
     public void testShouldAddArchiveFileWithUnpackAndModes()
-        throws ArchiveCreationException
+        throws ArchiveCreationException, AssemblyFormattingException
     {
         int directoryMode = Integer.parseInt( "777", 8 );
         int fileMode = Integer.parseInt( "777", 8 );
         
-        macForAddArtifact.expectModeChange( -1, -1, directoryMode, fileMode, 2 );
+        mac.expectModeChange( -1, -1, directoryMode, fileMode, 2 );
 
         String outputLocation = "artifact";
 
         try
         {
-            macForAddArtifact.archiver.addArchivedFileSet( macForAddArtifact.artifactFile,
outputLocation, null, null );
+            mac.archiver.addArchivedFileSet( mac.artifactFile, outputLocation, null, null
);
         }
         catch ( ArchiverException e )
         {
@@ -90,38 +104,38 @@
 
         mockManager.replayAll();
 
-        AddArtifactTask task = new AddArtifactTask( macForAddArtifact.artifact, outputLocation
);
+        AddArtifactTask task = createTask( mac.artifact );
 
         task.setUnpack( true );
-        task.setDirectoryMode( directoryMode );
-        task.setFileMode( fileMode );
+        task.setDirectoryMode( "777" );
+        task.setFileMode( "777" );
 
-        task.execute( macForAddArtifact.archiver, null );
+        task.execute( mac.archiver, mac.configSource );
 
         mockManager.verifyAll();
     }
 
     public void testShouldAddArchiveFileWithUnpackIncludesAndExcludes()
-        throws ArchiveCreationException
+        throws ArchiveCreationException, AssemblyFormattingException
     {
-        macForAddArtifact.expectModeChange( -1, -1, -1, -1, 1 );
+        mac.expectModeChange( -1, -1, -1, -1, 1 );
 
         String outputLocation = "artifact";
 
         String[] includes = { "**/*.txt" };
         String[] excludes = { "**/README.txt" };
 
-        macForAddArtifact.expectAddArchivedFileSet( outputLocation, includes, excludes );
+        mac.expectAddArchivedFileSet( outputLocation, includes, excludes );
 
         mockManager.replayAll();
 
-        AddArtifactTask task = new AddArtifactTask( macForAddArtifact.artifact, outputLocation
);
+        AddArtifactTask task = createTask( mac.artifact );
 
         task.setUnpack( true );
         task.setIncludes( Arrays.asList( includes ) );
         task.setExcludes( Arrays.asList( excludes ) );
 
-        task.execute( macForAddArtifact.archiver, null );
+        task.execute( mac.archiver, mac.configSource );
 
         mockManager.verifyAll();
     }

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddArtifactTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddArtifactTask.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddArtifactTask.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddArtifactTask.java
Tue Aug  1 17:28:06 2006
@@ -2,6 +2,7 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
 import org.apache.maven.plugin.assembly.testutils.MockManager;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.ArchiverException;
@@ -25,23 +26,66 @@
 
     public MockControl archiverCtl;
     
+    public AssemblerConfigurationSource configSource;
+    
+    public MockControl configSourceCtl;
+    
+    public ArtifactHandler artifactHandler;
+    
+    public MockControl artifactHandlerCtl;
+    
     public MockAndControlForAddArtifactTask( MockManager mockManager )
-        throws IOException
     {
         artifactCtl = MockControl.createControl( Artifact.class );
         mockManager.add( artifactCtl );
 
         artifact = ( Artifact ) artifactCtl.getMock();
         
+        artifactHandlerCtl = MockControl.createControl( ArtifactHandler.class );
+        mockManager.add( artifactHandlerCtl );
+        
+        artifactHandler = (ArtifactHandler) artifactHandlerCtl.getMock();
+        
         archiverCtl = MockControl.createControl( Archiver.class );
         mockManager.add( archiverCtl );
 
         archiver = (Archiver) archiverCtl.getMock();
+        
+        configSourceCtl = MockControl.createControl( AssemblerConfigurationSource.class );
+        mockManager.add( configSourceCtl );
+        
+        configSource = (AssemblerConfigurationSource) configSourceCtl.getMock();
     }
-
+    
+    public void expectGetArtifactHandler()
+    {
+        artifact.getArtifactHandler();
+        artifactCtl.setReturnValue( artifactHandler, MockControl.ONE_OR_MORE );
+    }
+    
+    public void expectGetClassifier( String classifier )
+    {
+        artifact.getClassifier();
+        artifactCtl.setReturnValue( classifier, MockControl.ONE_OR_MORE );
+    }
+    
+    public void expectGetFinalName( String finalName )
+    {
+        configSource.getFinalName();
+        configSourceCtl.setReturnValue( finalName, MockControl.ONE_OR_MORE );
+    }
+    
     public void expectArtifactGetFile() throws IOException
     {
-        artifactFile = File.createTempFile( "add-artifact-task.test.", ".jar" );
+        expectArtifactGetFile( true );
+    }
+
+    public void expectArtifactGetFile( boolean createTempFile ) throws IOException
+    {
+        if ( createTempFile )
+        {
+            artifactFile = File.createTempFile( "add-artifact-task.test.", ".jar" );
+        }
 
         artifact.getFile();
         
@@ -117,18 +161,6 @@
         }
     }
     
-    public void expectArtifactGetArtifactHandler( ArtifactHandler artifactHandler )
-    {
-        artifact.getArtifactHandler();
-        artifactCtl.setReturnValue( artifactHandler, MockControl.ONE_OR_MORE );
-    }
-
-    public void expectArtifactGetClassifier( String classifier )
-    {
-        artifact.getClassifier();
-        artifactCtl.setReturnValue( classifier, MockControl.ONE_OR_MORE );
-    }
-
     public void expectArtifactGetScope( String scope )
     {
         artifact.getScope();

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddFileSetsTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddFileSetsTask.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddFileSetsTask.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/task/testutils/MockAndControlForAddFileSetsTask.java
Tue Aug  1 17:28:06 2006
@@ -40,15 +40,16 @@
         mockManager.add( archiverCtl );
 
         archiver = ( Archiver ) archiverCtl.getMock();
-        
-        archiveBaseDir = fileManager.createTempDir();    }
+
+        archiveBaseDir = fileManager.createTempDir();
+    }
 
     public void expectGetArchiveBaseDirectory()
     {
         configSource.getArchiveBaseDirectory();
         configSourceCtl.setReturnValue( archiveBaseDir, MockControl.ONE_OR_MORE );
     }
-    
+
     public void expectGetBasedir( File basedir )
     {
         configSource.getBasedir();
@@ -75,10 +76,19 @@
         archiver.setDefaultDirectoryMode( modes[0] );
         archiver.setDefaultFileMode( modes[1] );
     }
-    
+
     public void expectAdditionOfSingleFileSet( MavenProject project, File basedir, String
finalName,
-                                              boolean shouldAddDir, int[] modes, int modeChangeCount,
-                                              boolean isDebugEnabled )
+                                               boolean shouldAddDir, int[] modes, int modeChangeCount,
+                                               boolean isDebugEnabled )
+    {
+        expectAdditionOfSingleFileSet( project, basedir, finalName, shouldAddDir, modes,
modeChangeCount,
+                                       isDebugEnabled, true );
+
+    }
+
+    public void expectAdditionOfSingleFileSet( MavenProject project, File basedir, String
finalName,
+                                               boolean shouldAddDir, int[] modes, int modeChangeCount,
+                                               boolean isDebugEnabled, boolean isProjectUsed
)
     {
         // the logger sends a debug message with this info inside the addFileSet(..) method..
         if ( isDebugEnabled )
@@ -90,8 +100,11 @@
             archiverCtl.setReturnValue( modes[1] );
         }
 
-        configSource.getProject();
-        configSourceCtl.setReturnValue( project, MockControl.ONE_OR_MORE );
+        if ( isProjectUsed )
+        {
+            configSource.getProject();
+            configSourceCtl.setReturnValue( project, MockControl.ONE_OR_MORE );
+        }
 
         configSource.getBasedir();
         configSourceCtl.setReturnValue( basedir, MockControl.ONE_OR_MORE );

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java
Tue Aug  1 17:28:06 2006
@@ -11,6 +11,7 @@
 import org.apache.maven.plugins.assembly.model.DependencySet;
 import org.apache.maven.plugins.assembly.model.FileItem;
 import org.apache.maven.plugins.assembly.model.FileSet;
+import org.apache.maven.plugins.assembly.model.Repository;
 import org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer;
 import org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer;
 import org.apache.maven.project.MavenProject;
@@ -296,6 +297,39 @@
         assertEquals( Artifact.SCOPE_RUNTIME, ((DependencySet) depSets.get( 0 )).getScope()
);
         assertEquals( Artifact.SCOPE_COMPILE, ((DependencySet) depSets.get( 1 )).getScope()
);
         assertEquals( Artifact.SCOPE_SYSTEM, ((DependencySet) depSets.get( 2 )).getScope()
);
+    }
+
+    public void testMergeComponentWithAssembly_ShouldAddOneRepositoryToExistingListOfTwo()
+    {
+        Assembly assembly = new Assembly();
+
+        Repository repo = new Repository();
+        repo.setScope( Artifact.SCOPE_RUNTIME );
+
+        assembly.addRepository( repo );
+
+        repo = new Repository();
+        repo.setScope( Artifact.SCOPE_COMPILE );
+
+        assembly.addRepository( repo );
+
+        Component component = new Component();
+
+        repo = new Repository();
+        repo.setScope( Artifact.SCOPE_SYSTEM );
+
+        component.addRepository( repo );
+
+        new DefaultAssemblyReader().mergeComponentWithAssembly( component, assembly );
+
+        List depSets = assembly.getRepositories();
+
+        assertNotNull( depSets );
+        assertEquals( 3, depSets.size() );
+
+        assertEquals( Artifact.SCOPE_RUNTIME, ((Repository) depSets.get( 0 )).getScope()
);
+        assertEquals( Artifact.SCOPE_COMPILE, ((Repository) depSets.get( 1 )).getScope()
);
+        assertEquals( Artifact.SCOPE_SYSTEM, ((Repository) depSets.get( 2 )).getScope() );
     }
 
     // FIXME: Deep merging should take place...

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/testutils/TestFileManager.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/testutils/TestFileManager.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/testutils/TestFileManager.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/testutils/TestFileManager.java
Tue Aug  1 17:28:06 2006
@@ -25,16 +25,51 @@
     private final String baseFilename;
 
     private final String fileSuffix;
+    
+    private StackTraceElement callerInfo;
+    
+    private Thread cleanupWarning;
+    
+    private boolean warnAboutCleanup = false;
 
     public TestFileManager( String baseFilename, String fileSuffix )
     {
         this.baseFilename = baseFilename;
         this.fileSuffix = fileSuffix;
+        
+        initializeCleanupMonitoring();
+    }
+
+    private void initializeCleanupMonitoring()
+    {
+        callerInfo = new NullPointerException().getStackTrace()[2];
+        
+        Runnable warning = new Runnable(){
+
+            public void run()
+            {
+                maybeWarnAboutCleanUp();
+            }
+
+        };
+        
+        cleanupWarning = new Thread( warning );
+        
+        Runtime.getRuntime().addShutdownHook( cleanupWarning );
+    }
+    
+    private void maybeWarnAboutCleanUp()
+    {
+        if ( warnAboutCleanup )
+        {
+            System.out.println( "[WARNING] TestFileManager from: " + callerInfo.getClassName()
+ " not cleaned up!" );
+        }
     }
 
     public void markForDeletion( File toDelete )
     {
         filesToDelete.add( toDelete );
+        warnAboutCleanup = true;
     }
 
     public synchronized File createTempDir()
@@ -60,7 +95,7 @@
     {
         File tempFile = File.createTempFile( baseFilename, fileSuffix );
         tempFile.deleteOnExit();
-        filesToDelete.add( tempFile );
+        markForDeletion( tempFile );
 
         return tempFile;
     }
@@ -86,6 +121,8 @@
 
             it.remove();
         }
+        
+        warnAboutCleanup = false;
     }
 
     public void assertFileExistence( File dir, String filename, boolean shouldExist )
@@ -145,6 +182,8 @@
         {
             IOUtil.close( writer );
         }
+        
+        markForDeletion( file );
 
         return file;
     }
@@ -171,6 +210,14 @@
         }
         
         return result;
+    }
+
+    protected void finalize()
+        throws Throwable
+    {
+        maybeWarnAboutCleanUp();
+        
+        super.finalize();
     }
 
 }

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/AssemblyFileUtilsTest.java
Tue Aug  1 17:28:06 2006
@@ -23,11 +23,18 @@
     extends TestCase
 {
 
+    private TestFileManager fileManager = new TestFileManager( "file-utils.test.", "" );
+    
+    public void tearDown()
+        throws IOException
+    {
+        fileManager.cleanUp();
+    }
+    
     public void testUnpack_ShouldSetSourceAndDestinationAndCallExtract()
         throws IOException, ArchiveExpansionException, NoSuchArchiverException
     {
         MockManager mockManager = new MockManager();
-        TestFileManager fileManager = new TestFileManager( "file-utils.unpack.test.", ""
);
         
         File source = fileManager.createTempFile();
         File destDir = fileManager.createTempDir();

Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java?rev=427819&r1=427818&r2=427819&view=diff
==============================================================================
--- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java
(original)
+++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java
Tue Aug  1 17:28:06 2006
@@ -6,6 +6,7 @@
 import org.apache.maven.plugin.assembly.testutils.MockManager;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
 import org.easymock.MockControl;
 
 import java.util.Collections;
@@ -248,7 +249,9 @@
             exclusions = Collections.EMPTY_LIST;
         }
 
-        FilterUtils.filterProjects( projects, inclusions, exclusions, depTrail != null );
+        Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
+        
+        FilterUtils.filterProjects( projects, inclusions, exclusions, depTrail != null, logger
);
 
         if ( verifyInclusion )
         {



Mime
View raw message