Search in sources :

Example 6 with MockAndControlForAddDependencySetsTask

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

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

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

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldReturnDescendentModulesOfCurrentProject.

public void testGetModuleProjects_ShouldReturnDescendentModulesOfCurrentProject() 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", project);
    final MavenProject project3 = createProject("group", "artifact3", "version", project2);
    final List<MavenProject> projects = new ArrayList<MavenProject>();
    projects.add(project);
    projects.add(project2);
    projects.add(project3);
    macTask.expectGetReactorProjects(projects);
    final ModuleSet moduleSet = new ModuleSet();
    moduleSet.setIncludeSubModules(true);
    mm.replayAll();
    final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
    assertEquals(2, moduleProjects.size());
    final List<MavenProject> check = new ArrayList<MavenProject>();
    check.add(project2);
    check.add(project3);
    verifyResultIs(check, moduleProjects);
    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 9 with MockAndControlForAddDependencySetsTask

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

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

the class DependencySetAssemblyPhaseTest method testExecute_ShouldNotAddDependenciesWhenProjectHasNone.

public void testExecute_ShouldNotAddDependenciesWhenProjectHasNone() throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    assembly.setIncludeBaseDirectory(false);
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, null);
    macTask.expectResolveDependencySets();
    mm.replayAll();
    createPhase(macTask, logger, macTask.dependencyResolver).execute(assembly, null, macTask.configSource);
    mm.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)12 MavenProject (org.apache.maven.project.MavenProject)11 Logger (org.codehaus.plexus.logging.Logger)7 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)7 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)6 Model (org.apache.maven.model.Model)5 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)5 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)5 EasyMockSupport (org.easymock.classextension.EasyMockSupport)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Assembly (org.apache.maven.plugins.assembly.model.Assembly)2 Artifact (org.apache.maven.artifact.Artifact)1 ProjectBuildingException (org.apache.maven.project.ProjectBuildingException)1