1   package org.apache.maven.plugin.lifecycle;
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.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
23  import org.codehaus.plexus.util.xml.Xpp3Dom;
24  import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
25  
26  import java.io.IOException;
27  import java.io.InputStreamReader;
28  
29  import junit.framework.TestCase;
30  
31  /**
32   * Test the lifecycle reader.
33   *
34   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
35   * @version $Id: LifecycleXpp3ReaderTest.java 640549 2008-03-24 20:05:11Z bentmann $
36   */
37  public class LifecycleXpp3ReaderTest
38      extends TestCase
39  {
40      public void testLifecycleReader()
41          throws IOException, XmlPullParserException
42      {
43          LifecycleMappingsXpp3Reader reader = new LifecycleMappingsXpp3Reader();
44          LifecycleConfiguration config = reader.read( new InputStreamReader( getClass().getResourceAsStream( "/lifecycle.xml" ) ) );
45          assertEquals( "check number of lifecycles", 1, config.getLifecycles().size() );
46          Lifecycle l = (Lifecycle) config.getLifecycles().iterator().next();
47          assertEquals( "check id", "clover", l.getId() );
48          assertEquals( "check number of phases", 1, l.getPhases().size() );
49          Phase p = (Phase) l.getPhases().iterator().next();
50          assertEquals( "check id", "generate-sources", p.getId() );
51          assertEquals( "check number of executions", 1, p.getExecutions().size() );
52          Execution e = (Execution) p.getExecutions().iterator().next();
53          assertEquals( "check configuration", "true", ((Xpp3Dom) e.getConfiguration()).getChild( "debug" ).getValue() );
54          assertEquals( "check number of goals", 1, e.getGoals().size() );
55          String g = (String) e.getGoals().iterator().next();
56          assertEquals( "check goal", "clover:compiler", g );
57      }
58  }