Search in sources :

Example 31 with EasyMockSupport

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

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldReturnNothingWhenReactorContainsTwoSiblingProjects.

public void testGetModuleProjects_ShouldReturnNothingWhenReactorContainsTwoSiblingProjects() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    final MavenProject project2 = createProject("group", "artifact2", "version", null);
    final List<MavenProject> projects = new ArrayList<MavenProject>();
    projects.add(project);
    projects.add(project2);
    macTask.expectGetReactorProjects(projects);
    final ModuleSet moduleSet = new ModuleSet();
    moduleSet.setIncludeSubModules(true);
    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)

Example 32 with EasyMockSupport

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

the class RepositoryAssemblyPhaseTest method testExecute_ShouldIncludeOneRepository.

public void testExecute_ShouldIncludeOneRepository() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File tempRoot = fileManager.createTempDir();
    macCS.expectGetTemporaryRootDirectory(tempRoot);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final Repository repo = new Repository();
    repo.setOutputDirectory("out");
    repo.setDirectoryMode("777");
    repo.setFileMode("777");
    final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    final File outDir = new File(tempRoot, "out");
    macArchiver.expectModeChange(-1, -1, mode, mode, true);
    macArchiver.expectAddDirectory(outDir, "out/", null, null);
    macRepo.expectAssemble();
    assembly.addRepository(repo);
    mm.replayAll();
    createPhase(macRepo.repositoryAssembler, new ConsoleLogger(Logger.LEVEL_DEBUG, "test")).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Repository(org.apache.maven.plugins.assembly.model.Repository) 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 33 with EasyMockSupport

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

the class DefaultAssemblyArchiverTest method testCreateTarArchiver_TarGzFormat_ShouldInitializeGZipCompression.

@Test
public void testCreateTarArchiver_TarGzFormat_ShouldInitializeGZipCompression() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestTarArchiver ttArchiver = new TestTarArchiver();
    final DefaultAssemblyArchiver subject = createSubject(mm, ttArchiver);
    subject.createTarArchiver("tar.gz", 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 34 with EasyMockSupport

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

the class DefaultAssemblyArchiverTest method testCreateWarArchiver_ShouldDisableIgnoreWebxmlOption.

@Test
public void testCreateWarArchiver_ShouldDisableIgnoreWebxmlOption() throws NoSuchArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final TestWarArchiver twArchiver = new TestWarArchiver();
    final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
    macArchiverManager.expectGetArchiver("war", twArchiver);
    mm.replayAll();
    final DefaultAssemblyArchiver subject = createSubject(macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null);
    subject.createWarArchiver();
    assertFalse(twArchiver.ignoreWebxml);
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) AssemblyArchiverPhase(org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase) Test(org.junit.Test)

Example 35 with EasyMockSupport

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

the class DefaultAssemblyArchiverTest method testCreateArchiver_ShouldCreateZipArchiver.

@Test
public void testCreateArchiver_ShouldCreateZipArchiver() throws NoSuchArchiverException, ArchiverException {
    final EasyMockSupport mm = new EasyMockSupport();
    final ZipArchiver archiver = new ZipArchiver();
    final MockAndControlForAssemblyArchiver macArchiverManager = new MockAndControlForAssemblyArchiver(mm);
    macArchiverManager.expectGetArchiver("zip", archiver);
    final AssemblerConfigurationSource configSource = mm.createMock(AssemblerConfigurationSource.class);
    expect(configSource.isDryRun()).andReturn(false).anyTimes();
    expect(configSource.getArchiverConfig()).andReturn(null).anyTimes();
    expect(configSource.getWorkingDirectory()).andReturn(new File(".")).anyTimes();
    expect(configSource.isUpdateOnly()).andReturn(false).anyTimes();
    expect(configSource.getJarArchiveConfiguration()).andReturn(null).anyTimes();
    expect(configSource.isIgnorePermissions()).andReturn(true).anyTimes();
    mm.replayAll();
    final DefaultAssemblyArchiver subject = createSubject(macArchiverManager, new ArrayList<AssemblyArchiverPhase>(), null);
    subject.createArchiver("zip", false, null, configSource, null, false, null);
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ZipArchiver(org.codehaus.plexus.archiver.zip.ZipArchiver) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) File(java.io.File) AssemblyArchiverPhase(org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase) 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