Search in sources :

Example 6 with Assembly

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();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 7 with Assembly

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();
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 8 with Assembly

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();
}
Also used : MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 9 with Assembly

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();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly) Test(org.junit.Test)

Example 10 with Assembly

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();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) IOException(java.io.IOException) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly) AssemblyArchiverPhase(org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase) Test(org.junit.Test)

Aggregations

Assembly (org.apache.maven.plugins.assembly.model.Assembly)56 File (java.io.File)29 MavenProject (org.apache.maven.project.MavenProject)28 Model (org.apache.maven.model.Model)21 EasyMockSupport (org.easymock.classextension.EasyMockSupport)13 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)12 FileSet (org.apache.maven.plugins.assembly.model.FileSet)9 ArrayList (java.util.ArrayList)8 Component (org.apache.maven.plugins.assembly.model.Component)8 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)7 PojoConfigSource (org.apache.maven.plugins.assembly.testutils.PojoConfigSource)7 FileItem (org.apache.maven.plugins.assembly.model.FileItem)6 FileOutputStream (java.io.FileOutputStream)5 IOException (java.io.IOException)5 OutputStreamWriter (java.io.OutputStreamWriter)5 StringWriter (java.io.StringWriter)5 Writer (java.io.Writer)5 AssemblyXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer)5 ComponentXpp3Reader (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader)5 ComponentXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer)5