Search in sources :

Example 1 with MockAndControlForAddDependencySetsTask

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

the class DependencySetAssemblyPhaseTest method testExecute_ShouldAddOneDependencyFromProject.

public void testExecute_ShouldAddOneDependencyFromProject() throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final String outputLocation = "/out";
    final MavenProject project = newMavenProject("group", "project", "0");
    final ArtifactMock projectArtifactMock = new ArtifactMock(mm, "group", "project", "0", "jar", false);
    project.setArtifact(projectArtifactMock.getArtifact());
    final DependencySet ds = new DependencySet();
    ds.setUseProjectArtifact(false);
    ds.setOutputDirectory(outputLocation);
    ds.setOutputFileNameMapping("${artifact.artifactId}");
    ds.setUnpack(false);
    ds.setScope(Artifact.SCOPE_COMPILE);
    ds.setFileMode(Integer.toString(10, 8));
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    assembly.setIncludeBaseDirectory(false);
    assembly.addDependencySet(ds);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "dep", "1", "jar", false);
    System.out.println("On test setup, hashcode for dependency artifact: " + artifactMock.getArtifact().hashCode());
    macTask.expectCSGetRepositories(null, null);
    macTask.expectGetDestFile(new File("junk"));
    // macTask.expectAddFile( artifactFile, "out/dep", 10 );
    project.setArtifacts(Collections.singleton(artifactMock.getArtifact()));
    macTask.expectCSGetFinalName("final-name");
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final MavenProject depProject = newMavenProject("group", "dep", "1");
    macTask.expectBuildFromRepository(depProject);
    macTask.expectResolveDependencySets();
    mm.replayAll();
    createPhase(macTask, logger, macTask.dependencyResolver).execute(assembly, macTask.archiver, macTask.configSource);
    mm.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) 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) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 2 with MockAndControlForAddDependencySetsTask

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

the class AddDependencySetsTaskTest method testGetDependencyArtifacts_ShouldGetOneDependencyArtifact.

public void testGetDependencyArtifacts_ShouldGetOneDependencyArtifact() throws ArchiveCreationException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager);
    final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
    project.setArtifacts(Collections.singleton(artifactMock.getArtifact()));
    final DependencySet dependencySet = new DependencySet();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    mockManager.replayAll();
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySet), Collections.singleton(artifactMock.getArtifact()), project, macTask.projectBuilder, logger);
    final Set<Artifact> result = task.resolveDependencyArtifacts(dependencySet);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertSame(artifactMock.getArtifact(), result.iterator().next());
    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) Artifact(org.apache.maven.artifact.Artifact) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 3 with MockAndControlForAddDependencySetsTask

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

the class AddDependencySetsTaskTest method testAddDependencySet_ShouldNotAddDependenciesWhenProjectHasNone.

public void testAddDependencySet_ShouldNotAddDependenciesWhenProjectHasNone() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager);
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory("/out");
    mockManager.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), null, project, macTask.projectBuilder, logger);
    task.addDependencySet(ds, null, 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) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 4 with MockAndControlForAddDependencySetsTask

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

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively.

public void testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    addArtifact(project, mm, false);
    final MavenProject project2 = createProject("group", "artifact2", "version", project);
    addArtifact(project2, mm, false);
    final MavenProject project3 = createProject("group", "artifact3", "version", project2);
    addArtifact(project3, mm, true);
    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);
    moduleSet.addExclude("group:artifact2");
    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 5 with MockAndControlForAddDependencySetsTask

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

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldReturnModuleOfCurrentProject.

public void testGetModuleProjects_ShouldReturnModuleOfCurrentProject() 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 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);
    assertFalse(moduleProjects.isEmpty());
    final MavenProject result = moduleProjects.iterator().next();
    assertEquals("artifact2", result.getArtifactId());
    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)

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