use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class ManifestCreationFinalizerTest method testShouldDoNothingWhenArchiverIsNotJarArchiver.
public void testShouldDoNothingWhenArchiverIsNotJarArchiver() throws ArchiverException {
EasyMockSupport mm = new EasyMockSupport();
MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
MavenProject project = new MavenProject(new Model());
MavenArchiveConfiguration config = new MavenArchiveConfiguration();
mm.replayAll();
new ManifestCreationFinalizer(null, project, config).finalizeArchiveCreation(macArchiver.archiver);
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class DefaultDependencyResolverTest method test_getModuleSetResolutionRequirements.
public void test_getModuleSetResolutionRequirements() throws DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final AssemblerConfigurationSource cs = mm.createMock(AssemblerConfigurationSource.class);
final File rootDir = new File("root");
final MavenProject project = createMavenProject("main-group", "main-artifact", "1", rootDir);
final File module1Dir = new File(rootDir, "module-1");
final MavenProject module1 = createMavenProject("main-group", "module-1", "1", module1Dir);
final MavenProject module1a = createMavenProject("group1", "module-1a", "1", new File(module1Dir, "module-1a"));
final MavenProject module1b = createMavenProject("group1.b", "module-1b", "1", new File(module1Dir, "module-1b"));
module1.getModel().addModule(module1a.getArtifactId());
module1.getModel().addModule(module1b.getArtifactId());
final File module2Dir = new File(rootDir, "module-2");
final MavenProject module2 = createMavenProject("main-group", "module-2", "1", module2Dir);
final MavenProject module2a = createMavenProject("main-group", "module-2a", "1", new File(module2Dir, "module-2a"));
module2.getModel().addModule(module2a.getArtifactId());
project.getModel().addModule(module1.getArtifactId());
project.getModel().addModule(module2.getArtifactId());
final List<MavenProject> allProjects = new ArrayList<MavenProject>();
allProjects.add(project);
allProjects.add(module1);
allProjects.add(module1a);
allProjects.add(module1b);
allProjects.add(module2);
allProjects.add(module2a);
expect(cs.getReactorProjects()).andReturn(allProjects).anyTimes();
expect(cs.getProject()).andReturn(project).anyTimes();
expect(cs.getMavenSession()).andReturn(newMavenSession(project)).anyTimes();
final ResolutionManagementInfo info = new ResolutionManagementInfo(project);
final List<ModuleSet> moduleSets = new ArrayList<ModuleSet>();
final ModuleSet ms1 = new ModuleSet();
final DependencySet ds1 = new DependencySet();
{
ms1.addInclude("*module1*");
ms1.setIncludeSubModules(false);
final ModuleBinaries mb = new ModuleBinaries();
ds1.setScope(Artifact.SCOPE_COMPILE);
mb.addDependencySet(ds1);
ms1.setBinaries(mb);
moduleSets.add(ms1);
}
final ModuleSet ms2 = new ModuleSet();
final DependencySet ds2 = new DependencySet();
{
ms2.addInclude("main-group:*");
ms2.setIncludeSubModules(true);
final ModuleBinaries mb = new ModuleBinaries();
ds2.setScope(Artifact.SCOPE_TEST);
mb.addDependencySet(ds2);
ms2.setBinaries(mb);
moduleSets.add(ms2);
}
mm.replayAll();
resolver.enableLogging(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
final Assembly assembly = new Assembly();
assembly.setModuleSets(moduleSets);
resolver.updateModuleSetResolutionRequirements(AssemblyId.createAssemblyId(assembly), ms1, ds1, info, cs);
resolver.updateModuleSetResolutionRequirements(AssemblyId.createAssemblyId(assembly), ms2, ds2, info, cs);
assertTrue(info.isResolutionRequired());
final Set<MavenProject> enabledProjects = info.getEnabledProjects();
assertTrue(enabledProjects.contains(project));
assertTrue(enabledProjects.contains(module1));
// these should be excluded since sub-modules are not traversable
assertFalse(enabledProjects.contains(module1a));
assertFalse(enabledProjects.contains(module1b));
assertTrue(enabledProjects.contains(module2));
assertTrue(enabledProjects.contains(module2a));
// these are the two we directly set above.
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_TEST));
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_COMPILE));
// this combination should be implied by the two direct scopes set above.
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_RUNTIME));
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_PROVIDED));
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_SYSTEM));
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.
the class RepositoryAssemblyPhaseTest method testExecute_ShouldNotIncludeRepositoryIfNonSpecifiedInAssembly.
public void testExecute_ShouldNotIncludeRepositoryIfNonSpecifiedInAssembly() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(mm);
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File tempRoot = fileManager.createTempDir();
macCS.expectGetTemporaryRootDirectory(tempRoot);
final Assembly assembly = new Assembly();
assembly.setId("test");
mm.replayAll();
createPhase(macRepo.repositoryAssembler, new ConsoleLogger(Logger.LEVEL_DEBUG, "test")).execute(assembly, macArchiver.archiver, macCS.configSource);
mm.verifyAll();
}
use of org.easymock.classextension.EasyMockSupport 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();
}
use of org.easymock.classextension.EasyMockSupport 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();
}
Aggregations