Search in sources :

Example 21 with ArtifactMock

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

the class AddDependencySetsTaskTest method verifyOneDependencyAdded.

private void verifyOneDependencyAdded(final String outputLocation, final boolean unpack) throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory(outputLocation);
    ds.setOutputFileNameMapping("artifact");
    ds.setUnpack(unpack);
    ds.setScope(Artifact.SCOPE_COMPILE);
    ds.setDirectoryMode(Integer.toString(10, 8));
    ds.setFileMode(Integer.toString(10, 8));
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, new MavenProject(new Model()));
    final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
    final File artifactFile = artifactMock.setNewFile();
    if (unpack) {
        macTask.expectAddArchivedFileSet();
    //            macTask.expectModeChange( -1, -1, 10, 10, 2 );
    } else {
        macTask.expectAddFile(artifactFile, outputLocation + "/artifact", 10);
    }
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectCSGetFinalName("final-name");
    macTask.expectCSGetRepositories(null, null);
    final MavenProject depProject = new MavenProject(new Model());
    macTask.expectBuildFromRepository(depProject);
    macTask.expectGetMode(0222, 0222);
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(artifactMock.getArtifact()), project, macTask.projectBuilder, logger);
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mockManager.replayAll();
    task.addDependencySet(ds, macTask.archiver, macTask.configSource);
    mockManager.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) 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) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 22 with ArtifactMock

use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock 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();
}
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 23 with ArtifactMock

use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock 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 24 with ArtifactMock

use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock 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 25 with ArtifactMock

use of org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock 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)

Aggregations

ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)26 MavenProject (org.apache.maven.project.MavenProject)20 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)20 File (java.io.File)16 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)14 Logger (org.codehaus.plexus.logging.Logger)12 EasyMockSupport (org.easymock.classextension.EasyMockSupport)11 Model (org.apache.maven.model.Model)10 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)8 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)7 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)6 FileSet (org.apache.maven.plugins.assembly.model.FileSet)4 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)4 Artifact (org.apache.maven.artifact.Artifact)3 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 MavenSession (org.apache.maven.execution.MavenSession)2 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)2 Assembly (org.apache.maven.plugins.assembly.model.Assembly)2 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)2