use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_ShouldAddNothingWhenNoFileItemsArePresent.
public void testExecute_ShouldAddNothingWhenNoFileItemsArePresent() throws ArchiveCreationException, AssemblyFormattingException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File basedir = fileManager.createTempDir();
macCS.expectGetBasedir(basedir);
final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
mm.replayAll();
createPhase(macLogger.logger).execute(assembly, null, macCS.configSource);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class FileSetAssemblyPhaseTest method testShouldAddOneFileSet.
public void testShouldAddOneFileSet() throws ArchiveCreationException, AssemblyFormattingException {
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeBaseDirectory(false);
final FileSet fs = new FileSet();
fs.setOutputDirectory("/out");
fs.setDirectory("/input");
fs.setFileMode("777");
fs.setDirectoryMode("777");
assembly.addFileSet(fs);
final MockAndControlForLogger macLogger = new MockAndControlForLogger();
final MockAndControlForAddFileSetsTask macTask = new MockAndControlForAddFileSetsTask(mm, fileManager);
macTask.expectGetArchiveBaseDirectory();
final MavenProject project = new MavenProject(new Model());
macLogger.expectError(true, true);
final int dirMode = Integer.parseInt("777", 8);
final int fileMode = Integer.parseInt("777", 8);
final int[] modes = { -1, -1, dirMode, fileMode };
macTask.expectAdditionOfSingleFileSet(project, "final-name", false, modes, 1, true);
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
createPhase(macLogger).execute(assembly, macTask.archiver, macTask.configSource);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class FileSetAssemblyPhaseTest method testShouldNotFailWhenNoFileSetsSpecified.
public void testShouldNotFailWhenNoFileSetsSpecified() throws ArchiveCreationException, AssemblyFormattingException {
final Assembly assembly = new Assembly();
assembly.setId("test");
final MockAndControlForLogger macLogger = new MockAndControlForLogger();
final MockAndControlForAddFileSetsTask macTask = new MockAndControlForAddFileSetsTask(mm, fileManager);
mm.replayAll();
createPhase(macLogger).execute(assembly, macTask.archiver, macTask.configSource);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method failWhenAssemblyIdIsNull.
@Test(expected = InvalidAssemblerConfigurationException.class)
public void failWhenAssemblyIdIsNull() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
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);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchive.
@Test
public void testCreateArchive() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException, IOException, DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver(mm);
macMgr.expectGetArchiver("zip", Archiver.class);
macMgr.expectGetDestFile(new File("test"));
final AssemblyArchiverPhase phase = mm.createControl().createMock(AssemblyArchiverPhase.class);
phase.execute((Assembly) anyObject(), (Archiver) anyObject(), (AssemblerConfigurationSource) anyObject());
final AssemblerConfigurationSource configSource = mm.createControl().createMock(AssemblerConfigurationSource.class);
final File tempDir = fileManager.createTempDir();
FileUtils.deleteDirectory(tempDir);
expect(configSource.getTemporaryRootDirectory()).andReturn(tempDir).anyTimes();
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.isIgnoreDirFormatExtensions()).andReturn(false).anyTimes();
final File outDir = fileManager.createTempDir();
macMgr.archiver.setDestFile(new File(outDir, "full-name.zip"));
try {
macMgr.archiver.createArchive();
} catch (final ArchiverException e) {
fail("Should never happen");
} catch (final IOException e) {
fail("Should never happen");
}
expect(configSource.getOutputDirectory()).andReturn(outDir);
expect(configSource.getFinalName()).andReturn("finalName");
expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
expect(configSource.getWorkingDirectory()).andReturn(new File(".")).anyTimes();
expect(configSource.isUpdateOnly()).andReturn(false).anyTimes();
expect(configSource.isIgnorePermissions()).andReturn(false).anyTimes();
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);
mm.verifyAll();
}
Aggregations