001 package org.apache.maven.lifecycle.internal; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 005 * agreements. See the NOTICE file distributed with this work for additional information regarding 006 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance with the License. You may obtain a 008 * copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed under the License 013 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 014 * or implied. See the License for the specific language governing permissions and limitations under 015 * the License. 016 */ 017 018 import junit.framework.TestCase; 019 import org.apache.maven.lifecycle.Schedule; 020 import org.apache.maven.lifecycle.internal.stub.MojoExecutorStub; 021 import org.apache.maven.plugin.MojoExecution; 022 023 /** 024 * @author Kristian Rosenvold 025 */ 026 public class ExecutionPlanItemTest 027 extends TestCase 028 { 029 030 public void testSetComplete() 031 throws Exception 032 { 033 ExecutionPlanItem item = createExecutionPlanItem( "testMojo", null ); 034 item.setComplete(); // This itself is a valid test 035 assertTrue( item.isDone() ); 036 } 037 038 public void testWaitUntilDone() 039 throws Exception 040 { 041 042 final ExecutionPlanItem item = 043 createExecutionPlanItem( "testMojo", createExecutionPlanItem( "testMojo2", null ) ); 044 new Thread( new Runnable() 045 { 046 public void run() 047 { 048 item.setComplete(); 049 } 050 } ).start(); 051 item.waitUntilDone(); 052 } 053 054 055 public static ExecutionPlanItem createExecutionPlanItem( String mojoDescription, ExecutionPlanItem downStream ) 056 { 057 return createExecutionPlanItem( mojoDescription, downStream, null ); 058 } 059 060 public static ExecutionPlanItem createExecutionPlanItem( String mojoDescription, ExecutionPlanItem downStream, 061 Schedule schedule ) 062 { 063 return new ExecutionPlanItem( new MojoExecution( MojoExecutorStub.createMojoDescriptor( mojoDescription ) ), 064 schedule ); 065 } 066 067 068 }