Search in sources :

Example 1 with MockAndControlForAddArtifactTask

use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testCreateFileSet_ShouldPrependModuleDirWhenOutDirIsProvided.

public void testCreateFileSet_ShouldPrependModuleDirWhenOutDirIsProvided() 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();
    fs.setOutputDirectory("out");
    final ModuleSources sources = new ModuleSources();
    sources.setIncludeModuleDirectory(true);
    final MavenProject artifactProject = new MavenProject(new Model());
    final File basedir = fileManager.createTempDir();
    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/out/", result.getOutputDirectory());
    mm.verifyAll();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) 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) Model(org.apache.maven.model.Model) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ModuleSources(org.apache.maven.plugins.assembly.model.ModuleSources) File(java.io.File)

Example 2 with MockAndControlForAddArtifactTask

use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.

the class AddArtifactTaskTest method setUp.

public void setUp() throws IOException {
    mockManager = new EasyMockSupport();
    Model model = new Model();
    model.setGroupId("group");
    model.setArtifactId("main");
    model.setVersion("1000");
    MavenProject mainProject = new MavenProject(model);
    mac = new MockAndControlForAddArtifactTask(mockManager, mainProject);
    mac.expectGetFinalName("final-name");
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model)

Example 3 with MockAndControlForAddArtifactTask

use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleArtifact_ShouldAddOneArtifact.

public void testAddModuleArtifact_ShouldAddOneArtifact() throws AssemblyFormattingException, IOException, ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "type", false);
    final File artifactFile = artifactMock.setNewFile();
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.setArtifact(artifactMock.getArtifact());
    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.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).addModuleArtifact(artifactMock.getArtifact(), project, macTask.archiver, macTask.configSource, binaries);
    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) File(java.io.File)

Example 4 with MockAndControlForAddArtifactTask

use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps.

public void testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
    final File artifactFile = artifactMock.setNewFile();
    macTask.expectGetFinalName("final-name");
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectAddFile(artifactFile, "out/artifact", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macTask.expectGetMode(0222, 0222);
    final ModuleBinaries binaries = new ModuleBinaries();
    binaries.setIncludeDependencies(false);
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    binaries.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.setArtifact(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 5 with MockAndControlForAddArtifactTask

use of org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleBinaries_ShouldFailWhenOneModuleDoesntHaveAttachmentWithMatchingClassifier.

public void testAddModuleBinaries_ShouldFailWhenOneModuleDoesntHaveAttachmentWithMatchingClassifier() throws ArchiveCreationException, AssemblyFormattingException, IOException, DependencyResolutionException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", "test", false);
    artifactMock.setNewFile();
    final ModuleBinaries binaries = new ModuleBinaries();
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    binaries.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    binaries.setAttachmentClassifier("test");
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.setArtifact(artifactMock.getArtifact());
    final Set<MavenProject> projects = singleton(project);
    mm.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    try {
        createPhase(logger, null).addModuleBinaries(null, null, binaries, projects, macTask.archiver, macTask.configSource);
        fail("Should throw an invalid configuration exception because of module with missing attachment.");
    } catch (final InvalidAssemblerConfigurationException e) {
    // should throw this because of missing attachment.
    }
    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) InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger)

Aggregations

MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)10 MavenProject (org.apache.maven.project.MavenProject)10 EasyMockSupport (org.easymock.classextension.EasyMockSupport)10 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)9 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)9 File (java.io.File)7 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)6 Model (org.apache.maven.model.Model)4 Logger (org.codehaus.plexus.logging.Logger)4 FileSet (org.apache.maven.plugins.assembly.model.FileSet)3 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)3 ArrayList (java.util.ArrayList)1 InvalidAssemblerConfigurationException (org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException)1 Assembly (org.apache.maven.plugins.assembly.model.Assembly)1 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)1