lifeCycleExecutionPlanCalculator.setupMojoExecution test

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1066895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Igor Fedorenko 2011-02-03 17:48:45 +00:00
parent 9d8fb63928
commit b884655f86
2 changed files with 41 additions and 13 deletions

View File

@ -15,14 +15,19 @@ package org.apache.maven.lifecycle;
* the License.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.maven.AbstractCoreMavenComponentTestCase;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.exception.ExceptionHandler;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator;
import org.apache.maven.lifecycle.internal.ExecutionPlanItem;
import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator;
import org.apache.maven.lifecycle.internal.LifecycleTask;
import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator;
import org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator;
import org.apache.maven.lifecycle.internal.MojoDescriptorCreator;
import org.apache.maven.lifecycle.internal.TaskSegment;
import org.apache.maven.model.Plugin;
@ -32,11 +37,6 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class LifecycleExecutorTest
extends AbstractCoreMavenComponentTestCase
{
@ -359,4 +359,25 @@ public class LifecycleExecutorTest
assertNotNull( plugin );
}
public void testSetupMojoExecution()
throws Exception
{
File pom = getProject( "mojo-configuration" );
MavenSession session = createMavenSession( pom );
LifecycleTask task = new LifecycleTask( "generate-sources" );
MavenExecutionPlan executionPlan =
lifeCycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(),
Arrays.asList( (Object) task ), false );
MojoExecution execution = executionPlan.getMojoExecutions().get(0);
assertEquals(execution.toString(), "maven-it-plugin", execution.getArtifactId());
assertNull(execution.getConfiguration());
lifeCycleExecutionPlanCalculator.setupMojoExecution( session, session.getCurrentProject(), execution );
assertNotNull(execution.getConfiguration());
assertEquals("1.0", execution.getConfiguration().getChild( "version" ).getAttribute( "default-value" ));
}
}

View File

@ -15,7 +15,9 @@
package org.apache.maven.lifecycle.internal;
import junit.framework.TestCase;
import java.io.File;
import org.apache.maven.AbstractCoreMavenComponentTestCase;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.lifecycle.internal.stub.BuildPluginManagerStub;
@ -29,7 +31,7 @@ import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
* @author Kristian Rosenvold>
*/
public class LifecycleExecutionPlanCalculatorTest
extends TestCase
extends AbstractCoreMavenComponentTestCase
{
public void testCalculateExecutionPlanWithGoalTasks()
@ -59,11 +61,9 @@ public class LifecycleExecutionPlanCalculatorTest
// Maybe also make one with LifeCycleTasks
public static LifecycleExecutionPlanCalculator createExecutionPlaceCalculator(
MojoDescriptorCreator mojoDescriptorCreator )
public static LifecycleExecutionPlanCalculator createExecutionPlaceCalculator( MojoDescriptorCreator mojoDescriptorCreator )
{
LifecyclePluginResolver lifecyclePluginResolver =
new LifecyclePluginResolver( new PluginVersionResolverStub() );
LifecyclePluginResolver lifecyclePluginResolver = new LifecyclePluginResolver( new PluginVersionResolverStub() );
return new DefaultLifecycleExecutionPlanCalculator( new BuildPluginManagerStub(),
DefaultLifecyclesStub.createDefaultLifecycles(),
mojoDescriptorCreator, lifecyclePluginResolver,
@ -76,4 +76,11 @@ public class LifecycleExecutionPlanCalculatorTest
new PluginPrefixResolverStub(),
new LifecyclePluginResolver( new PluginVersionResolverStub() ) );
}
@Override
protected String getProjectsDirectory()
{
return "src/test/projects/lifecycle-executor";
}
}