You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/04/17 16:46:53 UTC

[maven-assembly-plugin] branch MASSEMBLY-934 created (now 5ba9b81)

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a change to branch MASSEMBLY-934
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git.


      at 5ba9b81  [MASSEMBLY-934] Support concatenation of files

This branch includes the following new commits:

     new 5ba9b81  [MASSEMBLY-934] Support concatenation of files

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-assembly-plugin] 01/01: [MASSEMBLY-934] Support concatenation of files

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MASSEMBLY-934
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git

commit 5ba9b81c27302c582e609a06865cc2e83ab2a047
Author: rfscholte <rf...@apache.org>
AuthorDate: Fri Apr 17 18:46:40 2020 +0200

    [MASSEMBLY-934] Support concatenation of files
---
 pom.xml                                            |   9 +-
 .../massembly-934_concat-files/a.properties        |  18 +
 .../massembly-934_concat-files/invoker.properties  |  18 +
 src/it/projects/massembly-934_concat-files/pom.xml |  54 +++
 .../src/assemble/bin.xml                           |  40 ++
 .../src/config/a/file.txt                          |   2 +
 .../src/config/b/file.txt                          |   2 +
 .../massembly-934_concat-files/verify.groovy       |  29 ++
 .../archive/phase/FileItemAssemblyPhase.java       |  87 ++++-
 src/main/mdo/assembly-component.mdo                |  12 +
 src/main/mdo/assembly.mdo                          |  14 +-
 .../archive/phase/FileItemAssemblyPhaseTest.java   | 413 ++++++++-------------
 12 files changed, 431 insertions(+), 267 deletions(-)

diff --git a/pom.xml b/pom.xml
index d61916d..0b27d7c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,7 +62,7 @@ under the License.
 
   <properties>
     <javaVersion>7</javaVersion>
-    <mdoVersion>2.0.0</mdoVersion>
+    <mdoVersion>2.1.0</mdoVersion>
     <mavenArchiverVersion>3.5.0</mavenArchiverVersion>
     <mavenFilteringVersion>3.1.1</mavenFilteringVersion>
     <mavenVersion>3.0</mavenVersion>
@@ -199,6 +199,12 @@ under the License.
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>2.28.2</version>
+      <scope>test</scope> 
+    </dependency>
+    <dependency>
       <groupId>org.easymock</groupId>
       <artifactId>easymockclassextension</artifactId>
       <version>2.5.2</version>
@@ -281,7 +287,6 @@ under the License.
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
-        <version>1.8.3</version>
         <configuration>
           <version>${mdoVersion}</version>
           <models>
diff --git a/src/it/projects/massembly-934_concat-files/a.properties b/src/it/projects/massembly-934_concat-files/a.properties
new file mode 100644
index 0000000..aa0aca5
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/a.properties
@@ -0,0 +1,18 @@
+# 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.
+
+testProp=boo
diff --git a/src/it/projects/massembly-934_concat-files/invoker.properties b/src/it/projects/massembly-934_concat-files/invoker.properties
new file mode 100644
index 0000000..2da4fe6
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals=org.apache.maven.plugins:maven-assembly-plugin:${testVersion}:single
diff --git a/src/it/projects/massembly-934_concat-files/pom.xml b/src/it/projects/massembly-934_concat-files/pom.xml
new file mode 100644
index 0000000..5cc1857
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.plugin.assembly.test</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <groupId>org.test</groupId>
+  <artifactId>massembly934</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <url>https://issues.apache.org/jira/browse/MASSEMBLY-934</url>
+
+  <build>
+    <filters>
+      <filter>a.properties</filter>
+    </filters>
+        
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <appendAssemblyId>false</appendAssemblyId>
+          <descriptors>
+            <descriptor>src/assemble/bin.xml</descriptor>
+          </descriptors>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/massembly-934_concat-files/src/assemble/bin.xml b/src/it/projects/massembly-934_concat-files/src/assemble/bin.xml
new file mode 100644
index 0000000..dd9697d
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/src/assemble/bin.xml
@@ -0,0 +1,40 @@
+<?xml version='1.0'?>
+<!--
+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.
+-->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/2.1.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
+  <id>massembly-934</id>
+  <formats>
+    <format>dir</format>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <files>
+    <file>
+      <sources>
+        <source>src/config/a/file.txt</source>
+        <source>src/config/b/file.txt</source>
+      </sources>
+      <destName>ab.txt</destName>
+      <filtered>true</filtered>
+    </file>
+  </files>
+</assembly>
diff --git a/src/it/projects/massembly-934_concat-files/src/config/a/file.txt b/src/it/projects/massembly-934_concat-files/src/config/a/file.txt
new file mode 100644
index 0000000..7301c3c
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/src/config/a/file.txt
@@ -0,0 +1,2 @@
+file A
+${testProp}
diff --git a/src/it/projects/massembly-934_concat-files/src/config/b/file.txt b/src/it/projects/massembly-934_concat-files/src/config/b/file.txt
new file mode 100644
index 0000000..4b001d2
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/src/config/b/file.txt
@@ -0,0 +1,2 @@
+file B
+${testProp}
diff --git a/src/it/projects/massembly-934_concat-files/verify.groovy b/src/it/projects/massembly-934_concat-files/verify.groovy
new file mode 100644
index 0000000..0e4d987
--- /dev/null
+++ b/src/it/projects/massembly-934_concat-files/verify.groovy
@@ -0,0 +1,29 @@
+
+/*
+ * 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.
+ */
+
+def buildDirectory = new File(basedir, 'target')
+
+def dirFile = new File(buildDirectory, 'massembly934-1.0')
+
+assert new File( dirFile, "ab.txt").readLines() == ['file A','boo','file B','boo']
+
+def zipFile = new java.util.zip.ZipFile(new File(buildDirectory, 'massembly934-1.0.zip'))
+
+assert zipFile.getInputStream(zipFile.entries().next()).readLines() == ['file A','boo','file B','boo']
\ No newline at end of file
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
index 4572449..f866ffb 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
@@ -19,7 +19,20 @@ package org.apache.maven.plugins.assembly.archive.phase;
  * under the License.
  */
 
+import static org.codehaus.plexus.components.io.resources.ResourceFactory.createResource;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
+import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
 import org.apache.maven.plugins.assembly.archive.ArchiveCreationException;
 import org.apache.maven.plugins.assembly.format.AssemblyFormattingException;
 import org.apache.maven.plugins.assembly.format.ReaderFormatter;
@@ -31,16 +44,12 @@ import org.apache.maven.plugins.assembly.utils.TypeConversionUtils;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.components.io.functions.ContentSupplier;
 import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
+import org.codehaus.plexus.components.io.resources.PlexusIoFileResource;
 import org.codehaus.plexus.components.io.resources.PlexusIoResource;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import static org.codehaus.plexus.components.io.resources.ResourceFactory.createResource;
-
 /**
  * Handles the top-level &lt;files/&gt; section of the assembly descriptor.
  *
@@ -58,14 +67,36 @@ public class FileItemAssemblyPhase
     @Override
     public void execute( final Assembly assembly, final Archiver archiver,
                          final AssemblerConfigurationSource configSource )
-        throws ArchiveCreationException, AssemblyFormattingException
+        throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
     {
         final List<FileItem> fileList = assembly.getFiles();
         final File basedir = configSource.getBasedir();
 
         for ( final FileItem fileItem : fileList )
         {
-            final String sourcePath = fileItem.getSource();
+            if ( fileItem.getSource() != null ^ fileItem.getSources().isEmpty() )
+            {
+                throw new InvalidAssemblerConfigurationException( 
+                                                      "Misconfigured file: one of source or sources must be set" );
+            }
+            
+            String destName = fileItem.getDestName();
+            
+            final String sourcePath;
+            if ( fileItem.getSource() != null )
+            {
+                sourcePath = fileItem.getSource();
+            }
+            else if ( destName != null )
+            {
+                // because createResource() requires a file
+                sourcePath = fileItem.getSources().get( 0 );
+            }
+            else
+            {
+                throw new InvalidAssemblerConfigurationException( 
+                                "Misconfigured file: specify destName when using sources" );
+            }            
 
             // ensure source file is in absolute path for reactor build to work
             File source = new File( sourcePath );
@@ -78,9 +109,6 @@ public class FileItemAssemblyPhase
             {
                 source = new File( basedir, sourcePath );
             }
-
-            String destName = fileItem.getDestName();
-
             if ( destName == null )
             {
                 destName = sourceName;
@@ -115,8 +143,28 @@ public class FileItemAssemblyPhase
                 final InputStreamTransformer fileSetTransformers =
                     ReaderFormatter.getFileSetTransformers( configSource, fileItem.isFiltered(),
                                                             fileItem.getLineEnding() );
-
-                final PlexusIoResource restoUse = createResource( source, fileSetTransformers );
+                
+                final PlexusIoResource restoUse;
+                if ( !fileItem.getSources().isEmpty() )
+                {
+                    List<InputStream> content = new ArrayList<>( fileItem.getSources().size() );
+                    for ( String contentSourcePath : fileItem.getSources() )
+                    {
+                        File contentSource = new File( contentSourcePath );
+                        if ( !AssemblyFileUtils.isAbsolutePath( contentSource ) )
+                        {
+                            contentSource = new File( basedir, contentSourcePath );
+                        }
+                        content.add( new FileInputStream( contentSource ) );
+                    }
+                    
+                    String name = PlexusIoFileResource.getName( source );
+                    restoUse = createResource( source, name, getContentSupplier( content ), fileSetTransformers );
+                }
+                else
+                {
+                    restoUse = createResource( source, fileSetTransformers );
+                }
 
                 int mode = TypeConversionUtils.modeToInt( fileItem.getFileMode(), getLogger() );
                 archiver.addResource( restoUse, target, mode );
@@ -133,4 +181,17 @@ public class FileItemAssemblyPhase
     {
         return 10;
     }
+    
+    private ContentSupplier getContentSupplier( final Collection<InputStream> contentStreams ) 
+    {
+        return new ContentSupplier()
+        {
+            @Override
+            public InputStream getContents()
+                throws IOException
+            {
+                return new SequenceInputStream( Collections.enumeration( contentStreams ) );
+            }
+        };
+    }
 }
diff --git a/src/main/mdo/assembly-component.mdo b/src/main/mdo/assembly-component.mdo
index 18ae461..32b5f97 100644
--- a/src/main/mdo/assembly-component.mdo
+++ b/src/main/mdo/assembly-component.mdo
@@ -304,6 +304,18 @@
           </description>
         </field>
         <field>
+          <name>sources</name>
+          <version>2.1.0+</version>
+          <description>
+            Set of absolute or relative paths from the module's directory
+            of the files be combined and included in the assembly.
+          </description>
+           <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
           <name>outputDirectory</name>
           <version>1.0.0+</version>
           <type>String</type>
diff --git a/src/main/mdo/assembly.mdo b/src/main/mdo/assembly.mdo
index b8d584d..2b6517f 100644
--- a/src/main/mdo/assembly.mdo
+++ b/src/main/mdo/assembly.mdo
@@ -411,19 +411,31 @@
       <description>
         A file allows individual file inclusion with the option to change
         the destination filename not supported by fileSets.
+        Note: either source or sources is required
       </description>
       <fields>
         <field>
           <name>source</name>
           <version>1.0.0+</version>
           <type>String</type>
-          <required>true</required>
           <description>
             Sets the absolute or relative path from the module's directory
             of the file to be included in the assembly.
           </description>
         </field>
         <field>
+          <name>sources</name>
+          <version>2.1.0+</version>
+          <description>
+            Set of absolute or relative paths from the module's directory
+            of the files be combined and included in the assembly.
+          </description>
+           <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
           <name>outputDirectory</name>
           <version>1.0.0+</version>
           <type>String</type>
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java
index 3603066..3be332b 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java
@@ -19,90 +19,76 @@ package org.apache.maven.plugins.assembly.archive.phase;
  * under the License.
  */
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+
 import org.apache.maven.model.Model;
 import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
-import org.apache.maven.plugins.assembly.archive.ArchiveCreationException;
-import org.apache.maven.plugins.assembly.format.AssemblyFormattingException;
 import org.apache.maven.plugins.assembly.model.Assembly;
 import org.apache.maven.plugins.assembly.model.FileItem;
-import org.apache.maven.plugins.assembly.testutils.TestFileManager;
 import org.apache.maven.plugins.assembly.utils.TypeConversionUtils;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.utils.Os;
 import org.codehaus.plexus.archiver.Archiver;
-import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.components.io.resources.PlexusIoResource;
 import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.easymock.classextension.EasyMockSupport;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expect;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class FileItemAssemblyPhaseTest
-    extends TestCase
 {
-
-    private final TestFileManager fileManager = new TestFileManager( "file-item-phase.test.", "" );
-
-    @Override
-    public void tearDown()
-        throws IOException
-    {
-        fileManager.cleanUp();
-    }
-
+    @Rule
+    public TemporaryFolder temporaryFolder = new TemporaryFolder();
+    
+    @Test
     public void testExecute_ShouldAddNothingWhenNoFileItemsArePresent()
-        throws ArchiveCreationException, AssemblyFormattingException
+        throws Exception
     {
-        final EasyMockSupport mm = new EasyMockSupport();
-
-        final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+        final AssemblerConfigurationSource macCS = mock( AssemblerConfigurationSource.class );
 
-        final File basedir = fileManager.createTempDir();
+        final File basedir = temporaryFolder.getRoot();
 
-        macCS.expectGetBasedir( basedir );
+        when( macCS.getBasedir()).thenReturn( basedir );
 
-        final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
+        final Logger macLogger = mock( Logger.class );
 
         final Assembly assembly = new Assembly();
         assembly.setId( "test" );
 
-        mm.replayAll();
-
-        createPhase( macLogger.logger ).execute( assembly, null, macCS.configSource );
+        createPhase( macLogger ).execute( assembly, null, macCS );
 
-        mm.verifyAll();
+        verify( macCS ).getBasedir();
     }
 
+    @Test
     public void testExecute_ShouldAddAbsoluteFileNoFilterNoLineEndingConversion()
-        throws ArchiveCreationException, AssemblyFormattingException, IOException
+        throws Exception
     {
-        final EasyMockSupport mm = new EasyMockSupport();
-
-        final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
-
-        final File basedir = fileManager.createTempDir();
-
-        final File file = fileManager.createFile( basedir, "file.txt", "This is a test file." );
+        final AssemblerConfigurationSource macCS = mock( AssemblerConfigurationSource.class );
 
-        macCS.expectGetBasedir( basedir );
+        final File basedir = temporaryFolder.getRoot();
 
-        macCS.expectGetProject( new MavenProject( new Model() ) );
+        final File file = temporaryFolder.newFile( "file.txt" );
+        Files.write( file.toPath(), Arrays.asList( "This is a test file." ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetFinalName( "final-name" );
-        macCS.expectInterpolators();
+        when( macCS.getBasedir() ).thenReturn( basedir );
+        when( macCS.getProject() ).thenReturn( new MavenProject( new Model() ) );
+        when( macCS.getFinalName() ) .thenReturn( "final-name" );
+        prepareInterpolators( macCS );
 
-        final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
+        final Logger macLogger = mock( Logger.class );
 
-        final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        final Archiver macArchiver = mock( Archiver.class );
 
         final Assembly assembly = new Assembly();
         assembly.setId( "test" );
@@ -113,39 +99,36 @@ public class FileItemAssemblyPhaseTest
         fi.setLineEnding( "keep" );
         fi.setFileMode( "777" );
 
-        macArchiver.expectAddFile( file, "file.txt", TypeConversionUtils.modeToInt( "777", new ConsoleLogger(
-            Logger.LEVEL_DEBUG, "test" ) ) );
-
         assembly.addFile( fi );
 
-        mm.replayAll();
-
-        createPhase( macLogger.logger ).execute( assembly, macArchiver.archiver, macCS.configSource );
+        createPhase( macLogger ).execute( assembly, macArchiver, macCS );
 
-        mm.verifyAll();
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ),
+                                           eq( "file.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
     }
 
+    @Test
     public void testExecute_ShouldAddRelativeFileNoFilterNoLineEndingConversion()
-        throws ArchiveCreationException, AssemblyFormattingException, IOException
+        throws Exception
     {
-        final EasyMockSupport mm = new EasyMockSupport();
+        final AssemblerConfigurationSource macCS = mock( AssemblerConfigurationSource.class );
 
-        final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+        final File basedir = temporaryFolder.getRoot();
 
-        final File basedir = fileManager.createTempDir();
+        final File file = temporaryFolder.newFile( "file.txt" );
+        Files.write( file.toPath(), Arrays.asList( "This is a test file." ), StandardCharsets.UTF_8 );
 
-        final File file = fileManager.createFile( basedir, "file.txt", "This is a test file." );
+        when( macCS.getBasedir() ).thenReturn( basedir );
+        when( macCS.getProject() ).thenReturn( new MavenProject( new Model() ) );
+        when( macCS.getFinalName() ) .thenReturn( "final-name" );
+        prepareInterpolators( macCS );
 
-        macCS.expectGetBasedir( basedir );
+        final Logger macLogger = mock( Logger.class );
 
-        macCS.expectGetProject( new MavenProject( new Model() ) );
-
-        macCS.expectGetFinalName( "final-name" );
-        macCS.expectInterpolators();
-
-        final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
-
-        final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        final Archiver macArchiver = mock( Archiver.class );
 
         final Assembly assembly = new Assembly();
         assembly.setId( "test" );
@@ -156,43 +139,42 @@ public class FileItemAssemblyPhaseTest
         fi.setLineEnding( "keep" );
         fi.setFileMode( "777" );
 
-        macArchiver.expectAddFile( file, "file.txt", TypeConversionUtils.modeToInt( "777", new ConsoleLogger(
-            Logger.LEVEL_DEBUG, "test" ) ) );
-
         assembly.addFile( fi );
 
-        mm.replayAll();
-
-        createPhase( macLogger.logger ).execute( assembly, macArchiver.archiver, macCS.configSource );
+        createPhase( macLogger ).execute( assembly, macArchiver, macCS );
 
-        mm.verifyAll();
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ),
+                                           eq( "file.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
     }
 
+    @Test
     public void testExecute_WithOutputDirectory()
         throws Exception
     {
-        final EasyMockSupport mm = new EasyMockSupport();
-
-        final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+        final AssemblerConfigurationSource macCS = mock( AssemblerConfigurationSource.class );
 
-        final File basedir = fileManager.createTempDir();
+        final File basedir = temporaryFolder.getRoot();
 
-        final File readmeFile = fileManager.createFile( basedir, "README.txt", "This is a test file for README.txt." );
-        final File licenseFile =
-            fileManager.createFile( basedir, "LICENSE.txt", "This is a test file for LICENSE.txt." );
-        final File configFile =
-            fileManager.createFile( basedir, "config/config.txt", "This is a test file for config/config.txt" );
+        final File readmeFile = temporaryFolder.newFile( "README.txt" );
+        Files.write( readmeFile.toPath(), Arrays.asList( "This is a test file for README.txt." ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetBasedir( basedir );
+        final File licenseFile = temporaryFolder.newFile( "LICENSE.txt" );
+        Files.write( licenseFile.toPath(), Arrays.asList( "This is a test file for LICENSE.txt." ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetProject( new MavenProject( new Model() ) );
+        final File configFile = new File( temporaryFolder.newFolder( "config" ), "config.txt" );
+        Files.write( configFile.toPath(), Arrays.asList( "This is a test file for config/config.txt" ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetFinalName( "final-name" );
-        macCS.expectInterpolators();
+        when( macCS.getBasedir() ).thenReturn( basedir );
+        when( macCS.getProject() ).thenReturn( new MavenProject( new Model() ) );
+        when( macCS.getFinalName() ) .thenReturn( "final-name" );
+        prepareInterpolators( macCS );
 
-        final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
+        final Logger macLogger = mock( Logger.class );
 
-        final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        final Archiver macArchiver = mock( Archiver.class );
 
         final Assembly assembly = new Assembly();
         assembly.setId( "test" );
@@ -219,52 +201,55 @@ public class FileItemAssemblyPhaseTest
         configFileItem.setLineEnding( "keep" );
         configFileItem.setFileMode( "777" );
 
-        macArchiver.expectAddFile( readmeFile, "README.txt", TypeConversionUtils.modeToInt( "777", new ConsoleLogger(
-            Logger.LEVEL_DEBUG, "test" ) ) );
-        macArchiver.expectAddFile( licenseFile, "LICENSE.txt", TypeConversionUtils.modeToInt( "777", new ConsoleLogger(
-            Logger.LEVEL_DEBUG, "test" ) ) );
-        macArchiver.expectAddFile( configFile, "config/config.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                   new ConsoleLogger(
-                                                                                                       Logger
-                                                                                                           .LEVEL_DEBUG,
-                                                                                                       "test" ) ) );
-
         assembly.addFile( readmeFileItem );
         assembly.addFile( licenseFileItem );
         assembly.addFile( configFileItem );
 
-        mm.replayAll();
-
-        createPhase( macLogger.logger ).execute( assembly, macArchiver.archiver, macCS.configSource );
-
-        mm.verifyAll();
+        createPhase( macLogger ).execute( assembly, macArchiver, macCS );
+
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ),
+                                           eq( "README.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ),
+                                           eq( "LICENSE.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ),
+                                           eq( "config/config.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+    
     }
 
+    @Test
     public void testExecute_WithOutputDirectoryAndDestName()
         throws Exception
     {
-        final EasyMockSupport mm = new EasyMockSupport();
-
-        final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+        final AssemblerConfigurationSource macCS = mock( AssemblerConfigurationSource.class );
 
-        final File basedir = fileManager.createTempDir();
+        final File basedir = temporaryFolder.getRoot();
 
-        final File readmeFile = fileManager.createFile( basedir, "README.txt", "This is a test file for README.txt." );
-        final File licenseFile =
-            fileManager.createFile( basedir, "LICENSE.txt", "This is a test file for LICENSE.txt." );
-        final File configFile =
-            fileManager.createFile( basedir, "config/config.txt", "This is a test file for config/config.txt" );
+        final File readmeFile = temporaryFolder.newFile( "README.txt" );
+        Files.write( readmeFile.toPath(), Arrays.asList( "This is a test file for README.txt." ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetBasedir( basedir );
+        final File licenseFile = temporaryFolder.newFile( "LICENSE.txt" );
+        Files.write( licenseFile.toPath(), Arrays.asList( "This is a test file for LICENSE.txt." ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetProject( new MavenProject( new Model() ) );
+        final File configFile = new File( temporaryFolder.newFolder( "config" ), "config.txt" );
+        Files.write( configFile.toPath(), Arrays.asList( "This is a test file for config/config.txt" ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetFinalName( "final-name" );
-        macCS.expectInterpolators();
+        when( macCS.getBasedir() ).thenReturn( basedir );
+        when( macCS.getProject() ).thenReturn( new MavenProject( new Model() ) );
+        when( macCS.getFinalName() ) .thenReturn( "final-name" );
+        prepareInterpolators( macCS );
 
-        final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
+        final Logger macLogger = mock( Logger.class );
 
-        final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        final Archiver macArchiver = mock( Archiver.class );
 
         final Assembly assembly = new Assembly();
         assembly.setId( "test" );
@@ -294,59 +279,54 @@ public class FileItemAssemblyPhaseTest
         configFileItem.setLineEnding( "keep" );
         configFileItem.setFileMode( "777" );
 
-        macArchiver.expectAddFile( readmeFile, "README_renamed.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                    new ConsoleLogger(
-                                                                                                        Logger
-                                                                                                            .LEVEL_DEBUG,
-                                                                                                        "test" ) ) );
-        macArchiver.expectAddFile( licenseFile, "LICENSE_renamed.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                      new ConsoleLogger(
-                                                                                                          Logger
-                                                                                                              .LEVEL_DEBUG,
-                                                                                                          "test" ) ) );
-        macArchiver.expectAddFile( configFile, "config/config_renamed.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                           new ConsoleLogger(
-                                                                                                               Logger
-                                                                                                                   .LEVEL_DEBUG,
-                                                                                                               "test"
-                                                                                                           ) ) );
-
         assembly.addFile( readmeFileItem );
         assembly.addFile( licenseFileItem );
         assembly.addFile( configFileItem );
 
-        mm.replayAll();
-
-        createPhase( macLogger.logger ).execute( assembly, macArchiver.archiver, macCS.configSource );
-
-        mm.verifyAll();
+        createPhase( macLogger ).execute( assembly, macArchiver, macCS );
+
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ), 
+                                           eq( "README_renamed.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ), 
+                                           eq( "LICENSE_renamed.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ), 
+                                           eq( "config/config_renamed.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
     }
 
+    @Test
     public void testExecute_WithOutputDirectoryAndDestNameAndIncludeBaseDirectoryFalse()
         throws Exception
     {
-        final EasyMockSupport mm = new EasyMockSupport();
+        final AssemblerConfigurationSource macCS = mock( AssemblerConfigurationSource.class );
 
-        final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
+        final File basedir = temporaryFolder.getRoot();
 
-        final File basedir = fileManager.createTempDir();
+        final File readmeFile = temporaryFolder.newFile( "README.txt" );
+        Files.write( readmeFile.toPath(), Arrays.asList( "This is a test file for README.txt." ), StandardCharsets.UTF_8 );
 
-        final File readmeFile = fileManager.createFile( basedir, "README.txt", "This is a test file for README.txt." );
-        final File licenseFile =
-            fileManager.createFile( basedir, "LICENSE.txt", "This is a test file for LICENSE.txt." );
-        final File configFile =
-            fileManager.createFile( basedir, "config/config.txt", "This is a test file for config/config.txt" );
+        final File licenseFile = temporaryFolder.newFile( "LICENSE.txt" );
+        Files.write( licenseFile.toPath(), Arrays.asList( "This is a test file for LICENSE.txt." ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetBasedir( basedir );
+        final File configFile = new File( temporaryFolder.newFolder( "config" ), "config.txt" );
+        Files.write( configFile.toPath(), Arrays.asList( "This is a test file for config/config.txt" ), StandardCharsets.UTF_8 );
 
-        macCS.expectGetProject( new MavenProject( new Model() ) );
+        when( macCS.getBasedir() ).thenReturn( basedir );
+        when( macCS.getProject() ).thenReturn( new MavenProject( new Model() ) );
+        when( macCS.getFinalName() ) .thenReturn( "final-name" );
+        prepareInterpolators( macCS );
 
-        macCS.expectGetFinalName( "final-name" );
-        macCS.expectInterpolators();
+        final Logger macLogger = mock( Logger.class );
 
-        final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
-
-        final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
+        final Archiver macArchiver = mock( Archiver.class );
 
         final Assembly assembly = new Assembly();
         assembly.setId( "test" );
@@ -374,32 +354,27 @@ public class FileItemAssemblyPhaseTest
         configFileItem.setLineEnding( "keep" );
         configFileItem.setFileMode( "777" );
 
-        macArchiver.expectAddFile( readmeFile, "README_renamed.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                    new ConsoleLogger(
-                                                                                                        Logger
-                                                                                                            .LEVEL_DEBUG,
-                                                                                                        "test" ) ) );
-        macArchiver.expectAddFile( licenseFile, "LICENSE_renamed.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                      new ConsoleLogger(
-                                                                                                          Logger
-                                                                                                              .LEVEL_DEBUG,
-                                                                                                          "test" ) ) );
-        macArchiver.expectAddFile( configFile, "config/config_renamed.txt", TypeConversionUtils.modeToInt( "777",
-                                                                                                           new ConsoleLogger(
-                                                                                                               Logger
-                                                                                                                   .LEVEL_DEBUG,
-                                                                                                               "test"
-                                                                                                           ) ) );
-
         assembly.addFile( readmeFileItem );
         assembly.addFile( licenseFileItem );
         assembly.addFile( configFileItem );
 
-        mm.replayAll();
-
-        createPhase( macLogger.logger ).execute( assembly, macArchiver.archiver, macCS.configSource );
-
-        mm.verifyAll();
+        createPhase( macLogger ).execute( assembly, macArchiver, macCS );
+
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ), 
+                                           eq( "README_renamed.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ),
+                                           eq( "LICENSE_renamed.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
+        verify( macArchiver ).addResource( any( PlexusIoResource.class ), 
+                                           eq( "config/config_renamed.txt" ),
+                                           eq( TypeConversionUtils.modeToInt( "777",
+                                                                              new ConsoleLogger( Logger.LEVEL_DEBUG,
+                                                                                                 "test" ) ) ) );
     }
 
     private FileItemAssemblyPhase createPhase( final Logger logger )
@@ -410,75 +385,11 @@ public class FileItemAssemblyPhaseTest
         return phase;
     }
 
-    private final class MockAndControlForArchiver
-    {
-        final Archiver archiver;
-
-        public MockAndControlForArchiver( final EasyMockSupport mockManager )
-        {
-            archiver = mockManager.createMock( Archiver.class );
-        }
-
-        public void expectAddFile( final File file, final String outputLocation, final int fileMode )
-        {
-            try
-            {
-                archiver.addResource( (PlexusIoResource) anyObject(), (String) anyObject(), anyInt() );
-            }
-            catch ( final ArchiverException e )
-            {
-                Assert.fail( "Should never happen." );
-            }
-        }
-    }
-
-    private final class MockAndControlForConfigSource
+    private void prepareInterpolators( AssemblerConfigurationSource configSource )
     {
-        final AssemblerConfigurationSource configSource;
-
-        public MockAndControlForConfigSource( final EasyMockSupport mockManager )
-        {
-
-            configSource = mockManager.createMock( AssemblerConfigurationSource.class );
-
-            expect( configSource.getMavenSession() ).andReturn( null ).anyTimes();
-        }
-
-        public void expectGetProject( final MavenProject project )
-        {
-            expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
-        }
-
-        public void expectGetFinalName( final String finalName )
-        {
-            expect( configSource.getFinalName() ).andReturn( finalName ).atLeastOnce();
-        }
-
-        public void expectInterpolators()
-        {
-            expect( configSource.getCommandLinePropsInterpolator() ).andReturn(
-                FixedStringSearchInterpolator.empty() ).anyTimes();
-            expect( configSource.getEnvInterpolator() ).andReturn( FixedStringSearchInterpolator.empty() ).anyTimes();
-            expect( configSource.getMainProjectInterpolator() ).andReturn(
-                FixedStringSearchInterpolator.empty() ).anyTimes();
-        }
-
-
-        public void expectGetBasedir( final File basedir )
-        {
-            expect( configSource.getBasedir() ).andReturn( basedir ).atLeastOnce();
-        }
-    }
-
-    private final class MockAndControlForLogger
-    {
-        final Logger logger;
-
-        public MockAndControlForLogger( final EasyMockSupport mockManager )
-        {
-
-            logger = mockManager.createMock( Logger.class );
-        }
+        when( configSource.getCommandLinePropsInterpolator() ).thenReturn( FixedStringSearchInterpolator.empty() );
+        when( configSource.getEnvInterpolator() ).thenReturn( FixedStringSearchInterpolator.empty() );
+        when( configSource.getMainProjectInterpolator() ).thenReturn( FixedStringSearchInterpolator.empty() );
     }
 
 }