use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class AddFileSetsTaskTest method testAddFileSet_ShouldNotAddDirectoryWhenSourceDirNonExistent.
public void testAddFileSet_ShouldNotAddDirectoryWhenSourceDirNonExistent() throws ArchiveCreationException, AssemblyFormattingException {
final FileSet fs = new FileSet();
final String dirname = "dir";
fs.setDirectory(dirname);
final File archiveBaseDir = fileManager.createTempDir();
macTask.expectGetFinalName("finalName");
//macTask.expectGetProject( null );
expect(macTask.archiver.getOverrideDirectoryMode()).andReturn(-1);
expect(macTask.archiver.getOverrideFileMode()).andReturn(-1);
final MavenProject project = new MavenProject(new Model());
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mockManager.replayAll();
final AddFileSetsTask task = new AddFileSetsTask(new ArrayList<FileSet>());
task.setLogger(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
task.setProject(project);
task.addFileSet(fs, macTask.archiver, macTask.configSource, archiveBaseDir);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class AddFileSetsTaskTest method testGetFileSetDirectory_ShouldReturnDirFromArchiveBasedirAndSourceDir.
public void testGetFileSetDirectory_ShouldReturnDirFromArchiveBasedirAndSourceDir() throws ArchiveCreationException, AssemblyFormattingException {
final File dir = fileManager.createTempDir();
final String srcPath = "source";
final File srcDir = new File(dir, srcPath);
final FileSet fs = new FileSet();
fs.setDirectory(srcPath);
final File result = new AddFileSetsTask(new ArrayList<FileSet>()).getFileSetDirectory(fs, null, dir);
assertEquals(srcDir.getAbsolutePath(), result.getAbsolutePath());
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testIncludeSiteInAssembly_ShouldAddSiteDirFileSetWhenDirExists.
// public void testReadComponent_ShouldReadComponentFromXml()
// throws IOException, AssemblyReadException
// {
// Component component = new Component();
//
// FileSet fileSet = new FileSet();
// fileSet.setDirectory( "/dir" );
//
// component.addFileSet( fileSet );
//
// StringWriter sw = new StringWriter();
//
// ComponentXpp3Writer componentWriter = new ComponentXpp3Writer();
//
// componentWriter.write( sw, component );
//
// Component result = new DefaultAssemblyReader().readComponent( new StringReader( sw.toString() ) );
//
// List<FileSet> fileSets = result.getFileSets();
//
// assertNotNull( fileSets );
// assertEquals( 1, fileSets.size() );
//
// FileSet fs = (FileSet) fileSets.get( 0 );
//
// assertEquals( "/dir", fs.getDirectory() );
// }
//
// public void testGetComponentFromFile_ShouldReadComponent()
// throws IOException, AssemblyReadException
// {
// Component component = new Component();
//
// FileSet fileSet = new FileSet();
// fileSet.setDirectory( "/dir" );
//
// component.addFileSet( fileSet );
//
// File componentFile = fileManager.createTempFile();
//
// FileWriter writer = null;
//
// try
// {
// writer = new FileWriter( componentFile );
//
// ComponentXpp3Writer componentWriter = new ComponentXpp3Writer();
//
// componentWriter.write( writer, component );
// }
// finally
// {
// IOUtil.close( writer );
// }
//
// File basedir = componentFile.getParentFile();
// String filename = componentFile.getName();
//
// configSource.getBasedir();
// configSourceControl.setReturnValue( basedir );
//
// mockManager.replayAll();
//
// Component result = new DefaultAssemblyReader().getComponentFromFile( filename, configSource );
//
// List<FileSet> fileSets = result.getFileSets();
//
// assertNotNull( fileSets );
// assertEquals( 1, fileSets.size() );
//
// FileSet fs = (FileSet) fileSets.get( 0 );
//
// assertEquals( "/dir", fs.getDirectory() );
//
// mockManager.verifyAll();
// }
public void testIncludeSiteInAssembly_ShouldAddSiteDirFileSetWhenDirExists() throws IOException, InvalidAssemblerConfigurationException {
final File siteDir = fileManager.createTempDir();
expect(configSource.getSiteDirectory()).andReturn(siteDir).anyTimes();
final Assembly assembly = new Assembly();
mockManager.replayAll();
new DefaultAssemblyReader().includeSiteInAssembly(assembly, configSource);
final List<FileSet> fileSets = assembly.getFileSets();
assertNotNull(fileSets);
assertEquals(1, fileSets.size());
final FileSet fs = fileSets.get(0);
assertEquals(siteDir.getPath(), fs.getDirectory());
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testGetAssemblyFromDescriptorFile_ShouldReadAssembly.
public void testGetAssemblyFromDescriptorFile_ShouldReadAssembly() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final Assembly assembly = new Assembly();
assembly.setId("test");
final FileSet fs = new FileSet();
fs.setDirectory("/dir");
assembly.addFileSet(fs);
final File assemblyFile = fileManager.createTempFile();
final File basedir = assemblyFile.getParentFile();
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
expect(configSource.getProject()).andReturn(new MavenProject(new Model())).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
Writer writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(assemblyFile), "UTF-8");
new AssemblyXpp3Writer().write(writer, assembly);
writer.close();
writer = null;
} finally {
IOUtil.close(writer);
}
mockManager.replayAll();
final Assembly result = new DefaultAssemblyReader().getAssemblyFromDescriptorFile(assemblyFile, configSource);
assertEquals(assembly.getId(), result.getId());
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithSiteDirInclusionFromAssemblyWithoutComponentsOrInterpolation.
public void testReadAssembly_ShouldReadAssemblyWithSiteDirInclusionFromAssemblyWithoutComponentsOrInterpolation() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeSiteDirectory(true);
final StringReader sr = writeToStringReader(assembly);
final File siteDir = fileManager.createTempDir();
expect(configSource.getSiteDirectory()).andReturn(siteDir).anyTimes();
final File basedir = fileManager.createTempDir();
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
final Model model = new Model();
model.setGroupId("group");
model.setArtifactId("artifact");
model.setVersion("version");
final MavenProject project = new MavenProject(model);
expect(configSource.getProject()).andReturn(project).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
mockManager.replayAll();
final Assembly result = new DefaultAssemblyReader().readAssembly(sr, "testLocation", null, configSource);
assertEquals(assembly.getId(), result.getId());
final List<FileSet> fileSets = result.getFileSets();
assertEquals(1, fileSets.size());
assertEquals("/site", fileSets.get(0).getOutputDirectory());
mockManager.verifyAll();
}
Aggregations