use of org.apache.maven.plugins.assembly.AssemblerConfigurationSource in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldConfigureArchiver.
@Test
public void testCreateArchiver_ShouldConfigureArchiver() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
final TestArchiverWithConfig archiver = new TestArchiverWithConfig();
macArchiverManager.expectGetArchiver("dummy", archiver);
final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
final String simpleConfig = "value";
expect(configSource.getArchiverConfig()).andReturn("<configuration><simpleConfig>" + simpleConfig + "</simpleConfig></configuration>").anyTimes();
final MavenProject project = new MavenProject(new Model());
expect(configSource.getProject()).andReturn(project).anyTimes();
expect(configSource.getMavenSession()).andReturn(null).anyTimes();
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.getWorkingDirectory()).andReturn(new File(".")).anyTimes();
expect(configSource.isUpdateOnly()).andReturn(false).anyTimes();
final ArtifactRepository lr = mm.createMock(ArtifactRepository.class);
expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
expect(configSource.getLocalRepository()).andReturn(lr).anyTimes();
expect(configSource.isIgnorePermissions()).andReturn(true);
setupInterpolators(configSource, project);
mm.replayAll();
final DefaultAssemblyArchiver subject = createSubject(macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null);
subject.createArchiver("dummy", false, "finalName", configSource, null, false, null);
assertEquals(simpleConfig, archiver.getSimpleConfig());
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.AssemblerConfigurationSource 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();
}
use of org.apache.maven.plugins.assembly.AssemblerConfigurationSource in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldCreateTarArchiverWithNoCompression.
@Test
public void testCreateArchiver_ShouldCreateTarArchiverWithNoCompression() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final TestTarArchiver ttArchiver = new TestTarArchiver();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
macArchiverManager.expectGetArchiver("tar", ttArchiver);
final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
expect(configSource.getTarLongFileMode()).andReturn(TarLongFileMode.fail.toString()).anyTimes();
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
final DefaultAssemblyArchiver subject = setupStdExpectations(mm, macArchiverManager, configSource);
subject.createArchiver("tar", false, "finalName", configSource, null, false, null);
assertNull(ttArchiver.compressionMethod);
assertEquals(TarLongFileMode.fail, ttArchiver.longFileMode);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.AssemblerConfigurationSource 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.AssemblerConfigurationSource in project maven-plugins by apache.
the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldCreateWarArchiverWithIgnoreWebxmlSetToFalse.
@Test
public void testCreateArchiver_ShouldCreateWarArchiverWithIgnoreWebxmlSetToFalse() throws NoSuchArchiverException, ArchiverException {
final EasyMockSupport mm = new EasyMockSupport();
final TestWarArchiver twArchiver = new TestWarArchiver();
final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
macArchiverManager.expectGetArchiver("war", twArchiver);
final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
expect(configSource.isDryRun()).andReturn(false).anyTimes();
expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
expect(configSource.getMavenSession()).andReturn(null).anyTimes();
final DefaultAssemblyArchiver subject = setupStdExpectations(mm, macArchiverManager, configSource);
subject.createArchiver("war", false, null, configSource, null, false, null);
assertFalse(twArchiver.ignoreWebxml);
}
Aggregations