}
public void testExecute_WithOutputDirectoryAndDestName()
throws Exception
{
final MockManager mm = new MockManager();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource( mm );
final File basedir = fileManager.createTempDir();
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" );
macCS.expectGetBasedir( basedir );
final File tempRoot = fileManager.createTempDir();
macCS.expectGetTemporaryRootDirectory( tempRoot );
macCS.expectGetProject( new MavenProject( new Model() ) );
macCS.expectGetFinalName( "final-name" );
final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
final Assembly assembly = new Assembly();
assembly.setId( "test" );
assembly.setIncludeBaseDirectory( true );
final FileItem readmeFileItem = new FileItem();
readmeFileItem.setSource( "README.txt" );
readmeFileItem.setOutputDirectory( "" );
readmeFileItem.setDestName( "README_renamed.txt" );
readmeFileItem.setFiltered( false );
readmeFileItem.setLineEnding( "keep" );
readmeFileItem.setFileMode( "777" );
final FileItem licenseFileItem = new FileItem();
licenseFileItem.setSource( "LICENSE.txt" );
licenseFileItem.setOutputDirectory( "/" );
licenseFileItem.setDestName( "LICENSE_renamed.txt" );
licenseFileItem.setFiltered( false );
licenseFileItem.setLineEnding( "keep" );
licenseFileItem.setFileMode( "777" );
final FileItem configFileItem = new FileItem();
configFileItem.setSource( "config/config.txt" );
configFileItem.setDestName( "config_renamed.txt" );
configFileItem.setOutputDirectory( "config" );
configFileItem.setFiltered( false );
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 );
macCS.expectGetEncoding();
mm.replayAll();
createPhase( macLogger.logger ).execute( assembly, macArchiver.archiver, macCS.configSource,
new DefaultAssemblyContext() );
mm.verifyAll();
}