maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r399186 - in /maven/plugins/trunk/maven-release-plugin/src/test: java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java resources/mojos/prepare/ resources/mojos/prepare/prepare.xml
Date Wed, 03 May 2006 07:21:15 GMT
Author: brett
Date: Wed May  3 00:21:14 2006
New Revision: 399186

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

Added:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
  (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/prepare/
    maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
  (with props)

Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java?rev=399186&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/PrepareReleaseMojoTest.java
Wed May  3 00:21:14 2006
@@ -0,0 +1,194 @@
+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.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.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;
+
+/**
+ * Test release:prepare.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class PrepareReleaseMojoTest
+    extends AbstractMojoTestCase
+{
+    public void testPrepare()
+        throws Exception
+    {
+        PrepareReleaseMojo mojo = (PrepareReleaseMojo) lookupMojo( "prepare", getTestFile(
+            "target/test-classes/mojos/prepare/prepare.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
new IsEqual( Boolean.TRUE ),
+            new IsEqual( Boolean.FALSE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "prepare" ).with( constraints );
+        mojo.setReleaseManager( (ReleaseManager) mock.proxy() );
+
+        mojo.execute();
+
+        assertTrue( true );
+    }
+
+    public void testPrepareWithExecutionException()
+        throws Exception
+    {
+        PrepareReleaseMojo mojo = (PrepareReleaseMojo) lookupMojo( "prepare", getTestFile(
+            "target/test-classes/mojos/prepare/prepare.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
new IsEqual( Boolean.TRUE ),
+            new IsEqual( Boolean.FALSE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "prepare" ).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 testPrepareWithExecutionFailure()
+        throws Exception
+    {
+        PrepareReleaseMojo mojo = (PrepareReleaseMojo) lookupMojo( "prepare", getTestFile(
+            "target/test-classes/mojos/prepare/prepare.xml" ) );
+
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setSettings( mojo.getSettings() );
+
+        Mock mock = new Mock( ReleaseManager.class );
+        Constraint[] constraints = new Constraint[]{new IsEqual( releaseConfiguration ),
new IsEqual( Boolean.TRUE ),
+            new IsEqual( Boolean.FALSE )};
+        mock.expects( new InvokeOnceMatcher() ).method( "prepare" ).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/PrepareReleaseMojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml?rev=399186&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/mojos/prepare/prepare.xml
Wed May  3 00:21:14 2006
@@ -0,0 +1,30 @@
+<!--
+  ~ 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"/>
+          <resume>true</resume>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file

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

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



Mime
View raw message