use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testExecute_ShouldAddOneModuleSetWithOneModuleInIt.
public void testExecute_ShouldAddOneModuleSetWithOneModuleInIt() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final MavenProject project = createProject("group", "artifact", "version", null);
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, project);
final MavenProject module = createProject("group", "module", "version", project);
final ArtifactMock moduleArtifactMock = new ArtifactMock(mm, "group", "module", "version", "jar", false);
final File moduleArtifactFile = moduleArtifactMock.setNewFile();
module.setArtifact(moduleArtifactMock.getArtifact());
final List<MavenProject> projects = new ArrayList<MavenProject>();
projects.add(module);
macTask.expectGetReactorProjects(projects);
macTask.expectGetFinalName("final-name");
macTask.expectGetDestFile(new File("junk"));
macTask.expectGetMode(0777, 0777);
final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
macTask.expectAddFile(moduleArtifactFile, "out/artifact", mode);
final Assembly assembly = new Assembly();
assembly.setIncludeBaseDirectory(false);
final ModuleSet ms = new ModuleSet();
final ModuleBinaries bin = new ModuleBinaries();
bin.setOutputFileNameMapping("artifact");
bin.setOutputDirectory("out");
bin.setFileMode("777");
bin.setUnpack(false);
bin.setIncludeDependencies(false);
ms.setBinaries(bin);
assembly.addModuleSet(ms);
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
macTask.expectResolveDependencySets();
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
final ModuleSetAssemblyPhase phase = createPhase(logger, macTask.dependencyResolver, null);
phase.execute(assembly, macTask.archiver, macTask.configSource);
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testCreateFileSet_ShouldAddExcludesForSubModulesWhenExcludeSubModDirsIsTrue.
public void testCreateFileSet_ShouldAddExcludesForSubModulesWhenExcludeSubModDirsIsTrue() throws AssemblyFormattingException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, null);
macTask.expectGetFinalName(null);
final FileSet fs = new FileSet();
final ModuleSources sources = new ModuleSources();
sources.setExcludeSubModuleDirectories(true);
final Model model = new Model();
model.setArtifactId("artifact");
model.addModule("submodule");
final MavenProject project = new MavenProject(model);
final File basedir = fileManager.createTempDir();
project.setFile(new File(basedir, "pom.xml"));
final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
project.setArtifact(artifactMock.getArtifact());
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
final FileSet result = createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).createFileSet(fs, sources, project, macTask.configSource);
assertEquals(1, result.getExcludes().size());
assertEquals("submodule/**", result.getExcludes().get(0));
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testCreateFileSet_ShouldUseModuleDirOnlyWhenOutDirIsNull.
public void testCreateFileSet_ShouldUseModuleDirOnlyWhenOutDirIsNull() throws AssemblyFormattingException {
final EasyMockSupport mm = new EasyMockSupport();
final Model model = new Model();
model.setArtifactId("artifact");
final MavenProject project = new MavenProject(model);
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, project);
macTask.expectGetFinalName(null);
final FileSet fs = new FileSet();
final ModuleSources sources = new ModuleSources();
sources.setIncludeModuleDirectory(true);
final File basedir = fileManager.createTempDir();
final MavenProject artifactProject = new MavenProject(new Model());
artifactProject.setFile(new File(basedir, "pom.xml"));
final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
artifactProject.setArtifact(artifactMock.getArtifact());
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
final FileSet result = createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).createFileSet(fs, sources, artifactProject, macTask.configSource);
assertEquals("artifact/", result.getOutputDirectory());
mm.verifyAll();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask 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();
}
use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask 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();
}
Aggregations