maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r516628 - /maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
Date Sat, 10 Mar 2007 00:57:55 GMT
Author: jdcasey
Date: Fri Mar  9 16:57:54 2007
New Revision: 516628

URL: http://svn.apache.org/viewvc?view=rev&rev=516628
Log:
unit tests for DefaultLifecyclePlan

Added:
    maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
  (with props)

Added: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java?view=auto&rev=516628
==============================================================================
--- maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
(added)
+++ maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
Fri Mar  9 16:57:54 2007
@@ -0,0 +1,95 @@
+package org.apache.maven.lifecycle.plan;
+
+import org.apache.maven.lifecycle.LifecycleSpecificationException;
+import org.apache.maven.lifecycle.model.LifecycleBindings;
+import org.apache.maven.lifecycle.model.MojoBinding;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class DefaultLifecyclePlanTest
+    extends TestCase
+{
+
+    public void testSingleTask_TwoMojoBindings()
+        throws LifecycleSpecificationException, LifecyclePlannerException
+    {
+        LifecycleBindings bindings = new LifecycleBindings();
+        bindings.getCleanBinding().getPreClean().addBinding( newMojo( "group", "artifact",
"pre-clean" ) );
+        bindings.getCleanBinding().getClean().addBinding( newMojo( "group", "artifact", "clean"
) );
+
+        List plan = new DefaultLifecyclePlan( Collections.singletonList( "clean" ), bindings
).getPlanMojoBindings();
+
+        assertEquals( 2, plan.size() );
+        assertMojo( "group", "artifact", "pre-clean", (MojoBinding) plan.get( 0 ) );
+        assertMojo( "group", "artifact", "clean", (MojoBinding) plan.get( 1 ) );
+    }
+
+    public void testTwoAdditiveTasksInOrder_ThreeMojoBindings_NoDupes()
+        throws LifecycleSpecificationException, LifecyclePlannerException
+    {
+        LifecycleBindings bindings = new LifecycleBindings();
+        bindings.getCleanBinding().getPreClean().addBinding( newMojo( "group", "artifact",
"pre-clean" ) );
+        bindings.getCleanBinding().getClean().addBinding( newMojo( "group", "artifact", "clean"
) );
+        bindings.getCleanBinding().getClean().addBinding( newMojo( "group", "artifact", "post-clean"
) );
+
+        List tasks = new ArrayList();
+        tasks.add( "clean" );
+        tasks.add( "post-clean" );
+
+        List plan = new DefaultLifecyclePlan( tasks, bindings ).getPlanMojoBindings();
+
+        assertEquals( 3, plan.size() );
+        assertMojo( "group", "artifact", "pre-clean", (MojoBinding) plan.get( 0 ) );
+        assertMojo( "group", "artifact", "clean", (MojoBinding) plan.get( 1 ) );
+        assertMojo( "group", "artifact", "post-clean", (MojoBinding) plan.get( 2 ) );
+    }
+
+    public void testTwoAdditiveTasksInOrder_TwoMojoBindings_OneMojoModifierInsertedBetween_NoDupes()
+        throws LifecycleSpecificationException, LifecyclePlannerException
+    {
+        MojoBinding preClean = newMojo( "group", "artifact", "pre-clean" );
+
+        List mods = Collections.singletonList( newMojo( "group", "artifact", "clean" ) );
+
+        LifecyclePlanModifier modder = new DefaultLifecyclePlanModifier( preClean, mods );
+
+        LifecycleBindings bindings = new LifecycleBindings();
+        bindings.getCleanBinding().getPreClean().addBinding( preClean );
+        bindings.getCleanBinding().getClean().addBinding( newMojo( "group", "artifact", "post-clean"
) );
+
+        List tasks = new ArrayList();
+        tasks.add( "clean" );
+        tasks.add( "post-clean" );
+
+        LifecyclePlan lifecyclePlan = new DefaultLifecyclePlan( tasks, bindings );
+        lifecyclePlan.addModifier( modder );
+        
+        List plan = lifecyclePlan.getPlanMojoBindings();
+
+        assertEquals( 3, plan.size() );
+        assertMojo( "group", "artifact", "pre-clean", (MojoBinding) plan.get( 0 ) );
+        assertMojo( "group", "artifact", "clean", (MojoBinding) plan.get( 1 ) );
+        assertMojo( "group", "artifact", "post-clean", (MojoBinding) plan.get( 2 ) );
+    }
+
+    private void assertMojo( String groupId, String artifactId, String goal, MojoBinding
binding )
+    {
+        assertEquals( groupId, binding.getGroupId() );
+        assertEquals( artifactId, binding.getArtifactId() );
+        assertEquals( goal, binding.getGoal() );
+    }
+
+    private MojoBinding newMojo( String groupId, String artifactId, String goal )
+    {
+        MojoBinding binding = new MojoBinding();
+        binding.setGroupId( groupId );
+        binding.setArtifactId( artifactId );
+        binding.setGoal( goal );
+
+        return binding;
+    }
+}

Propchange: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/2.1-lifecycle-refactor/maven-core/src/test/java/org/apache/maven/lifecycle/plan/DefaultLifecyclePlanTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message