public void testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly()
throws IOException, AssemblyReadException
{
final Component component = new Component();
final FileSet fileSet = new FileSet();
fileSet.setDirectory( "/dir" );
component.addFileSet( fileSet );
final File componentFile = fileManager.createTempFile();
Writer writer = null;
try
{
writer = new OutputStreamWriter( new FileOutputStream( componentFile ), "UTF-8" );
final ComponentXpp3Writer componentWriter = new ComponentXpp3Writer();
componentWriter.write( writer, component );
writer.flush();
}
finally
{
IOUtil.close( writer );
}
final String filename = componentFile.getName();
final Assembly assembly = new Assembly();
assembly.addComponentDescriptor( filename );
final File basedir = componentFile.getParentFile();
configSource.getBasedir();
configSourceControl.setReturnValue( basedir, MockControl.ZERO_OR_MORE );
final MavenProject project = new MavenProject();
configSource.getProject();
configSourceControl.setReturnValue( project, MockControl.ZERO_OR_MORE );
mockManager.replayAll();
new DefaultAssemblyReader().mergeComponentsWithMainAssembly( assembly, null, configSource );
final List<FileSet> fileSets = assembly.getFileSets();
assertNotNull( fileSets );
assertEquals( 1, fileSets.size() );
final FileSet fs = fileSets.get( 0 );
assertEquals( "/dir", fs.getDirectory() );
mockManager.verifyAll();
}