1   package org.apache.maven.plugin.testing;
2   
3   import org.apache.maven.plugin.MojoExecutionException;
4   import org.codehaus.plexus.configuration.PlexusConfiguration;
5   import org.codehaus.plexus.util.xml.Xpp3Dom;
6   import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
7   
8   import java.io.StringReader;
9   
10  /**
11   * @author Edwin Punzalan
12   */
13  public class ExpressionEvaluatorTest
14      extends AbstractMojoTestCase
15  {
16      private Xpp3Dom pomDom;
17  
18      private PlexusConfiguration pluginConfiguration;
19  
20      protected void setUp()
21          throws Exception
22      {
23          super.setUp();
24  
25          StringBuffer pom = new StringBuffer();
26  
27          pom.append( "<project>" ).append( "\n" );
28          pom.append( "  <build>" ).append( "\n" );
29          pom.append( "    <plugins>" ).append( "\n" );
30          pom.append( "      <plugin>" ).append( "\n" );
31          pom.append( "        <artifactId>maven-test-mojo</artifactId>" ).append( "\n" );
32          pom.append( "        <configuration>" ).append( "\n" );
33          pom.append( "          <basedir>${basedir}</basedir>" ).append( "\n" );
34          pom.append( "          <workdir>${basedir}/workDirectory</workdir>" ).append( "\n" );
35          pom.append( "          <localRepository>${localRepository}</localRepository>" ).append( "\n" );
36          pom.append( "        </configuration>" ).append( "\n" );
37          pom.append( "      </plugin>" ).append( "\n" );
38          pom.append( "    </plugins>" ).append( "\n" );
39          pom.append( "  </build>" ).append( "\n" );
40          pom.append( "</project>" ).append( "\n" );
41  
42          pomDom = Xpp3DomBuilder.build( new StringReader( pom.toString() ) );
43  
44          pluginConfiguration = extractPluginConfiguration( "maven-test-mojo", pomDom );
45      }
46  
47      public void testInjection()
48          throws Exception
49      {
50          ExpressionEvaluatorMojo mojo = new ExpressionEvaluatorMojo();
51  
52          mojo = (ExpressionEvaluatorMojo) configureMojo( mojo, pluginConfiguration );
53  
54          try
55          {
56              mojo.execute();
57          }
58          catch ( MojoExecutionException e )
59          {
60              fail( e.getMessage() );
61          }
62      }
63  }