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 package org.apache.maven.lifecycle.internal; 016 017 import junit.framework.TestCase; 018 import org.apache.maven.lifecycle.Schedule; 019 import org.apache.maven.lifecycle.internal.stub.MojoExecutorStub; 020 import org.apache.maven.plugin.MojoExecution; 021 022 /** 023 * @author Kristian Rosenvold 024 */ 025 public class ExecutionPlanItemTest 026 extends TestCase 027 { 028 029 public void testSetComplete() 030 throws Exception 031 { 032 ExecutionPlanItem item = createExecutionPlanItem( "testMojo", null ); 033 item.setComplete(); // This itself is a valid test 034 assertTrue( item.isDone() ); 035 } 036 037 public void testWaitUntilDone() 038 throws Exception 039 { 040 041 final ExecutionPlanItem item = 042 createExecutionPlanItem( "testMojo", createExecutionPlanItem( "testMojo2", null ) ); 043 new Thread( new Runnable() 044 { 045 public void run() 046 { 047 item.setComplete(); 048 } 049 } ).start(); 050 item.waitUntilDone(); 051 } 052 053 054 public static ExecutionPlanItem createExecutionPlanItem( String mojoDescription, ExecutionPlanItem downStream ) 055 { 056 return createExecutionPlanItem( mojoDescription, downStream, null ); 057 } 058 059 public static ExecutionPlanItem createExecutionPlanItem( String mojoDescription, ExecutionPlanItem downStream, 060 Schedule schedule ) 061 { 062 return new ExecutionPlanItem( new MojoExecution( MojoExecutorStub.createMojoDescriptor( mojoDescription ) ), 063 schedule ); 064 } 065 066 067 }