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 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   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
34   * @version $Id: CanonicalProjectBuilderTest.java 495147 2007-01-11 07:47:53Z jvanzyl $
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          // Top-level elements
48          // ----------------------------------------------------------------------
49  
50          assertEquals( "4.0.0", project.getModelVersion() );
51  
52          // ----------------------------------------------------------------------
53          // Plugins
54          // ----------------------------------------------------------------------
55  
56          List plugins = project.getBuildPlugins();
57  
58          // Plugin0 [plexus]
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          // Goal specific configuration
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         // Plugin1 [antlr]
104     }
105 }