Search in sources :

Example 21 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class AddFileSetsTaskTest method setUp.

@Override
public void setUp() {
    mockManager = new EasyMockSupport();
    fileManager = new TestFileManager("add-fileset.test.", "");
    macTask = new MockAndControlForAddFileSetsTask(mockManager, fileManager);
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) TestFileManager(org.apache.maven.plugins.assembly.testutils.TestFileManager) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask)

Example 22 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class AssemblyInterpolatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.

public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Properties props = new Properties();
    props.setProperty("groupId", "other.id");
    model.setProperties(props);
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${groupId}");
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenSession session = mm.createMock(MavenSession.class);
    final Properties execProps = new Properties();
    execProps.setProperty("groupId", "still.another.id");
    expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
    expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
    final PojoConfigSource cs = new PojoConfigSource();
    final ArtifactRepository lr = mm.createMock(ArtifactRepository.class);
    cs.setLocalRepository(lr);
    cs.setMavenSession(session);
    cs.setRootInterpolator(FixedStringSearchInterpolator.create());
    cs.setEnvironmentInterpolator(FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(execProps)));
    cs.setEnvInterpolator(FixedStringSearchInterpolator.empty());
    expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
    mm.replayAll();
    final MavenProject project = new MavenProject(model);
    cs.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, cs);
    assertEquals("assembly.still.another.id", result.getId());
    mm.verifyAll();
    mm.resetAll();
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Properties(java.util.Properties) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 23 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport 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)

Example 24 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleSourceFileSets_ShouldReturnImmediatelyIfSourcesIsNull.

public void testAddModuleSourceFileSets_ShouldReturnImmediatelyIfSourcesIsNull() throws ArchiveCreationException, AssemblyFormattingException {
    final EasyMockSupport mm = new EasyMockSupport();
    mm.replayAll();
    createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).addModuleSourceFileSets(null, null, null, null);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger)

Example 25 with EasyMockSupport

use of org.easymock.classextension.EasyMockSupport 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)

Aggregations

EasyMockSupport (org.easymock.classextension.EasyMockSupport)50 MavenProject (org.apache.maven.project.MavenProject)27 File (java.io.File)21 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)21 Test (org.junit.Test)16 Model (org.apache.maven.model.Model)14 Assembly (org.apache.maven.plugins.assembly.model.Assembly)13 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)11 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)10 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)9 ArrayList (java.util.ArrayList)7 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)7 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)7 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)5 FileItem (org.apache.maven.plugins.assembly.model.FileItem)5 Logger (org.codehaus.plexus.logging.Logger)5 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4 AssemblyArchiverPhase (org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase)4 FileSet (org.apache.maven.plugins.assembly.model.FileSet)4 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)4