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/25 16:20:27 UTC
[maven-assembly-plugin] 03/04: Migrate all
AssemblerConfigurationSource to mockito
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch mockito
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git
commit d84f30ee929abc856942af07fceaeee9371dd9a5
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Apr 25 11:30:26 2020 +0200
Migrate all AssemblerConfigurationSource to mockito
---
.../archive/DefaultAssemblyArchiverTest.java | 206 +++++++++++----------
.../phase/DependencySetAssemblyPhaseTest.java | 7 +-
.../archive/phase/FileSetAssemblyPhaseTest.java | 29 +--
.../archive/phase/ModuleSetAssemblyPhaseTest.java | 159 ++++++++++------
.../archive/phase/RepositoryAssemblyPhaseTest.java | 49 ++---
.../assembly/archive/task/AddArtifactTaskTest.java | 27 ++-
.../archive/task/AddDependencySetsTaskTest.java | 52 ++++--
.../assembly/archive/task/AddFileSetsTaskTest.java | 44 +++--
.../artifact/DefaultDependencyResolverTest.java | 30 +--
.../AssemblyExpressionEvaluatorTest.java | 41 ++--
.../assembly/utils/AssemblyFormatUtilsTest.java | 23 ++-
11 files changed, 386 insertions(+), 281 deletions(-)
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java
index da79304..8770006 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/DefaultAssemblyArchiverTest.java
@@ -28,7 +28,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.File;
@@ -37,14 +40,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException;
import org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase;
-import org.apache.maven.plugins.assembly.artifact.DependencyResolutionException;
import org.apache.maven.plugins.assembly.artifact.DependencyResolver;
-import org.apache.maven.plugins.assembly.format.AssemblyFormattingException;
import org.apache.maven.plugins.assembly.model.Assembly;
import org.apache.maven.plugins.assembly.mojos.AbstractAssemblyMojo;
import org.apache.maven.project.MavenProject;
@@ -90,13 +90,9 @@ public class DefaultAssemblyArchiverTest
public static void setupInterpolators( AssemblerConfigurationSource configSource, MavenProject mavenProject )
{
-// when( configSource.getCommandLinePropsInterpolator() ).thenReturn( FixedStringSearchInterpolator.create() );
-// when( configSource.getEnvInterpolator() ).thenReturn( FixedStringSearchInterpolator.create() );
-// when( configSource.getMainProjectInterpolator() ).thenReturn( AbstractAssemblyMojo.mainProjectInterpolator( mavenProject ) );
-
- expect( configSource.getCommandLinePropsInterpolator() ).andReturn( FixedStringSearchInterpolator.create() ).atLeastOnce();
- expect( configSource.getEnvInterpolator() ).andReturn( FixedStringSearchInterpolator.create() ).atLeastOnce();
- expect( configSource.getMainProjectInterpolator() ).andReturn( AbstractAssemblyMojo.mainProjectInterpolator( mavenProject ) ).atLeastOnce();
+ when( configSource.getCommandLinePropsInterpolator() ).thenReturn( FixedStringSearchInterpolator.create() );
+ when( configSource.getEnvInterpolator() ).thenReturn( FixedStringSearchInterpolator.create() );
+ when( configSource.getMainProjectInterpolator() ).thenReturn( AbstractAssemblyMojo.mainProjectInterpolator( mavenProject ) );
}
@Before
@@ -108,27 +104,23 @@ public class DefaultAssemblyArchiverTest
@Test( expected = InvalidAssemblerConfigurationException.class )
public void failWhenAssemblyIdIsNull()
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
+ throws Exception
{
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver( mm );
- final AssemblerConfigurationSource configSource =
- mm.createControl().createMock( AssemblerConfigurationSource.class );
-
mm.replayAll();
final DefaultAssemblyArchiver archiver = createSubject( macMgr, null, null );
- archiver.createArchive( new Assembly(), "full-name", "zip", configSource, false, null, null );
+ archiver.createArchive( new Assembly(), "full-name", "zip", null, false, null, null );
mm.verifyAll();
}
@Test
public void testCreateArchive()
- throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException,
- IOException, DependencyResolutionException
+ throws Exception
{
final EasyMockSupport mm = new EasyMockSupport();
@@ -140,15 +132,8 @@ public class DefaultAssemblyArchiverTest
phase.execute( (Assembly) anyObject(), (Archiver) anyObject(), (AssemblerConfigurationSource) anyObject() );
- final AssemblerConfigurationSource configSource =
- mm.createControl().createMock( AssemblerConfigurationSource.class );
-
final File tempDir = new File ( temporaryFolder.getRoot(), "temp" );
- expect( configSource.getTemporaryRootDirectory() ).andReturn( tempDir );
- expect( configSource.isDryRun() ).andReturn( false );
- expect( configSource.isIgnoreDirFormatExtensions() ).andReturn( false );
-
final File outDir = temporaryFolder.newFolder( "out" );
macMgr.archiver.setDestFile( new File( outDir, "full-name.zip" ) );
@@ -162,43 +147,46 @@ public class DefaultAssemblyArchiverTest
fail( "Should never happen" );
}
- expect( configSource.getOverrideUid() ).andReturn( 0 ).atLeastOnce();
- expect( configSource.getOverrideUserName() ).andReturn( "root" ).atLeastOnce();
- expect( configSource.getOverrideGid() ).andReturn( 0 ).atLeastOnce();
- expect( configSource.getOverrideGroupName() ).andReturn( "root" ).atLeastOnce();
- expect( configSource.getOutputDirectory() ).andReturn( outDir );
- expect( configSource.getFinalName() ).andReturn( "finalName" );
- expect( configSource.getArchiverConfig() ).andReturn( null );
- expect( configSource.getWorkingDirectory() ).andReturn( new File( "." ) );
- expect( configSource.isUpdateOnly() ).andReturn( false ).times( 2 );
- expect( configSource.isIgnorePermissions() ).andReturn( false );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getTemporaryRootDirectory() ).thenReturn( tempDir );
+ when( configSource.getOverrideUid() ).thenReturn( 0 );
+ when( configSource.getOverrideUserName() ).thenReturn( "root" );
+ when( configSource.getOverrideGid() ).thenReturn( 0 );
+ when( configSource.getOverrideGroupName() ).thenReturn( "root" );
+ when( configSource.getOutputDirectory() ).thenReturn( outDir );
+ when( configSource.getFinalName() ).thenReturn( "finalName" );
+ when( configSource.getWorkingDirectory() ).thenReturn( new File( "." ) );
final Assembly assembly = new Assembly();
assembly.setId( "id" );
- // try
- // {
- // expect( macMgr.dependencyResolver.resolve( (Assembly) anyObject(), (AssemblerConfigurationSource)
- // anyObject() )).andReturn( new HashSet<Artifact>( ) );
-// macMgr.dependencyResolverControl.setMatcher( MockControl.ALWAYS_MATCHER );
- // }
- // catch ( final DependencyResolutionException e )
- // {
- // fail( "Should never happen" );
- // }
-
mm.replayAll();
final DefaultAssemblyArchiver subject = createSubject( macMgr, Collections.singletonList( phase ), null );
subject.createArchive( assembly, "full-name", "zip", configSource, false, null, null );
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiverConfig();
+ verify( configSource ).getFinalName();
+ verify( configSource ).getOutputDirectory();
+ verify( configSource, atLeastOnce() ).getOverrideUid();
+ verify( configSource, atLeastOnce() ).getOverrideUserName();
+ verify( configSource, atLeastOnce() ).getOverrideGid();
+ verify( configSource, atLeastOnce() ).getOverrideGroupName();
+ verify( configSource ).getTemporaryRootDirectory();
+ verify( configSource ).getWorkingDirectory();
+ verify( configSource ).isDryRun();
+ verify( configSource ).isIgnoreDirFormatExtensions();
+ verify( configSource ).isIgnorePermissions();
+ verify( configSource, times( 2 ) ).isUpdateOnly();
mm.verifyAll();
}
@Test
public void testCreateArchiver_ShouldConfigureArchiver()
- throws NoSuchArchiverException, ArchiverException
+ throws Exception
{
final EasyMockSupport mm = new EasyMockSupport();
@@ -242,7 +230,7 @@ public class DefaultAssemblyArchiverTest
@Test
public void testCreateArchiver_ShouldCreateTarArchiverWithNoCompression()
- throws NoSuchArchiverException, ArchiverException
+ throws Exception
{
final EasyMockSupport mm = new EasyMockSupport();
@@ -252,46 +240,42 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "tar", ttArchiver );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.getTarLongFileMode() ).andReturn( TarLongFileMode.fail.toString() );
- expect( configSource.isDryRun() ).andReturn( false );
-
- expect( configSource.getArchiverConfig() ).andReturn( null );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getTarLongFileMode() ).thenReturn( TarLongFileMode.fail.toString() );
+ when( configSource.getWorkingDirectory() ).thenReturn( new File( "." ) );
+ when( configSource.isIgnorePermissions() ).thenReturn( true );
+ when( configSource.getOverrideUid() ).thenReturn( 0 );
+ when( configSource.getOverrideUserName() ).thenReturn( "root" );
+ when( configSource.getOverrideGid() ).thenReturn( 0 );
+ when( configSource.getOverrideGroupName() ).thenReturn( "root" );
+
+ mm.replayAll();
- final DefaultAssemblyArchiver subject = setupStdExpectations( mm, macArchiverManager, configSource );
+ final DefaultAssemblyArchiver subject = createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
subject.createArchiver( "tar", false, "finalName", configSource, null, false, null, null );
assertNull( ttArchiver.compressionMethod );
assertEquals( TarLongFileMode.fail, ttArchiver.longFileMode );
- mm.verifyAll();
- }
-
- private DefaultAssemblyArchiver setupStdExpectations( EasyMockSupport mm,
- MockAndControlForAssemblyArchiver macArchiverManager,
- AssemblerConfigurationSource configSource )
- {
- expect( configSource.getWorkingDirectory() ).andReturn( new File( "." ) );
-
- expect( configSource.isUpdateOnly() ).andReturn( false ).times( 2 );
-
- expect( configSource.isIgnorePermissions() ).andReturn( true );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiverConfig();
+ verify( configSource, times( 2 ) ).getOverrideGid();
+ verify( configSource, times( 2 ) ).getOverrideGroupName();
+ verify( configSource, times( 2 ) ).getOverrideUid();
+ verify( configSource, times( 2 ) ).getOverrideUserName();
+ verify( configSource ).getTarLongFileMode();
+ verify( configSource ).getWorkingDirectory();
+ verify( configSource ).isDryRun();
+ verify( configSource ).isIgnorePermissions();
+ verify( configSource, times( 2 ) ).isUpdateOnly();
- expect( configSource.getOverrideUid() ).andReturn( 0 ).times( 2 );
- expect( configSource.getOverrideUserName() ).andReturn( "root" ).times( 2 );
- expect( configSource.getOverrideGid() ).andReturn( 0 ).times( 2 );
- expect( configSource.getOverrideGroupName() ).andReturn( "root" ).times( 2 );
-
- mm.replayAll();
-
- return createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
+ mm.verifyAll();
}
@Test
public void testCreateArchiver_ShouldCreateWarArchiverWithIgnoreWebxmlSetToFalse()
- throws NoSuchArchiverException, ArchiverException
+ throws Exception
{
final EasyMockSupport mm = new EasyMockSupport();
@@ -301,24 +285,42 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "war", twArchiver );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.isDryRun() ).andReturn( false );
- expect( configSource.getArchiverConfig() ).andReturn( null );
- expect( configSource.getMavenSession() ).andReturn( null );
- expect( configSource.getProject() ).andReturn( new MavenProject( new Model() ) );
- expect( configSource.getJarArchiveConfiguration() ).andReturn( null );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getOverrideGid() ).thenReturn( 0 );
+ when( configSource.getOverrideGroupName() ).thenReturn( "root" );
+ when( configSource.getOverrideUid() ).thenReturn( 0 );
+ when( configSource.getOverrideUserName() ).thenReturn( "root" );
+ when( configSource.getProject() ).thenReturn( new MavenProject( new Model() ) );
+ when( configSource.getWorkingDirectory() ).thenReturn( new File( "." ) );
+ when( configSource.isIgnorePermissions() ).thenReturn( true );
+
+ mm.replayAll();
- final DefaultAssemblyArchiver subject = setupStdExpectations( mm, macArchiverManager, configSource );
+ final DefaultAssemblyArchiver subject = createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
subject.createArchiver( "war", false, null, configSource, null, false, null, null );
assertFalse( twArchiver.ignoreWebxml );
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiverConfig();
+ verify( configSource ).getJarArchiveConfiguration();
+ verify( configSource ).getMavenSession();
+ verify( configSource, times( 2 ) ).getOverrideGid();
+ verify( configSource, times( 2 ) ).getOverrideGroupName();
+ verify( configSource, times( 2 ) ).getOverrideUid();
+ verify( configSource, times( 2 ) ).getOverrideUserName();
+ verify( configSource ).getProject();
+ verify( configSource ).getWorkingDirectory();
+ verify( configSource ).isDryRun();
+ verify( configSource ).isIgnorePermissions();
+ verify( configSource, times( 2 ) ).isUpdateOnly();
+
}
@Test
public void testCreateArchiver_ShouldCreateZipArchiver()
- throws NoSuchArchiverException, ArchiverException
+ throws Exception
{
final EasyMockSupport mm = new EasyMockSupport();
@@ -328,19 +330,13 @@ public class DefaultAssemblyArchiverTest
macArchiverManager.expectGetArchiver( "zip", archiver );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.isDryRun() ).andReturn( false );
- expect( configSource.getArchiverConfig() ).andReturn( null );
- expect( configSource.getWorkingDirectory() ).andReturn( new File( "." ) );
- expect( configSource.isUpdateOnly() ).andReturn( false ).times( 2 );
- expect( configSource.getJarArchiveConfiguration() ).andReturn( null );
- expect( configSource.isIgnorePermissions() ).andReturn( true );
-
- expect( configSource.getOverrideUid() ).andReturn( 0 ).times( 2 );
- expect( configSource.getOverrideUserName() ).andReturn( "root" ).times( 2 );
- expect( configSource.getOverrideGid() ).andReturn( 0 ).times( 2 );
- expect( configSource.getOverrideGroupName() ).andReturn( "root" ).times( 2 );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getOverrideGid() ).thenReturn( 0 );
+ when( configSource.getOverrideGroupName() ).thenReturn( "root" );
+ when( configSource.getOverrideUid() ).thenReturn( 0 );
+ when( configSource.getOverrideUserName() ).thenReturn( "root" );
+ when( configSource.getWorkingDirectory() ).thenReturn( new File( "." ) );
+ when( configSource.isIgnorePermissions() ).thenReturn( true );
mm.replayAll();
@@ -348,6 +344,17 @@ public class DefaultAssemblyArchiverTest
createSubject( macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null );
subject.createArchiver( "zip", false, null, configSource, null, false, null, null );
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiverConfig();
+ verify( configSource, times( 2 ) ).getOverrideGid();
+ verify( configSource, times( 2 ) ).getOverrideGroupName();
+ verify( configSource, times( 2 ) ).getOverrideUid();
+ verify( configSource, times( 2 ) ).getOverrideUserName();
+ verify( configSource ).getWorkingDirectory();
+ verify( configSource ).isDryRun();
+ verify( configSource ).isIgnorePermissions();
+ verify( configSource, times( 2 ) ).isUpdateOnly();
}
@Test
@@ -634,11 +641,6 @@ public class DefaultAssemblyArchiverTest
}
- void expectGetDestFile( final File file )
- {
- expect( archiver.getDestFile() ).andReturn( file );
- }
-
void createArchiver( final Class<? extends Archiver> archiverClass )
{
archiver = mm.createControl().createMock( archiverClass );
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java
index 93835b6..13e361a 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/DependencySetAssemblyPhaseTest.java
@@ -78,8 +78,6 @@ public class DependencySetAssemblyPhaseTest
final MockAndControlForAddDependencySetsTask macTask =
new MockAndControlForAddDependencySetsTask( mm, project );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
project.setArtifacts( Collections.singleton( artifact ) );
final Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
@@ -89,7 +87,7 @@ public class DependencySetAssemblyPhaseTest
mm.replayAll();
createPhase( macTask, logger, macTask.dependencyResolver ).execute( assembly, macTask.archiver,
- configSource );
+ null );
mm.verifyAll();
}
@@ -117,13 +115,12 @@ public class DependencySetAssemblyPhaseTest
final Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask( mm, null );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
macTask.expectResolveDependencySets();
mm.replayAll();
- createPhase( macTask, logger, macTask.dependencyResolver ).execute( assembly, null, configSource );
+ createPhase( macTask, logger, macTask.dependencyResolver ).execute( assembly, null, null );
mm.verifyAll();
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhaseTest.java
index 080b0ce..b9cfc0d 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileSetAssemblyPhaseTest.java
@@ -20,7 +20,9 @@ package org.apache.maven.plugins.assembly.archive.phase;
*/
import static org.easymock.EasyMock.expect;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.maven.model.Model;
@@ -63,11 +65,10 @@ public class FileSetAssemblyPhaseTest
assembly.setId( "test" );
final MockAndControlForAddFileSetsTask macTask = new MockAndControlForAddFileSetsTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
mm.replayAll();
- this.phase.execute( assembly, macTask.archiver, configSource );
+ this.phase.execute( assembly, macTask.archiver, null );
mm.verifyAll();
}
@@ -90,9 +91,6 @@ public class FileSetAssemblyPhaseTest
assembly.addFileSet( fs );
final MockAndControlForAddFileSetsTask macTask = new MockAndControlForAddFileSetsTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.getArchiveBaseDirectory() ).andReturn( null );
final MavenProject project = new MavenProject( new Model() );
@@ -102,15 +100,12 @@ public class FileSetAssemblyPhaseTest
final int[] modes = { -1, -1, dirMode, fileMode };
// the logger sends a debug message with this info inside the addFileSet(..) method..
- if ( true )
- {
- expect( macTask.archiver.getOverrideDirectoryMode() ).andReturn( modes[0] );
- expect( macTask.archiver.getOverrideFileMode() ).andReturn( modes[1] );
- }
-
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
+ expect( macTask.archiver.getOverrideDirectoryMode() ).andReturn( modes[0] );
+ expect( macTask.archiver.getOverrideFileMode() ).andReturn( modes[1] );
+
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getProject() ).thenReturn( project );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
DefaultAssemblyArchiverTest.setupInterpolators( configSource, project );
@@ -118,6 +113,12 @@ public class FileSetAssemblyPhaseTest
this.phase.execute( assembly, macTask.archiver, configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiveBaseDirectory();
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
index b459800..35073d7 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhaseTest.java
@@ -26,8 +26,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
import java.io.File;
import java.util.ArrayList;
@@ -139,11 +141,8 @@ public class ModuleSetAssemblyPhaseTest
final MavenProject project = new MavenProject( model );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.getFinalName() ).andReturn( null ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getProject() ).thenReturn( project );
final FileSet fs = new FileSet();
@@ -171,6 +170,11 @@ public class ModuleSetAssemblyPhaseTest
assertEquals( "artifact/", result.getOutputDirectory() );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -185,11 +189,8 @@ public class ModuleSetAssemblyPhaseTest
final MavenProject project = new MavenProject( model );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.getFinalName() ).andReturn( null ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getProject() ).thenReturn( project );
final FileSet fs = new FileSet();
fs.setOutputDirectory( "out" );
@@ -218,6 +219,11 @@ public class ModuleSetAssemblyPhaseTest
assertEquals( "artifact/out/", result.getOutputDirectory() );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -227,11 +233,7 @@ public class ModuleSetAssemblyPhaseTest
{
final EasyMockSupport mm = new EasyMockSupport();
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
-
- expect( configSource.getFinalName() ).andReturn( null ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( null ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
final FileSet fs = new FileSet();
@@ -263,6 +265,11 @@ public class ModuleSetAssemblyPhaseTest
assertEquals( 1, result.getExcludes().size() );
assertEquals( "submodule/**", result.getExcludes().get( 0 ) );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -285,7 +292,6 @@ public class ModuleSetAssemblyPhaseTest
final MavenProject project = createProject( "group", "artifact", "version", null );
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
final MavenProject module = createProject( "group", "module", "version", project );
@@ -298,9 +304,11 @@ public class ModuleSetAssemblyPhaseTest
projects.add( module );
- expect( configSource.getReactorProjects() ).andReturn( projects ).atLeastOnce();
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getReactorProjects() ).thenReturn( projects );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
+ when( configSource.getProject() ).thenReturn( project );
+
macTask.expectGetDestFile( new File( "junk" ) );
expect( macTask.archiver.getOverrideDirectoryMode() ).andReturn( 0777 );
expect( macTask.archiver.getOverrideFileMode() ).andReturn( 0777 );
@@ -331,7 +339,6 @@ public class ModuleSetAssemblyPhaseTest
final Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
macTask.expectResolveDependencySets();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
DefaultAssemblyArchiverTest.setupInterpolators( configSource, module );
mm.replayAll();
@@ -339,6 +346,12 @@ public class ModuleSetAssemblyPhaseTest
final ModuleSetAssemblyPhase phase = createPhase( logger, macTask.dependencyResolver, null );
phase.execute( assembly, macTask.archiver, configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+ verify( configSource, atLeastOnce() ).getReactorProjects();
+
mm.verifyAll();
}
@@ -356,7 +369,6 @@ public class ModuleSetAssemblyPhaseTest
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
final ModuleBinaries binaries = new ModuleBinaries();
@@ -378,7 +390,7 @@ public class ModuleSetAssemblyPhaseTest
createPhase( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ), null ).addModuleBinaries( null, null, binaries,
projects,
macTask.archiver,
- configSource );
+ null );
mm.verifyAll();
}
@@ -390,16 +402,14 @@ public class ModuleSetAssemblyPhaseTest
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
Artifact artifact = mock( Artifact.class );
when( artifact.getClassifier() ).thenReturn( "test" );
final File artifactFile = temporaryFolder.newFile();
when( artifact.getFile() ).thenReturn( artifactFile );
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( null ).atLeastOnce();
macTask.expectGetDestFile( new File( "junk" ) );
expect( macTask.archiver.getOverrideDirectoryMode() ).andReturn( 0222 );
expect( macTask.archiver.getOverrideFileMode() ).andReturn( 0222 );
@@ -434,6 +444,11 @@ public class ModuleSetAssemblyPhaseTest
macTask.archiver,
configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -444,7 +459,6 @@ public class ModuleSetAssemblyPhaseTest
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
Artifact artifact = mock( Artifact.class );
@@ -468,7 +482,7 @@ public class ModuleSetAssemblyPhaseTest
try
{
createPhase( logger, null ).addModuleBinaries( null, null, binaries, projects, macTask.archiver,
- configSource );
+ null );
fail( "Should throw an invalid configuration exception because of module with missing attachment." );
}
@@ -489,15 +503,13 @@ public class ModuleSetAssemblyPhaseTest
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask( mm );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
Artifact artifact = mock( Artifact.class );
final File artifactFile = temporaryFolder.newFile();
when( artifact.getFile() ).thenReturn( artifactFile );
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( null ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
macTask.expectGetDestFile( new File( "junk" ) );
macTask.expectAddFile( artifactFile, "out/artifact",
@@ -532,6 +544,11 @@ public class ModuleSetAssemblyPhaseTest
macTask.archiver,
configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -568,10 +585,8 @@ public class ModuleSetAssemblyPhaseTest
final MavenProject project = createProject( "group", "artifact", "version", null );
project.setArtifact( artifact );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( null ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
macTask.expectGetDestFile( new File( "junk" ) );
expect( macTask.archiver.getOverrideDirectoryMode() ).andReturn( 0222 );
@@ -596,6 +611,11 @@ public class ModuleSetAssemblyPhaseTest
null ).addModuleArtifact( artifact, project, macTask.archiver,
configSource, binaries );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -617,10 +637,9 @@ public class ModuleSetAssemblyPhaseTest
final MavenProject project = createProject( "group", "artifact", "version", null );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
-
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
+ when( configSource.getProject() ).thenReturn( project );
project.setArtifact( mock( Artifact.class ) );
final Set<MavenProject> projects = singleton( project );
@@ -634,8 +653,6 @@ public class ModuleSetAssemblyPhaseTest
sources.addFileSet( fs );
- expect( configSource.getArchiveBaseDirectory() ).andReturn( null );
-
final int mode = TypeConversionUtils.modeToInt( "777", new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
final int[] modes = { -1, -1, mode, mode };
@@ -646,7 +663,7 @@ public class ModuleSetAssemblyPhaseTest
expect( macTask.archiver.getOverrideFileMode() ).andReturn( modes[1] );
}
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
+
DefaultAssemblyArchiverTest.setupInterpolators( configSource, project );
@@ -657,6 +674,12 @@ public class ModuleSetAssemblyPhaseTest
createPhase( logger, null ).addModuleSourceFileSets( sources, projects, macTask.archiver,
configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiveBaseDirectory();
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getProject();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+
mm.verifyAll();
}
@@ -670,9 +693,9 @@ public class ModuleSetAssemblyPhaseTest
final List<MavenProject> projects = Collections.singletonList( project );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getReactorProjects() ).andReturn( projects );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getProject() ).thenReturn( project );
+ when( configSource.getReactorProjects() ).thenReturn( projects );
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules( true );
@@ -684,6 +707,10 @@ public class ModuleSetAssemblyPhaseTest
assertTrue( moduleProjects.isEmpty() );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getReactorProjects();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -700,9 +727,9 @@ public class ModuleSetAssemblyPhaseTest
projects.add( project );
projects.add( project2 );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getReactorProjects() ).andReturn( projects );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getReactorProjects() ).thenReturn( projects );
+ when( configSource.getProject() ).thenReturn( project );
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules( true );
@@ -714,6 +741,10 @@ public class ModuleSetAssemblyPhaseTest
assertTrue( moduleProjects.isEmpty() );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getReactorProjects();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -730,9 +761,9 @@ public class ModuleSetAssemblyPhaseTest
projects.add( project );
projects.add( project2 );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getReactorProjects() ).andReturn( projects );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getReactorProjects() ).thenReturn( projects );
+ when( configSource.getProject() ).thenReturn( project );
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules( true );
@@ -748,6 +779,10 @@ public class ModuleSetAssemblyPhaseTest
assertEquals( "artifact2", result.getArtifactId() );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getReactorProjects();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -766,9 +801,9 @@ public class ModuleSetAssemblyPhaseTest
projects.add( project2 );
projects.add( project3 );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getReactorProjects() ).andReturn( projects );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getReactorProjects() ).thenReturn( projects );
+ when( configSource.getProject() ).thenReturn( project );
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules( true );
@@ -786,6 +821,10 @@ public class ModuleSetAssemblyPhaseTest
verifyResultIs( check, moduleProjects );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getReactorProjects();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
@@ -822,9 +861,9 @@ public class ModuleSetAssemblyPhaseTest
projects.add( project2 );
projects.add( project3 );
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getReactorProjects() ).andReturn( projects );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getReactorProjects() ).thenReturn( projects );
+ when( configSource.getProject() ).thenReturn( project );
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules( true );
@@ -838,6 +877,10 @@ public class ModuleSetAssemblyPhaseTest
assertTrue( moduleProjects.isEmpty() );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getReactorProjects();
+ verify( configSource, atLeastOnce() ).getProject();
+
mm.verifyAll();
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/RepositoryAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
index db69778..830c1ca 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/RepositoryAssemblyPhaseTest.java
@@ -22,6 +22,10 @@ package org.apache.maven.plugins.assembly.archive.phase;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.File;
@@ -67,8 +71,8 @@ public class RepositoryAssemblyPhaseTest
final File tempRoot = temporaryFolder.getRoot();
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getTemporaryRootDirectory() ).andReturn( tempRoot ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getTemporaryRootDirectory() ).thenReturn( tempRoot );
final Assembly assembly = new Assembly();
@@ -79,6 +83,9 @@ public class RepositoryAssemblyPhaseTest
createPhase( macRepo.repositoryAssembler, new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) ).execute( assembly,
macArchiver.archiver,
configSource );
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getTemporaryRootDirectory();
mm.verifyAll();
}
@@ -94,16 +101,13 @@ public class RepositoryAssemblyPhaseTest
final File tempRoot = temporaryFolder.getRoot();
- final AssemblerConfigurationSource configSource = mm.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getMavenSession() ).andReturn( null );
- expect( configSource.getTemporaryRootDirectory() ).andReturn( tempRoot ).atLeastOnce();
- expect( configSource.getProject() ).andReturn( new MavenProject( new Model() ) ).atLeastOnce();
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
- expect( configSource.getCommandLinePropsInterpolator() ).andReturn(
- FixedStringSearchInterpolator.empty() );
- expect( configSource.getEnvInterpolator() ).andReturn( FixedStringSearchInterpolator.empty() );
- expect( configSource.getMainProjectInterpolator() ).andReturn(
- FixedStringSearchInterpolator.empty() );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getCommandLinePropsInterpolator() ).thenReturn( FixedStringSearchInterpolator.empty() );
+ when( configSource.getEnvInterpolator() ).thenReturn( FixedStringSearchInterpolator.empty() );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
+ when( configSource.getMainProjectInterpolator() ).thenReturn( FixedStringSearchInterpolator.empty() );
+ when( configSource.getProject() ).thenReturn( new MavenProject( new Model() ) );
+ when( configSource.getTemporaryRootDirectory() ).thenReturn( tempRoot );
final Assembly assembly = new Assembly();
@@ -132,6 +136,15 @@ public class RepositoryAssemblyPhaseTest
macArchiver.archiver,
configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getCommandLinePropsInterpolator();
+ verify( configSource ).getEnvInterpolator();
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource ).getMainProjectInterpolator();
+ verify( configSource ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+ verify( configSource, atLeastOnce() ).getTemporaryRootDirectory();
+
mm.verifyAll();
}
@@ -190,18 +203,6 @@ public class RepositoryAssemblyPhaseTest
archiver.setDirectoryMode( defaultDirMode );
archiver.setFileMode( 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 MockAndControlForRepositoryAssembler
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTaskTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTaskTest.java
index d5d1e49..3e44596 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTaskTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddArtifactTaskTest.java
@@ -22,7 +22,9 @@ package org.apache.maven.plugins.assembly.archive.task;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.File;
@@ -46,6 +48,7 @@ import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.easymock.classextension.EasyMockSupport;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -81,9 +84,17 @@ public class AddArtifactTaskTest
this.mainProject = new MavenProject( model );
mac = new MockAndControlForAddArtifactTask( mockManager );
- this.configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getFinalName() ).andReturn( "final-name" ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
+
+ this.configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
+ }
+
+ @After
+ public void tearDown()
+ {
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
}
@Test
@@ -101,7 +112,7 @@ public class AddArtifactTaskTest
mac.expectGetDestFile( new File( "junk" ) );
mac.expectAddFile( artifactFile, outputLocation );
- expect( configSource.getProject() ).andReturn( mainProject ).atLeastOnce();
+ when( configSource.getProject() ).thenReturn( mainProject );
DefaultAssemblyArchiverTest.setupInterpolators( configSource, mainProject );
mockManager.replayAll();
@@ -110,6 +121,9 @@ public class AddArtifactTaskTest
task.execute( mac.archiver, configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getProject();
+
mockManager.verifyAll();
}
@@ -134,7 +148,7 @@ public class AddArtifactTaskTest
mac.expectGetDestFile( new File( "junk" ) );
mac.expectAddFile( artifactFile, outputDir + artifactId + "-" + version + "." + ext );
- expect( configSource.getProject() ).andReturn( mainProject ).atLeastOnce();
+ when( configSource.getProject() ).thenReturn( mainProject );
DefaultAssemblyArchiverTest.setupInterpolators( configSource, mainProject );
mockManager.replayAll();
@@ -152,6 +166,9 @@ public class AddArtifactTaskTest
task.execute( mac.archiver, configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getProject();
+
mockManager.verifyAll();
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
index 1375a22..e03ad81 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddDependencySetsTaskTest.java
@@ -24,7 +24,9 @@ import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.maven.artifact.Artifact;
@@ -115,16 +117,16 @@ public class AddDependencySetsTaskTest
new MockAndControlForAddDependencySetsTask( mockManager, mainProject );
macTask.expectBuildFromRepository( depProject );
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getFinalName() ).andReturn( mainAid + "-" + mainVer );
- expect( configSource.getProject() ).andReturn( mainProject ).atLeastOnce();
final MavenSession session = mockManager.createMock( MavenSession.class );
final ProjectBuildingRequest projectBuildingRequest = mockManager.createMock( ProjectBuildingRequest.class );
-
expect( session.getProjectBuildingRequest() ).andReturn( projectBuildingRequest );
expect( session.getExecutionProperties() ).andReturn( new Properties() ).times( 2 );
- expect( configSource.getMavenSession() ).andReturn( session ).atLeastOnce();
+
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( mainAid + "-" + mainVer );
+ when( configSource.getProject() ).thenReturn( mainProject );
+ when( configSource.getMavenSession() ).thenReturn( session );
macTask.expectGetDestFile( new File( "junk" ) );
macTask.expectAddFile( newFile, outDir + depAid + "-" + depVer + "." + depExt, 10 );
@@ -147,6 +149,11 @@ public class AddDependencySetsTaskTest
depProject, macTask.projectBuilder, logger );
task.addDependencySet( ds, macTask.archiver, configSource );
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
mockManager.verifyAll();
}
@@ -159,7 +166,6 @@ public class AddDependencySetsTaskTest
final MockAndControlForAddDependencySetsTask macTask =
new MockAndControlForAddDependencySetsTask( mockManager );
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
final DependencySet ds = new DependencySet();
ds.setOutputDirectory( "/out" );
@@ -171,7 +177,7 @@ public class AddDependencySetsTaskTest
final AddDependencySetsTask task =
new AddDependencySetsTask( Collections.singletonList( ds ), null, project, macTask.projectBuilder, logger );
- task.addDependencySet( ds, null, configSource );
+ task.addDependencySet( ds, null, null );
mockManager.verifyAll();
}
@@ -206,15 +212,16 @@ public class AddDependencySetsTaskTest
macTask.expectGetDestFile( destFile );
macTask.expectBuildFromRepository( pbe );
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
- expect( configSource.getFinalName() ).andReturn( "final-name" );
final MavenSession session = mockManager.createMock( MavenSession.class );
final ProjectBuildingRequest projectBuildingRequest = mockManager.createMock( ProjectBuildingRequest.class );
expect( session.getProjectBuildingRequest() ).andReturn( projectBuildingRequest );
expect( session.getExecutionProperties() ).andReturn( new Properties() ).times( 2 );
- expect( configSource.getMavenSession() ).andReturn( session ).atLeastOnce();
+
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
+ when( configSource.getMavenSession() ).thenReturn( session );
+ when( configSource.getProject() ).thenReturn( project );
macTask.expectAddFile( file, "out/" + aid + "-" + version + "." + type );
@@ -235,6 +242,11 @@ public class AddDependencySetsTaskTest
task.addDependencySet( ds, macTask.archiver, configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+ verify( configSource, atLeastOnce() ).getProject();
+
mockManager.verifyAll();
}
@@ -271,13 +283,15 @@ public class AddDependencySetsTaskTest
final MockAndControlForAddDependencySetsTask macTask =
new MockAndControlForAddDependencySetsTask( mockManager, project );
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
final MavenSession session = mockManager.createMock( MavenSession.class );
final ProjectBuildingRequest projectBuildingRequest = mockManager.createMock( ProjectBuildingRequest.class );
expect( session.getProjectBuildingRequest() ).andReturn( projectBuildingRequest );
- expect( configSource.getMavenSession() ).andReturn( session ).atLeastOnce();
+
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getMavenSession() ).thenReturn( session );
+ when( configSource.getFinalName() ).thenReturn( "final-name" );
Artifact artifact = mock( Artifact.class );
final File artifactFile = temporaryFolder.newFile();
@@ -291,12 +305,11 @@ public class AddDependencySetsTaskTest
else
{
expect( session.getExecutionProperties() ).andReturn( new Properties() ).times( 2 );
- expect( configSource.getProject() ).andReturn( project ).atLeastOnce();
+ when( configSource.getProject() ).thenReturn( project );
macTask.expectAddFile( artifactFile, outputLocation + "/artifact", 10 );
}
macTask.expectGetDestFile( new File( "junk" ) );
- expect( configSource.getFinalName() ).andReturn( "final-name" );
final MavenProject depProject = new MavenProject( new Model() );
@@ -320,6 +333,15 @@ public class AddDependencySetsTaskTest
task.addDependencySet( ds, macTask.archiver, configSource );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+
+ if ( !unpack )
+ {
+ verify( configSource, atLeastOnce() ).getProject();
+ }
+
mockManager.verifyAll();
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTaskTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTaskTest.java
index b628c2f..df9042a 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTaskTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTaskTest.java
@@ -19,10 +19,14 @@ package org.apache.maven.plugins.assembly.archive.task;
* under the License.
*/
-import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.anyObject;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.util.ArrayList;
@@ -153,9 +157,7 @@ public class AddFileSetsTaskTest
expect( macTask.archiver.getOverrideFileMode() ).andReturn( modes[1] );
}
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getFinalName() ).andReturn( null ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
macTask.expectModeChanges( modes, 1 );
@@ -174,6 +176,10 @@ public class AddFileSetsTaskTest
task.addFileSet( fs, macTask.archiver, configSource, null );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+
mockManager.verifyAll();
}
@@ -202,9 +208,7 @@ public class AddFileSetsTaskTest
expect( macTask.archiver.getOverrideFileMode() ).andReturn( modes[1] );
}
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getFinalName() ).andReturn( null ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
macTask.expectModeChanges( modes, 1 );
@@ -223,6 +227,10 @@ public class AddFileSetsTaskTest
task.addFileSet( fs, macTask.archiver, configSource, archiveBaseDir );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+
mockManager.verifyAll();
}
@@ -238,9 +246,8 @@ public class AddFileSetsTaskTest
final File archiveBaseDir = temporaryFolder.newFolder();
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getFinalName() ).andReturn( "finalName" ).atLeastOnce();
- expect( configSource.getMavenSession() ).andReturn( null ).atLeastOnce();
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getFinalName() ).thenReturn( "finalName" );
//macTask.expectGetProject( null );
@@ -259,6 +266,10 @@ public class AddFileSetsTaskTest
task.addFileSet( fs, macTask.archiver, configSource, archiveBaseDir );
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource, atLeastOnce() ).getFinalName();
+ verify( configSource, atLeastOnce() ).getMavenSession();
+
mockManager.verifyAll();
}
@@ -267,8 +278,8 @@ public class AddFileSetsTaskTest
throws Exception
{
File archiveBaseDir = new File( temporaryFolder.getRoot(), "archive");
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getArchiveBaseDirectory() ).andReturn( archiveBaseDir );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getArchiveBaseDirectory() ).thenReturn( archiveBaseDir );
mockManager.replayAll();
@@ -285,6 +296,9 @@ public class AddFileSetsTaskTest
// should do this, because it cannot use the provide archiveBasedir.
}
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( configSource ).getArchiveBaseDirectory();
+
mockManager.verifyAll();
}
@@ -293,8 +307,8 @@ public class AddFileSetsTaskTest
throws Exception
{
File archiveBaseDir = temporaryFolder.newFile();
- final AssemblerConfigurationSource configSource = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( configSource.getArchiveBaseDirectory() ).andReturn( archiveBaseDir );
+ final AssemblerConfigurationSource configSource = mock( AssemblerConfigurationSource.class );
+ when( configSource.getArchiveBaseDirectory() ).thenReturn( archiveBaseDir );
mockManager.replayAll();
@@ -312,6 +326,8 @@ public class AddFileSetsTaskTest
}
mockManager.verifyAll();
+
+ verify( configSource ).getArchiveBaseDirectory();
}
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java b/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
index 52ab6c0..66e8ecb 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
@@ -19,7 +19,9 @@ package org.apache.maven.plugins.assembly.artifact;
* under the License.
*/
-import static org.easymock.EasyMock.expect;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.util.Arrays;
@@ -46,7 +48,6 @@ import org.apache.maven.plugins.assembly.model.ModuleSet;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.codehaus.plexus.PlexusTestCase;
-import org.easymock.classextension.EasyMockSupport;
public class DefaultDependencyResolverTest
extends PlexusTestCase
@@ -124,10 +125,6 @@ public class DefaultDependencyResolverTest
public void test_getModuleSetResolutionRequirements_withoutBinaries()
throws DependencyResolutionException
{
- final EasyMockSupport mm = new EasyMockSupport();
-
- final AssemblerConfigurationSource cs = mm.createMock( AssemblerConfigurationSource.class );
-
final File rootDir = new File( "root" );
final MavenProject project = createMavenProject( "main-group", "main-artifact", "1", rootDir );
final MavenProject module1 =
@@ -143,21 +140,13 @@ public class DefaultDependencyResolverTest
final ModuleSet ms = new ModuleSet();
ms.setBinaries( null );
- mm.replayAll();
-
- resolver.updateModuleSetResolutionRequirements( ms, new DependencySet(), info, cs );
+ resolver.updateModuleSetResolutionRequirements( ms, new DependencySet(), info, null );
assertTrue( info.getArtifacts().isEmpty() );
-
- mm.verifyAll();
}
public void test_getModuleSetResolutionRequirements_includeDeps()
throws DependencyResolutionException
{
- final EasyMockSupport mm = new EasyMockSupport();
-
- final AssemblerConfigurationSource cs = mm.createMock( AssemblerConfigurationSource.class );
-
final File rootDir = new File( "root" );
final MavenProject project = createMavenProject( "main-group", "main-artifact", "1", rootDir );
final MavenProject module1 =
@@ -173,8 +162,9 @@ public class DefaultDependencyResolverTest
project.getModel().addModule( module1.getArtifactId() );
project.getModel().addModule( module2.getArtifactId() );
- expect( cs.getReactorProjects() ).andReturn( Arrays.asList( project, module1, module2 ) );
- expect( cs.getProject() ).andReturn( project );
+ final AssemblerConfigurationSource cs = mock( AssemblerConfigurationSource.class );
+ when( cs.getReactorProjects() ).thenReturn( Arrays.asList( project, module1, module2 ) );
+ when( cs.getProject() ).thenReturn( project );
final ResolutionManagementInfo info = new ResolutionManagementInfo();
@@ -184,12 +174,12 @@ public class DefaultDependencyResolverTest
ms.setBinaries( mb );
ms.addInclude( "*:module-1" );
- mm.replayAll();
-
resolver.updateModuleSetResolutionRequirements( ms, new DependencySet(), info, cs );
assertEquals( module1Artifacts, info.getArtifacts() );
- mm.verifyAll();
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( cs ).getReactorProjects();
+ verify( cs ).getProject();
}
private MavenProject createMavenProject( final String groupId, final String artifactId, final String version,
diff --git a/src/test/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluatorTest.java b/src/test/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluatorTest.java
index e947678..b00e401 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluatorTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/interpolation/AssemblyExpressionEvaluatorTest.java
@@ -19,7 +19,10 @@ package org.apache.maven.plugins.assembly.interpolation;
* under the License.
*/
-import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
import java.util.Properties;
@@ -31,16 +34,16 @@ import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
import org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource;
-import org.easymock.classextension.EasyMockSupport;
-
-import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+@RunWith( MockitoJUnitRunner.class )
public class AssemblyExpressionEvaluatorTest
- extends TestCase
{
-
private final PojoConfigSource configSourceStub = new PojoConfigSource();
+ @Test
public void testShouldResolveModelGroupId()
throws ExpressionEvaluationException
{
@@ -63,9 +66,9 @@ public class AssemblyExpressionEvaluatorTest
configSourceStub.setRootInterpolator( FixedStringSearchInterpolator.create() );
configSourceStub.setEnvironmentInterpolator( FixedStringSearchInterpolator.create() );
configSourceStub.setEnvInterpolator( FixedStringSearchInterpolator.create() );
-
}
+ @Test
public void testShouldResolveModelPropertyBeforeModelGroupId()
throws ExpressionEvaluationException
{
@@ -88,6 +91,7 @@ public class AssemblyExpressionEvaluatorTest
assertEquals( "assembly.other.id", result );
}
+ @Test
public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId()
throws ExpressionEvaluationException
{
@@ -102,29 +106,29 @@ public class AssemblyExpressionEvaluatorTest
model.setProperties( props );
- final EasyMockSupport mm = new EasyMockSupport();
-
final Properties execProps = new Properties();
execProps.setProperty( "groupId", "still.another.id" );
PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource( execProps );
- AssemblerConfigurationSource cs = mm.createControl().createMock( AssemblerConfigurationSource.class );
- expect( cs.getCommandLinePropsInterpolator() ).andReturn(
- FixedStringSearchInterpolator.create( cliProps ) );
- expect( cs.getRepositoryInterpolator() ).andReturn( FixedStringSearchInterpolator.create() );
- expect( cs.getEnvInterpolator() ).andReturn( FixedStringSearchInterpolator.create() );
- expect( cs.getProject() ).andReturn( new MavenProject( model ) );
-
- mm.replayAll();
+ AssemblerConfigurationSource cs = mock( AssemblerConfigurationSource.class );
+ when( cs.getCommandLinePropsInterpolator() ).thenReturn( FixedStringSearchInterpolator.create( cliProps ) );
+ when( cs.getRepositoryInterpolator() ).thenReturn( FixedStringSearchInterpolator.create() );
+ when( cs.getEnvInterpolator() ).thenReturn( FixedStringSearchInterpolator.create() );
+ when( cs.getProject() ).thenReturn( new MavenProject( model ) );
final Object result = new AssemblyExpressionEvaluator( cs ).evaluate( "assembly.${groupId}" );
assertEquals( "assembly.still.another.id", result );
- mm.verifyAll();
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( cs ).getCommandLinePropsInterpolator();
+ verify( cs ).getRepositoryInterpolator();
+ verify( cs ).getEnvInterpolator();
+ verify( cs ).getProject();
}
+ @Test
public void testShouldReturnUnchangedInputForUnresolvedExpression()
throws ExpressionEvaluationException
{
@@ -142,6 +146,7 @@ public class AssemblyExpressionEvaluatorTest
assertEquals( "assembly.${unresolved}", result );
}
+ @Test
public void testShouldInterpolateMultiDotProjectExpression()
throws ExpressionEvaluationException
{
diff --git a/src/test/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtilsTest.java b/src/test/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtilsTest.java
index 8e91d05..4fe72fb 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtilsTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/utils/AssemblyFormatUtilsTest.java
@@ -348,8 +348,8 @@ public class AssemblyFormatUtilsTest
final MavenSession session = mock( MavenSession.class );
- final AssemblerConfigurationSource cs = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( cs.getMavenSession() ).andReturn( session );
+ final AssemblerConfigurationSource cs = mock( AssemblerConfigurationSource.class );
+ when( cs.getMavenSession() ).thenReturn( session );
DefaultAssemblyArchiverTest.setupInterpolators( cs, mainProject );
mockManager.replayAll();
@@ -366,6 +366,9 @@ public class AssemblyFormatUtilsTest
// clear out for next call.
mockManager.resetAll();
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( cs ).getMavenSession();
}
@Test
@@ -685,8 +688,9 @@ public class AssemblyFormatUtilsTest
final MavenSession session = mock( MavenSession.class );
when( session.getExecutionProperties() ).thenReturn( System.getProperties() );
- final AssemblerConfigurationSource cs = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( cs.getMavenSession() ).andReturn( session );
+ final AssemblerConfigurationSource cs = mock( AssemblerConfigurationSource.class );
+ when( cs.getMavenSession() ).thenReturn( session );
+
DefaultAssemblyArchiverTest.setupInterpolators( cs, mainProject );
mockManager.replayAll();
@@ -703,6 +707,9 @@ public class AssemblyFormatUtilsTest
// clear out for next call.
mockManager.resetAll();
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( cs ).getMavenSession();
}
private void verifyOutputDir( final String outDir, final String finalName, final String projectFinalName,
@@ -787,8 +794,9 @@ public class AssemblyFormatUtilsTest
final MavenSession session = mock( MavenSession.class );
when( session.getExecutionProperties() ).thenReturn( System.getProperties() );
- final AssemblerConfigurationSource cs = mockManager.createMock( AssemblerConfigurationSource.class );
- expect( cs.getMavenSession() ).andReturn( session );
+ final AssemblerConfigurationSource cs = mock( AssemblerConfigurationSource.class );
+ when( cs.getMavenSession() ).thenReturn( session );
+
DefaultAssemblyArchiverTest.setupInterpolators( cs, mainProject );
String result;
@@ -804,6 +812,9 @@ public class AssemblyFormatUtilsTest
mockManager.verifyAll();
mockManager.resetAll();
+
+ // result of easymock migration, should be assert of expected result instead of verifying methodcalls
+ verify( cs ).getMavenSession();
}
private void verifyDistroName( final String assemblyId, final String finalName, final boolean appendAssemblyId,