Search in sources :

Example 11 with EasyMockSupport

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

Example 12 with EasyMockSupport

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

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_TgzFormat_ShouldInitializeGZipCompression.

@Test
public void testCreateTarArchiver_TgzFormat_ShouldInitializeGZipCompression() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestTarArchiver ttArchiver = new TestTarArchiver();
    final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
    subject.createTarArchiver("tgz", TarLongFileMode.fail);
    assertEquals(TarArchiver.TarCompressionMethod.gzip, ttArchiver.compressionMethod);
    assertEquals(TarLongFileMode.fail, ttArchiver.longFileMode);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Test(org.junit.Test)

Example 13 with EasyMockSupport

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

the class AssemblyProxyArchiverTest method addFile_NoPerms_CallAcceptFilesOnlyOnce.

@Test
public void addFile_NoPerms_CallAcceptFilesOnlyOnce() throws IOException, ArchiverException {
    EasyMockSupport mm = new EasyMockSupport();
    final Archiver delegate = mm.createMock(Archiver.class);
    delegate.addFile((File) anyObject(), (String) anyObject());
    EasyMock.expectLastCall().anyTimes();
    delegate.setForced(true);
    EasyMock.expectLastCall().anyTimes();
    final CounterSelector counter = new CounterSelector(true);
    final List<FileSelector> selectors = new ArrayList<FileSelector>();
    selectors.add(counter);
    mm.replayAll();
    final AssemblyProxyArchiver archiver = new AssemblyProxyArchiver("", delegate, null, selectors, null, new File("."), new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    archiver.setForced(true);
    final File inputFile = fileManager.createTempFile();
    archiver.addFile(inputFile, "file.txt");
    assertEquals(1, counter.getCount());
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) FileSelector(org.codehaus.plexus.components.io.fileselectors.FileSelector) ArrayList(java.util.ArrayList) TrackingArchiver(org.codehaus.plexus.archiver.diags.TrackingArchiver) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) Archiver(org.codehaus.plexus.archiver.Archiver) File(java.io.File) Test(org.junit.Test)

Example 14 with EasyMockSupport

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

the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectoryAndDestName.

public void testExecute_WithOutputDirectoryAndDestName() 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.setDestName("README_renamed.txt");
    readmeFileItem.setFiltered(false);
    readmeFileItem.setLineEnding("keep");
    readmeFileItem.setFileMode("777");
    final FileItem licenseFileItem = new FileItem();
    licenseFileItem.setSource("LICENSE.txt");
    licenseFileItem.setOutputDirectory("/");
    licenseFileItem.setDestName("LICENSE_renamed.txt");
    licenseFileItem.setFiltered(false);
    licenseFileItem.setLineEnding("keep");
    licenseFileItem.setFileMode("777");
    final FileItem configFileItem = new FileItem();
    configFileItem.setSource("config/config.txt");
    configFileItem.setDestName("config_renamed.txt");
    configFileItem.setOutputDirectory("config");
    configFileItem.setFiltered(false);
    configFileItem.setLineEnding("keep");
    configFileItem.setFileMode("777");
    macArchiver.expectAddFile(readmeFile, "README_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macArchiver.expectAddFile(licenseFile, "LICENSE_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macArchiver.expectAddFile(configFile, "config/config_renamed.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 15 with EasyMockSupport

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

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively.

public void testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    addArtifact(project, mm, false);
    final MavenProject project2 = createProject("group", "artifact2", "version", project);
    addArtifact(project2, mm, false);
    final MavenProject project3 = createProject("group", "artifact3", "version", project2);
    addArtifact(project3, mm, true);
    final List<MavenProject> projects = new ArrayList<MavenProject>();
    projects.add(project);
    projects.add(project2);
    projects.add(project3);
    macTask.expectGetReactorProjects(projects);
    final ModuleSet moduleSet = new ModuleSet();
    moduleSet.setIncludeSubModules(true);
    moduleSet.addExclude("group:artifact2");
    mm.replayAll();
    final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
    assertTrue(moduleProjects.isEmpty());
    mm.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet)

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