1 package org.apache.maven.project.canonical;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Iterator;
24 import java.util.List;
25
26 import org.apache.maven.model.Plugin;
27 import org.apache.maven.model.PluginExecution;
28 import org.apache.maven.project.AbstractMavenProjectTestCase;
29 import org.apache.maven.project.MavenProject;
30 import org.codehaus.plexus.util.xml.Xpp3Dom;
31
32
33
34
35 public class CanonicalProjectBuilderTest
36 extends AbstractMavenProjectTestCase
37 {
38 public void testProjectBuilder()
39 throws Exception
40 {
41 File f = getFileForClasspathResource( "canonical-pom.xml" );
42
43 MavenProject project = getProject( f );
44
45
46
47
48
49 assertEquals( "4.0.0", project.getModelVersion() );
50
51
52
53
54
55 List plugins = project.getBuildPlugins();
56
57
58
59 String key = "org.apache.maven.plugins:maven-plexus-plugin";
60
61 Plugin plugin = null;
62 for ( Iterator it = plugins.iterator(); it.hasNext(); )
63 {
64 Plugin check = (Plugin) it.next();
65
66 if ( key.equals( check.getKey() ) )
67 {
68 plugin = check;
69 break;
70 }
71 }
72
73 assertNotNull( plugin );
74
75 assertEquals( "1.0", plugin.getVersion() );
76
77 Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
78
79 assertEquals( "src/conf/plexus.conf", configuration.getChild( "plexusConfiguration" ).getValue() );
80
81 assertEquals( "src/conf/plexus.properties",
82 configuration.getChild( "plexusConfigurationPropertiesFile" ).getValue() );
83
84 assertEquals( "Continuum", configuration.getChild( "plexusApplicationName" ).getValue() );
85
86
87
88
89
90 List executions = plugin.getExecutions();
91
92 PluginExecution execution = (PluginExecution) executions.get( 0 );
93
94 String g0 = (String) execution.getGoals().get( 0 );
95
96 assertEquals( "plexus:runtime", g0 );
97
98 configuration = (Xpp3Dom) execution.getConfiguration();
99
100 assertEquals( "ContinuumPro", configuration.getChild( "plexusApplicationName" ).getValue() );
101
102
103 }
104 }