View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.project.canonical;
20  
21  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.maven.model.Plugin;
25  import org.apache.maven.model.PluginExecution;
26  import org.apache.maven.project.AbstractMavenProjectTestCase;
27  import org.apache.maven.project.MavenProject;
28  import org.codehaus.plexus.util.xml.Xpp3Dom;
29  
30  /**
31   * @author Jason van Zyl
32   */
33  public class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase {
34      public void testProjectBuilder() throws Exception {
35          File f = getFileForClasspathResource("canonical-pom.xml");
36  
37          MavenProject project = getProject(f);
38  
39          // ----------------------------------------------------------------------
40          // Top-level elements
41          // ----------------------------------------------------------------------
42  
43          assertEquals("4.0.0", project.getModelVersion());
44  
45          // ----------------------------------------------------------------------
46          // Plugins
47          // ----------------------------------------------------------------------
48  
49          List<Plugin> plugins = project.getBuildPlugins();
50  
51          // Plugin0 [plexus]
52  
53          String key = "org.apache.maven.plugins:maven-plexus-plugin";
54  
55          Plugin plugin = null;
56          for (Plugin check : plugins) {
57              if (key.equals(check.getKey())) {
58                  plugin = check;
59                  break;
60              }
61          }
62  
63          assertNotNull(plugin);
64  
65          assertEquals("1.0", plugin.getVersion());
66  
67          Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
68  
69          assertEquals(
70                  "src/conf/plexus.conf",
71                  configuration.getChild("plexusConfiguration").getValue());
72  
73          assertEquals(
74                  "src/conf/plexus.properties",
75                  configuration.getChild("plexusConfigurationPropertiesFile").getValue());
76  
77          assertEquals(
78                  "Continuum", configuration.getChild("plexusApplicationName").getValue());
79  
80          // ----------------------------------------------------------------------
81          // Goal specific configuration
82          // ----------------------------------------------------------------------
83  
84          List<PluginExecution> executions = plugin.getExecutions();
85  
86          PluginExecution execution = executions.get(0);
87  
88          String g0 = execution.getGoals().get(0);
89  
90          assertEquals("plexus:runtime", g0);
91  
92          configuration = (Xpp3Dom) execution.getConfiguration();
93  
94          assertEquals(
95                  "ContinuumPro", configuration.getChild("plexusApplicationName").getValue());
96  
97          // Plugin1 [antlr]
98      }
99  }