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();
}
Aggregations