001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 003 * agreements. See the NOTICE file distributed with this work for additional information regarding 004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 005 * "License"); you may not use this file except in compliance with the License. You may obtain a 006 * copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software distributed under the License 011 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing permissions and limitations under 013 * the License. 014 */ 015 016package org.apache.maven.lifecycle; 017 018import junit.framework.TestCase; 019 020import org.apache.maven.lifecycle.internal.ExecutionPlanItem; 021import org.apache.maven.lifecycle.internal.stub.DefaultLifecyclesStub; 022import org.apache.maven.lifecycle.internal.stub.LifecycleExecutionPlanCalculatorStub; 023import org.apache.maven.model.Plugin; 024 025import java.util.Iterator; 026import java.util.List; 027import java.util.Set; 028 029/** 030 * @author Kristian Rosenvold 031 */ 032public class MavenExecutionPlanTest 033 extends TestCase 034{ 035 036 public void testFindLastInPhase() 037 throws Exception 038 { 039 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); 040 041 ExecutionPlanItem expected = plan.findLastInPhase( "package" ); 042 ExecutionPlanItem beerPhase = plan.findLastInPhase( "BEER" ); // Beer comes straight after package in stub 043 assertEquals( expected, beerPhase ); 044 assertNotNull( expected ); 045 } 046 047 public void testThreadSafeMojos() 048 throws Exception 049 { 050 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); 051 final Set<Plugin> unSafePlugins = plan.getNonThreadSafePlugins(); 052 // There is only a single threadsafe plugin here... 053 assertEquals( plan.size() - 1, unSafePlugins.size() ); 054 055 } 056 057 058 public void testFindLastWhenFirst() 059 throws Exception 060 { 061 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); 062 063 ExecutionPlanItem beerPhase = plan.findLastInPhase( 064 LifecycleExecutionPlanCalculatorStub.VALIDATE.getPhase() ); // Beer comes straight after package in stub 065 assertNull( beerPhase ); 066 } 067 068 public void testFindLastInPhaseMisc() 069 throws Exception 070 { 071 MavenExecutionPlan plan = LifecycleExecutionPlanCalculatorStub.getProjectAExceutionPlan(); 072 073 assertNull( plan.findLastInPhase( "pacXkage" ) ); 074 // Beer comes straight after package in stub, much like real life. 075 assertNotNull( plan.findLastInPhase( LifecycleExecutionPlanCalculatorStub.INITIALIZE.getPhase() ) ); 076 } 077}