1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.maven.lifecycle;
17
18 import junit.framework.TestCase;
19 import org.apache.maven.lifecycle.internal.ExecutionPlanItem;
20 import org.apache.maven.lifecycle.internal.stub.DefaultLifecyclesStub;
21 import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub;
22 import org.apache.maven.model.Plugin;
23
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.Set;
27
28
29
30
31 public class MavenExecutionPlanTest
32 extends TestCase
33 {
34 public void testFindFirstWithMatchingSchedule()
35 throws Exception
36 {
37 final List<Scheduling> cycles = DefaultLifecyclesStub.getSchedulingList();
38 final Schedule schedule = cycles.get( 0 ).getSchedules().get( 0 );
39 assertNotNull( schedule );
40
41 }
42
43 public void testForceAllComplete()
44 throws Exception
45 {
46 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
47 plan.forceAllComplete();
48 final Iterator<ExecutionPlanItem> planItemIterator = plan.iterator();
49 assertTrue( planItemIterator.next().isDone() );
50 assertTrue( planItemIterator.next().isDone() );
51 }
52
53 public void testFindLastInPhase()
54 throws Exception
55 {
56 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
57
58 ExecutionPlanItem expected = plan.findLastInPhase( "package" );
59 ExecutionPlanItem beerPhase = plan.findLastInPhase( "BEER" );
60 assertEquals( expected, beerPhase );
61 assertNotNull( expected );
62 }
63
64 public void testThreadSafeMojos()
65 throws Exception
66 {
67 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
68 final Set<Plugin> unSafePlugins = plan.getNonThreadSafePlugins();
69
70 assertEquals( plan.size() - 1, unSafePlugins.size() );
71
72 }
73
74
75 public void testFindLastWhenFirst()
76 throws Exception
77 {
78 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
79
80 ExecutionPlanItem beerPhase = plan.findLastInPhase(
81 LifecycleExecutionPlanCalculatorStub.VALIDATE.getPhase() );
82 assertNull( beerPhase );
83 }
84
85 public void testFindLastInPhaseMisc()
86 throws Exception
87 {
88 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan();
89
90 assertNull( plan.findLastInPhase( "pacXkage" ) );
91
92 assertNotNull( plan.findLastInPhase( LifecycleExecutionPlanCalculatorStub.INITIALIZE.getPhase() ) );
93 }
94 }