1 package org.apache.maven.plugin.lifecycle;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
33
34
35
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 }