Search in sources :

Example 41 with EasyMockSupport

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

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldReturnNothingWhenReactorContainsOnlyCurrentProject.

public void testGetModuleProjects_ShouldReturnNothingWhenReactorContainsOnlyCurrentProject() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    final List<MavenProject> projects = Collections.singletonList(project);
    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) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet)

Example 42 with EasyMockSupport

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

the class ModuleSetAssemblyPhaseTest method testAddModuleSourceFileSets_ShouldAddOneSourceDirectory.

public void testAddModuleSourceFileSets_ShouldAddOneSourceDirectory() throws ArchiveCreationException, AssemblyFormattingException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddFileSetsTask macTask = new MockAndControlForAddFileSetsTask(mm, fileManager);
    final MavenProject project = createProject("group", "artifact", "version", null);
    macTask.expectGetProject(project);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
    project.setArtifact(artifactMock.getArtifact());
    final Set<MavenProject> projects = singleton(project);
    final ModuleSources sources = new ModuleSources();
    final FileSet fs = new FileSet();
    fs.setDirectory("/src");
    fs.setDirectoryMode("777");
    fs.setFileMode("777");
    sources.addFileSet(fs);
    macTask.expectGetArchiveBaseDirectory();
    final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    final int[] modes = { -1, -1, mode, mode };
    macTask.expectAdditionOfSingleFileSet(project, "final-name", false, modes, 1, true, false);
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    createPhase(logger, null).addModuleSourceFileSets(sources, projects, macTask.archiver, macTask.configSource);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) FileSet(org.apache.maven.plugins.assembly.model.FileSet) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) ModuleSources(org.apache.maven.plugins.assembly.model.ModuleSources) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger)

Example 43 with EasyMockSupport

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

the class ModuleSetAssemblyPhaseTest method testAddModuleBinaries_ShouldAddOneModuleAttachmentArtifactAndNoDeps.

public void testAddModuleBinaries_ShouldAddOneModuleAttachmentArtifactAndNoDeps() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, null);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", "test", false);
    final File artifactFile = artifactMock.setNewFile();
    macTask.expectGetFinalName("final-name");
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectGetMode(0222, 0222);
    macTask.expectAddFile(artifactFile, "out/artifact", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    final ModuleBinaries binaries = new ModuleBinaries();
    binaries.setIncludeDependencies(false);
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    binaries.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    binaries.setAttachmentClassifier("test");
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.addAttachedArtifact(artifactMock.getArtifact());
    final Set<MavenProject> projects = singleton(project);
    macTask.expectResolveDependencySets();
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    createPhase(logger, macTask.dependencyResolver, null).addModuleBinaries(null, null, binaries, projects, macTask.archiver, macTask.configSource);
    mm.verifyAll();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) ModuleBinaries(org.apache.maven.plugins.assembly.model.ModuleBinaries) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) File(java.io.File)

Example 44 with EasyMockSupport

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

the class ModuleSetAssemblyPhaseTest method testAddModuleBinaries_ShouldFilterPomModule.

public void testAddModuleBinaries_ShouldFilterPomModule() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
    final ModuleBinaries binaries = new ModuleBinaries();
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    binaries.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.setPackaging("pom");
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "pom", false);
    project.setArtifact(artifactMock.getArtifact());
    final Set<MavenProject> projects = singleton(project);
    mm.replayAll();
    createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).addModuleBinaries(null, null, binaries, projects, macTask.archiver, macTask.configSource);
    mm.verifyAll();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) ModuleBinaries(org.apache.maven.plugins.assembly.model.ModuleBinaries) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)

Example 45 with EasyMockSupport

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

the class AddDirectoryTaskTest method setUp.

public void setUp() {
    fileManager = new TestFileManager("ArchiveAssemblyUtils.test.", "");
    mockManager = new EasyMockSupport();
    archiver = mockManager.createMock(Archiver.class);
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) TestFileManager(org.apache.maven.plugins.assembly.testutils.TestFileManager) Archiver(org.codehaus.plexus.archiver.Archiver)

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