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