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