You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/05/03 09:11:38 UTC

svn commit: r399182 - in /maven/plugins/trunk/maven-release-plugin/src: main/java/org/apache/maven/plugins/release/ test/java/org/apache/maven/plugins/release/ test/resources/mojos/perform/

Author: brett
Date: Wed May  3 00:11:02 2006
New Revision: 399182

URL: http://svn.apache.org/viewcvs?rev=399182&view=rev
Log:
[MRELEASE-98] test perform mojo

Added:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java   (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml   (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml   (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml   (with props)
Modified:
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java?rev=399182&r1=399181&r2=399182&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java Wed May  3 00:11:02 2006
@@ -151,4 +151,9 @@
     {
         this.releaseManager = releaseManager;
     }
+
+    Settings getSettings()
+    {
+        return settings;
+    }
 }

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java?rev=399182&r1=399181&r2=399182&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java Wed May  3 00:11:02 2006
@@ -26,6 +26,7 @@
  * Perform a release from SCM
  *
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
  * @aggregator
  * @goal perform
@@ -43,7 +44,7 @@
     /**
      * The checkout directory.
      *
-     * @parameter expression="${project.build.directory}/checkout"
+     * @parameter default-value="${project.build.directory}/checkout"
      * @required
      */
     private File workingDirectory;
@@ -86,5 +87,4 @@
             throw new MojoFailureException( e.getMessage() );
         }
     }
-
 }

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java?rev=399182&r1=399181&r2=399182&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java Wed May  3 00:11:02 2006
@@ -28,6 +28,7 @@
  * @author <a href="mailto:jdcasey@apache.org">John Casey</a>
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
  * @aggregator
  * @goal prepare

Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java?rev=399182&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java Wed May  3 00:11:02 2006
@@ -0,0 +1,200 @@
+package org.apache.maven.plugins.release;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.model.Profile;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugins.release.config.ReleaseConfiguration;
+import org.apache.maven.project.MavenProject;
+import org.jmock.Mock;
+import org.jmock.core.Constraint;
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.matcher.InvokeOnceMatcher;
+import org.jmock.core.stub.ThrowStub;
+
+import java.io.File;
+import java.util.Arrays;
+
+/**
+ * Test release:perform.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class PerformReleaseMojoTest
+    extends AbstractMojoTestCase
+{
+    public void testPerform()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/perform.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy site-deploy" ),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        mojo.execute();
+
+        assertTrue( true );
+    }
+
+    public void testPerformWithExecutionException()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/perform.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy site-deploy" ),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints ).will(
+            new ThrowStub( new ReleaseExecutionException( "..." ) ) );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        try
+        {
+            mojo.execute();
+
+            fail( "Should have thrown an exception" );
+        }
+        catch ( MojoExecutionException e )
+        {
+            assertEquals( "Check cause", ReleaseExecutionException.class, e.getCause().getClass() );
+        }
+    }
+
+    public void testPerformWithExecutionFailure()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/perform.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy site-deploy" ),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints ).will(
+            new ThrowStub( new ReleaseFailureException( "..." ) ) );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        try
+        {
+            mojo.execute();
+
+            fail( "Should have thrown an exception" );
+        }
+        catch ( MojoFailureException e )
+        {
+            assertNull( "Check no cause", e.getCause() );
+        }
+    }
+
+    public void testPerformWithScm()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/perform-with-scm.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+        releaseConfiguration.setUrl( "scm-url" );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy site-deploy" ),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        mojo.execute();
+
+        assertTrue( true );
+    }
+
+    public void testPerformWithProfiles()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/perform.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+        releaseConfiguration.setAdditionalArguments( "-P prof1,2prof" );
+
+        MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+        Profile profile1 = new Profile();
+        profile1.setId( "prof1" );
+        Profile profile2 = new Profile();
+        profile2.setId( "2prof" );
+        project.setActiveProfiles( Arrays.asList( new Profile[]{profile1, profile2} ) );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy site-deploy" ),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        mojo.execute();
+
+        assertTrue( true );
+    }
+
+    public void testPerformWithProfilesAndArguments()
+        throws Exception
+    {
+        PerformReleaseMojo mojo = (PerformReleaseMojo) lookupMojo( "perform", getTestFile(
+            "target/test-classes/mojos/perform/perform-with-args.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+        releaseConfiguration.setAdditionalArguments( "-Dmaven.test.skip=true -P prof1,2prof" );
+
+        MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
+        Profile profile1 = new Profile();
+        profile1.setId( "prof1" );
+        Profile profile2 = new Profile();
+        profile2.setId( "2prof" );
+        project.setActiveProfiles( Arrays.asList( new Profile[]{profile1, profile2} ) );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
+            new IsEqual( new File( getBasedir(), "target/checkout" ) ), new IsEqual( "deploy site-deploy" ),
+            new IsEqual( Boolean.TRUE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "perform" ).with( constraints );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        mojo.execute();
+
+        assertTrue( true );
+    }
+}

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PerformReleaseMojoTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml?rev=399182&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml Wed May  3 00:11:02 2006
@@ -0,0 +1,32 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-release-plugin</artifactId>
+        <configuration>
+          <settings implementation="org.apache.maven.settings.Settings"/>
+          <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <workingDirectory>${basedir}/target/checkout</workingDirectory>
+          <useReleaseProfile>true</useReleaseProfile>
+          <arguments>-Dmaven.test.skip=true</arguments>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-args.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml?rev=399182&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml Wed May  3 00:11:02 2006
@@ -0,0 +1,32 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-release-plugin</artifactId>
+        <configuration>
+          <settings implementation="org.apache.maven.settings.Settings"/>
+          <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <workingDirectory>${basedir}/target/checkout</workingDirectory>
+          <useReleaseProfile>true</useReleaseProfile>
+          <scmUrl>scm-url</scmUrl>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform-with-scm.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml?rev=399182&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml Wed May  3 00:11:02 2006
@@ -0,0 +1,31 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-release-plugin</artifactId>
+        <configuration>
+          <settings implementation="org.apache.maven.settings.Settings"/>
+          <project implementation="org.apache.maven.plugin.testing.stubs.MavenProjectStub"/>
+          <workingDirectory>${basedir}/target/checkout</workingDirectory>
+          <useReleaseProfile>true</useReleaseProfile>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/perform/perform.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision