Search in sources :

Example 1 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class FileItemAssemblyPhaseTest method testExecute_ShouldAddRelativeFileNoFilterNoLineEndingConversion.

public void testExecute_ShouldAddRelativeFileNoFilterNoLineEndingConversion() throws ArchiveCreationException, AssemblyFormattingException, IOException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File basedir = fileManager.createTempDir();
    final File file = fileManager.createFile(basedir, "file.txt", "This is a test file.");
    macCS.expectGetBasedir(basedir);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final FileItem fi = new FileItem();
    fi.setSource("file.txt");
    fi.setFiltered(false);
    fi.setLineEnding("keep");
    fi.setFileMode("777");
    macArchiver.expectAddFile(file, "file.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    assembly.addFile(fi);
    mm.replayAll();
    createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : FileItem(org.apache.maven.plugins.assembly.model.FileItem) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 2 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectory.

public void testExecute_WithOutputDirectory() throws Exception {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File basedir = fileManager.createTempDir();
    final File readmeFile = fileManager.createFile(basedir, "README.txt", "This is a test file for README.txt.");
    final File licenseFile = fileManager.createFile(basedir, "LICENSE.txt", "This is a test file for LICENSE.txt.");
    final File configFile = fileManager.createFile(basedir, "config/config.txt", "This is a test file for config/config.txt");
    macCS.expectGetBasedir(basedir);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        macLogger.logger.error("OS=Windows and the assembly descriptor contains a *nix-specific " + "root-relative-reference (starting with slash) /");
    } else {
        macLogger.logger.warn((String) anyObject());
    }
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    assembly.setIncludeBaseDirectory(true);
    final FileItem readmeFileItem = new FileItem();
    readmeFileItem.setSource("README.txt");
    readmeFileItem.setOutputDirectory("");
    readmeFileItem.setFiltered(false);
    readmeFileItem.setLineEnding("keep");
    readmeFileItem.setFileMode("777");
    final FileItem licenseFileItem = new FileItem();
    licenseFileItem.setSource("LICENSE.txt");
    licenseFileItem.setOutputDirectory("/");
    licenseFileItem.setFiltered(false);
    licenseFileItem.setLineEnding("keep");
    licenseFileItem.setFileMode("777");
    final FileItem configFileItem = new FileItem();
    configFileItem.setSource("config/config.txt");
    configFileItem.setOutputDirectory("config");
    configFileItem.setFiltered(false);
    configFileItem.setLineEnding("keep");
    configFileItem.setFileMode("777");
    macArchiver.expectAddFile(readmeFile, "README.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macArchiver.expectAddFile(licenseFile, "LICENSE.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macArchiver.expectAddFile(configFile, "config/config.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    assembly.addFile(readmeFileItem);
    assembly.addFile(licenseFileItem);
    assembly.addFile(configFileItem);
    mm.replayAll();
    createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : FileItem(org.apache.maven.plugins.assembly.model.FileItem) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 3 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport 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 4 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport 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();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) File(java.io.File) AssemblyArchiverPhase(org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase) Test(org.junit.Test)

Example 5 with EasyMockSupport

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

Aggregations

EasyMockSupport (org.easymock.classextension.EasyMockSupport)50 MavenProject (org.apache.maven.project.MavenProject)27 File (java.io.File)21 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)21 Test (org.junit.Test)16 Model (org.apache.maven.model.Model)14 Assembly (org.apache.maven.plugins.assembly.model.Assembly)13 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)11 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)10 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)9 ArrayList (java.util.ArrayList)7 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)7 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)7 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)5 FileItem (org.apache.maven.plugins.assembly.model.FileItem)5 Logger (org.codehaus.plexus.logging.Logger)5 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4 AssemblyArchiverPhase (org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase)4 FileSet (org.apache.maven.plugins.assembly.model.FileSet)4 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)4