KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > project > canonical > CanonicalProjectBuilderTest


1 package org.apache.maven.project.canonical;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.maven.model.Plugin;
20 import org.apache.maven.model.PluginExecution;
21 import org.apache.maven.project.AbstractMavenProjectTestCase;
22 import org.apache.maven.project.MavenProject;
23 import org.codehaus.plexus.util.xml.Xpp3Dom;
24
25 import java.io.File JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28
29 /**
30  * @author <a HREF="mailto:jason@maven.org">Jason van Zyl</a>
31  * @version $Id: CanonicalProjectBuilderTest.java 293328 2005-10-03 13:10:39Z brett $
32  */

33 public class CanonicalProjectBuilderTest
34     extends AbstractMavenProjectTestCase
35 {
36     public void testProjectBuilder()
37         throws Exception JavaDoc
38     {
39         File JavaDoc f = getFileForClasspathResource( "canonical-pom.xml" );
40
41         MavenProject project = getProject( f );
42
43         // ----------------------------------------------------------------------
44
// Top-level elements
45
// ----------------------------------------------------------------------
46

47         assertEquals( "4.0.0", project.getModelVersion() );
48
49         // ----------------------------------------------------------------------
50
// Plugins
51
// ----------------------------------------------------------------------
52

53         List JavaDoc plugins = project.getBuildPlugins();
54
55         // Plugin0 [plexus]
56

57         String JavaDoc key = "org.apache.maven.plugins:maven-plexus-plugin";
58
59         Plugin plugin = null;
60         for ( Iterator JavaDoc it = plugins.iterator(); it.hasNext(); )
61         {
62             Plugin check = (Plugin) it.next();
63
64             if ( key.equals( check.getKey() ) )
65             {
66                 plugin = check;
67                 break;
68             }
69         }
70
71         assertNotNull( plugin );
72
73         assertEquals( "1.0", plugin.getVersion() );
74
75         Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
76
77         assertEquals( "src/conf/plexus.conf", configuration.getChild( "plexusConfiguration" ).getValue() );
78
79         assertEquals( "src/conf/plexus.properties",
80                       configuration.getChild( "plexusConfigurationPropertiesFile" ).getValue() );
81
82         assertEquals( "Continuum", configuration.getChild( "plexusApplicationName" ).getValue() );
83
84         // ----------------------------------------------------------------------
85
// Goal specific configuration
86
// ----------------------------------------------------------------------
87

88         List JavaDoc executions = plugin.getExecutions();
89
90         PluginExecution execution = (PluginExecution) executions.get( 0 );
91
92         String JavaDoc g0 = (String JavaDoc) execution.getGoals().get( 0 );
93
94         assertEquals( "plexus:runtime", g0 );
95
96         configuration = (Xpp3Dom) execution.getConfiguration();
97
98         assertEquals( "ContinuumPro", configuration.getChild( "plexusApplicationName" ).getValue() );
99
100         // Plugin1 [antlr]
101
}
102 }
103
Popular Tags