Search in sources :

Example 1 with IMocksControl

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

the class AssemblyExpressionEvaluatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.

public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws ExpressionEvaluationException {
    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 EasyMockSupport mm = new EasyMockSupport();
    MavenSession session = mm.createControl().createMock(MavenSession.class);
    final Properties execProps = new Properties();
    execProps.setProperty("groupId", "still.another.id");
    PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource(execProps);
    expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
    expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
    AssemblerConfigurationSource cs = mm.createControl().createMock(AssemblerConfigurationSource.class);
    expect(cs.getCommandLinePropsInterpolator()).andReturn(FixedStringSearchInterpolator.create(cliProps)).anyTimes();
    expect(cs.getRepositoryInterpolator()).andReturn(FixedStringSearchInterpolator.create()).anyTimes();
    expect(cs.getEnvInterpolator()).andReturn(FixedStringSearchInterpolator.create()).anyTimes();
    expect(cs.getMavenSession()).andReturn(session).anyTimes();
    expect(cs.getProject()).andReturn(new MavenProject(model));
    final IMocksControl lrCtl = mm.createControl();
    final ArtifactRepository lr = lrCtl.createMock(ArtifactRepository.class);
    expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
    expect(cs.getLocalRepository()).andReturn(lr).anyTimes();
    mm.replayAll();
    final Object result = new AssemblyExpressionEvaluator(cs).evaluate("assembly.${groupId}");
    assertEquals("assembly.still.another.id", result);
    mm.verifyAll();
}
Also used : IMocksControl(org.easymock.classextension.IMocksControl) 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) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) Properties(java.util.Properties) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource)

Aggregations

Properties (java.util.Properties)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 MavenSession (org.apache.maven.execution.MavenSession)1 Model (org.apache.maven.model.Model)1 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)1 MavenProject (org.apache.maven.project.MavenProject)1 PropertiesBasedValueSource (org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource)1 EasyMockSupport (org.easymock.classextension.EasyMockSupport)1 IMocksControl (org.easymock.classextension.IMocksControl)1