View Javadoc

1   package org.apache.maven.plugin.testing;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.plugin.MojoExecutionException;
23  import org.codehaus.plexus.configuration.PlexusConfiguration;
24  import org.codehaus.plexus.util.xml.Xpp3Dom;
25  import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
26  
27  import java.io.StringReader;
28  
29  /**
30   * @author Edwin Punzalan
31   * @version $Id: ExpressionEvaluatorTest.java 638332 2008-03-18 11:39:00Z bentmann $
32   */
33  public class ExpressionEvaluatorTest
34      extends AbstractMojoTestCase
35  {
36      private Xpp3Dom pomDom;
37  
38      private PlexusConfiguration pluginConfiguration;
39  
40      /** {@inheritDoc} */
41      protected void setUp()
42          throws Exception
43      {
44          super.setUp();
45  
46          StringBuffer pom = new StringBuffer();
47  
48          pom.append( "<project>" ).append( "\n" );
49          pom.append( "  <build>" ).append( "\n" );
50          pom.append( "    <plugins>" ).append( "\n" );
51          pom.append( "      <plugin>" ).append( "\n" );
52          pom.append( "        <artifactId>maven-test-mojo</artifactId>" ).append( "\n" );
53          pom.append( "        <configuration>" ).append( "\n" );
54          pom.append( "          <basedir>${basedir}</basedir>" ).append( "\n" );
55          pom.append( "          <workdir>${basedir}/workDirectory</workdir>" ).append( "\n" );
56          pom.append( "          <localRepository>${localRepository}</localRepository>" ).append( "\n" );
57          pom.append( "        </configuration>" ).append( "\n" );
58          pom.append( "      </plugin>" ).append( "\n" );
59          pom.append( "    </plugins>" ).append( "\n" );
60          pom.append( "  </build>" ).append( "\n" );
61          pom.append( "</project>" ).append( "\n" );
62  
63          pomDom = Xpp3DomBuilder.build( new StringReader( pom.toString() ) );
64  
65          pluginConfiguration = extractPluginConfiguration( "maven-test-mojo", pomDom );
66      }
67  
68      /**
69       * @throws Exception if any
70       */
71      public void testInjection()
72          throws Exception
73      {
74          ExpressionEvaluatorMojo mojo = new ExpressionEvaluatorMojo();
75  
76          mojo = (ExpressionEvaluatorMojo) configureMojo( mojo, pluginConfiguration );
77  
78          try
79          {
80              mojo.execute();
81          }
82          catch ( MojoExecutionException e )
83          {
84              fail( e.getMessage() );
85          }
86      }
87  }