KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > plugin > lifecycle > LifecycleXpp3ReaderTest


1 package org.apache.maven.plugin.lifecycle;
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.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
20 import org.codehaus.plexus.util.xml.Xpp3Dom;
21 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
22
23 import java.io.IOException JavaDoc;
24 import java.io.InputStreamReader JavaDoc;
25
26 import junit.framework.TestCase;
27
28 /**
29  * Test the lifecycle reader.
30  *
31  * @author <a HREF="mailto:brett@apache.org">Brett Porter</a>
32  * @version $Id: LifecycleXpp3ReaderTest.java 327885 2005-10-23 23:50:38Z brett $
33  */

34 public class LifecycleXpp3ReaderTest
35     extends TestCase
36 {
37     public void testLifecycleReader()
38         throws IOException JavaDoc, XmlPullParserException
39     {
40         LifecycleMappingsXpp3Reader reader = new LifecycleMappingsXpp3Reader();
41         LifecycleConfiguration config = reader.read( new InputStreamReader JavaDoc( getClass().getResourceAsStream( "/lifecycle.xml" ) ) );
42         assertEquals( "check number of lifecycles", 1, config.getLifecycles().size() );
43         Lifecycle l = (Lifecycle) config.getLifecycles().iterator().next();
44         assertEquals( "check id", "clover", l.getId() );
45         assertEquals( "check number of phases", 1, l.getPhases().size() );
46         Phase p = (Phase) l.getPhases().iterator().next();
47         assertEquals( "check id", "generate-sources", p.getId() );
48         assertEquals( "check number of executions", 1, p.getExecutions().size() );
49         Execution e = (Execution) p.getExecutions().iterator().next();
50         assertEquals( "check configuration", "true", ((Xpp3Dom) e.getConfiguration()).getChild( "debug" ).getValue() );
51         assertEquals( "check number of goals", 1, e.getGoals().size() );
52         String JavaDoc g = (String JavaDoc) e.getGoals().iterator().next();
53         assertEquals( "check goal", "clover:compiler", g );
54     }
55 }
56
Popular Tags