1 package org.apache.maven.plugin.testing;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
31
32
33 public class ExpressionEvaluatorTest
34 extends AbstractMojoTestCase
35 {
36 private Xpp3Dom pomDom;
37
38 private PlexusConfiguration pluginConfiguration;
39
40
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
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 }