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