maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r398873 - in /maven/plugins/trunk/maven-release-plugin/src: main/java/org/apache/maven/plugins/release/phase/ main/resources/META-INF/plexus/ test/java/org/apache/maven/plugins/release/phase/ test/resources/org/apache/maven/plugins/release/...
Date Tue, 02 May 2006 09:02:02 GMT
Author: brett
Date: Tue May  2 02:01:52 2006
New Revision: 398873

URL: http://svn.apache.org/viewcvs?rev=398873&view=rev
Log:
[MRELEASE-98] tag phase and tests

Added:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/IsScmFileSetEquals.java
  (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.java
  (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml
  (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml
  (with props)
Modified:
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmCommitPhase.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmTagPhase.java
    maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCommitPhaseTest.java

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmCommitPhase.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmCommitPhase.java?rev=398873&r1=398872&r2=398873&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmCommitPhase.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmCommitPhase.java
Tue May  2 02:01:52 2006
@@ -92,11 +92,11 @@
         }
         catch ( ScmException e )
         {
-            throw new ReleaseExecutionException( "An error is occurred in the checkin process.",
e );
+            throw new ReleaseExecutionException( "An error is occurred in the checkin process:
" + e.getMessage(), e );
         }
         if ( !result.isSuccess() )
         {
-            throw new ReleaseScmCommandException( "Unable to check for local modifications",
result );
+            throw new ReleaseScmCommandException( "Unable to commit files", result );
         }
     }
 
@@ -106,7 +106,7 @@
         validateConfiguration( releaseConfiguration );
 
         Collection pomFiles = createPomFiles( releaseConfiguration.getReactorProjects() );
-        getLogger().info( "Expected to be checking in " + pomFiles.size() + " files with
message: '" +
+        getLogger().info( "Full run would be checking in " + pomFiles.size() + " files with
message: '" +
             createMessage( releaseConfiguration ) + "'" );
     }
 

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmTagPhase.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmTagPhase.java?rev=398873&r1=398872&r2=398873&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmTagPhase.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/ScmTagPhase.java
Tue May  2 02:01:52 2006
@@ -16,25 +16,91 @@
  * limitations under the License.
  */
 
+import org.apache.maven.plugins.release.ReleaseExecutionException;
 import org.apache.maven.plugins.release.config.ReleaseConfiguration;
+import org.apache.maven.plugins.release.scm.ReleaseScmCommandException;
+import org.apache.maven.plugins.release.scm.ReleaseScmRepositoryException;
+import org.apache.maven.plugins.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 /**
- * TODO [!]: Description.
+ * Tag the SCM repository after committing the release.
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
 public class ScmTagPhase
+    extends AbstractLogEnabled
     implements ReleasePhase
 {
+    /**
+     * Tool that gets a configured SCM repository from release configuration.
+     */
+    private ScmRepositoryConfigurator scmRepositoryConfigurator;
+
     public void execute( ReleaseConfiguration releaseConfiguration )
+        throws ReleaseExecutionException
     {
-        // TODO [!]: implement
+        validateConfiguration( releaseConfiguration );
+
+        getLogger().info( "Tagging release with the label " + releaseConfiguration.getReleaseLabel()
+ "." );
+
+        ScmRepository repository;
+        ScmProvider provider;
+        try
+        {
+            repository = scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration
);
+
+            provider = scmRepositoryConfigurator.getRepositoryProvider( repository );
+        }
+        catch ( ScmRepositoryException e )
+        {
+            throw new ReleaseScmRepositoryException( e.getMessage(), e.getValidationMessages()
);
+        }
+        catch ( NoSuchScmProviderException e )
+        {
+            throw new ReleaseExecutionException( "Unable to configure SCM repository: " +
e.getMessage(), e );
+        }
 
+        TagScmResult result;
+        try
+        {
+            // TODO: want includes/excludes?
+            ScmFileSet fileSet = new ScmFileSet( releaseConfiguration.getWorkingDirectory()
);
+            result = provider.tag( repository, fileSet, releaseConfiguration.getReleaseLabel()
);
+        }
+        catch ( ScmException e )
+        {
+            throw new ReleaseExecutionException( "An error is occurred in the tag process:
" + e.getMessage(), e );
+        }
+
+        if ( !result.isSuccess() )
+        {
+            throw new ReleaseScmCommandException( "Unable to tag SCM", result );
+        }
     }
 
     public void simulate( ReleaseConfiguration releaseConfiguration )
+        throws ReleaseExecutionException
     {
-        // TODO [!]: implement
+        validateConfiguration( releaseConfiguration );
+
+        getLogger().info( "Full run would be tagging " + releaseConfiguration.getWorkingDirectory()
+ " with label: '" +
+            releaseConfiguration.getReleaseLabel() );
+    }
 
+    private static void validateConfiguration( ReleaseConfiguration releaseConfiguration
)
+        throws ReleaseExecutionException
+    {
+        if ( releaseConfiguration.getReleaseLabel() == null )
+        {
+            throw new ReleaseExecutionException( "A release label is required for committing"
);
+        }
     }
 }

Modified: maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml?rev=398873&r1=398872&r2=398873&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml
Tue May  2 02:01:52 2006
@@ -187,6 +187,11 @@
       <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
       <role-hint>scm-tag</role-hint>
       <implementation>org.apache.maven.plugins.release.phase.ScmTagPhase</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.plugins.release.scm.ScmRepositoryConfigurator</role>
+        </requirement>
+      </requirements>
     </component>
     <component>
       <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>

Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/IsScmFileSetEquals.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/IsScmFileSetEquals.java?rev=398873&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/IsScmFileSetEquals.java
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/IsScmFileSetEquals.java
Tue May  2 02:01:52 2006
@@ -0,0 +1,52 @@
+package org.apache.maven.plugins.release.phase;
+
+/*
+ * 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.scm.ScmFileSet;
+import org.jmock.core.Constraint;
+
+import java.util.Arrays;
+
+/**
+ * JMock constraint to compare file sets since it has no equals method.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @todo add an equals() method
+ */
+class IsScmFileSetEquals
+    implements Constraint
+{
+    private final ScmFileSet fileSet;
+
+    IsScmFileSetEquals( ScmFileSet fileSet )
+    {
+        this.fileSet = fileSet;
+    }
+
+    public boolean eval( Object object )
+    {
+        ScmFileSet fs = (ScmFileSet) object;
+
+        return fs.getBasedir().equals( fileSet.getBasedir() ) &&
+            Arrays.asList( fs.getFiles() ).equals( Arrays.asList( fileSet.getFiles() ) );
+    }
+
+    public StringBuffer describeTo( StringBuffer stringBuffer )
+    {
+        return stringBuffer.append( fileSet.toString() );
+    }
+}

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

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

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCommitPhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCommitPhaseTest.java?rev=398873&r1=398872&r2=398873&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCommitPhaseTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCommitPhaseTest.java
Tue May  2 02:01:52 2006
@@ -44,7 +44,6 @@
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -72,7 +71,7 @@
     public void testCommit()
         throws Exception
     {
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
true );
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
         config.setUrl( "scm-url" );
         MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
         config.setWorkingDirectory( rootProject.getFile().getParentFile() );
@@ -97,7 +96,7 @@
     public void testCommitMultiModule()
         throws Exception
     {
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "multiple-poms",
true );
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "multiple-poms",
false );
         config.setUrl( "scm-url" );
         MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
         config.setWorkingDirectory( rootProject.getFile().getParentFile() );
@@ -131,7 +130,7 @@
     {
         phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "scm-commit-development" );
 
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
true );
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
         config.setUrl( "scm-url" );
         MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
         config.setWorkingDirectory( rootProject.getFile().getParentFile() );
@@ -156,7 +155,7 @@
     public void testCommitNoReleaseLabel()
         throws Exception
     {
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
true );
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
 
         try
         {
@@ -172,7 +171,7 @@
     public void testSimulateCommit()
         throws Exception
     {
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
true );
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
         config.setUrl( "scm-url" );
         MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
         config.setWorkingDirectory( rootProject.getFile().getParentFile() );
@@ -192,7 +191,7 @@
     public void testSimulateCommitNoReleaseLabel()
         throws Exception
     {
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
true );
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
 
         try
         {
@@ -281,16 +280,6 @@
         }
     }
 
-    private ReleaseConfiguration createReleaseConfiguration()
-        throws Exception
-    {
-        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
-        config.setUrl( "scm-url" );
-        config.setReleaseLabel( "release-label" );
-        config.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
-        return config;
-    }
-
     public void testScmResultFailure()
         throws Exception
     {
@@ -313,27 +302,14 @@
         }
     }
 
-    private static class IsScmFileSetEquals
-        implements Constraint
+    private ReleaseConfiguration createReleaseConfiguration()
+        throws Exception
     {
-        private final ScmFileSet fileSet;
-
-        IsScmFileSetEquals( ScmFileSet fileSet )
-        {
-            this.fileSet = fileSet;
-        }
-
-        public boolean eval( Object object )
-        {
-            ScmFileSet fs = (ScmFileSet) object;
-
-            return fs.getBasedir().equals( fileSet.getBasedir() ) &&
-                Arrays.asList( fs.getFiles() ).equals( Arrays.asList( fileSet.getFiles()
) );
-        }
-
-        public StringBuffer describeTo( StringBuffer stringBuffer )
-        {
-            return stringBuffer.append( fileSet.toString() );
-        }
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
+        config.setUrl( "scm-url" );
+        config.setReleaseLabel( "release-label" );
+        config.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
+        return config;
     }
+
 }

Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.java?rev=398873&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.java
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.java
Tue May  2 02:01:52 2006
@@ -0,0 +1,272 @@
+package org.apache.maven.plugins.release.phase;
+
+/*
+ * 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.plugins.release.ReleaseExecutionException;
+import org.apache.maven.plugins.release.config.ReleaseConfiguration;
+import org.apache.maven.plugins.release.scm.DefaultScmRepositoryConfigurator;
+import org.apache.maven.plugins.release.scm.ReleaseScmCommandException;
+import org.apache.maven.plugins.release.scm.ReleaseScmRepositoryException;
+import org.apache.maven.plugins.release.scm.ScmRepositoryConfigurator;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.manager.ScmManagerStub;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.ScmProviderStub;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.jmock.cglib.Mock;
+import org.jmock.core.Constraint;
+import org.jmock.core.constraint.IsAnything;
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.matcher.InvokeOnceMatcher;
+import org.jmock.core.matcher.TestFailureMatcher;
+import org.jmock.core.stub.ReturnStub;
+import org.jmock.core.stub.ThrowStub;
+
+import java.util.Collections;
+
+/**
+ * Test the SCM tag phase.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ScmTagPhaseTest
+    extends AbstractReleaseTestCase
+{
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "scm-tag" );
+    }
+
+    public void testTag()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
+        config.setUrl( "scm-url" );
+        MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
+        config.setWorkingDirectory( rootProject.getFile().getParentFile() );
+        config.setReleaseLabel( "release-label" );
+
+        ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() );
+
+        Mock scmProviderMock = new Mock( ScmProvider.class );
+        Constraint[] arguments =
+            new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual(
"release-label" )};
+        scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).with( arguments
).will(
+            new ReturnStub( new TagScmResult( "...", Collections.singletonList( rootProject.getFile()
) ) ) );
+
+        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
+        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
+
+        phase.execute( config );
+
+        assertTrue( true );
+    }
+
+    public void testCommitMultiModule()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "multiple-poms",
false );
+        config.setUrl( "scm-url" );
+        MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
+        config.setWorkingDirectory( rootProject.getFile().getParentFile() );
+        config.setReleaseLabel( "release-label" );
+
+        ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() );
+
+        Mock scmProviderMock = new Mock( ScmProvider.class );
+        Constraint[] arguments =
+            new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual(
"release-label" )};
+        scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).with( arguments
).will(
+            new ReturnStub( new TagScmResult( "...", Collections.singletonList( rootProject.getFile()
) ) ) );
+
+        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
+        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
+
+        phase.execute( config );
+
+        assertTrue( true );
+    }
+
+    public void testTagNoReleaseLabel()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
+
+        try
+        {
+            phase.execute( config );
+            fail( "Should have thrown an exception" );
+        }
+        catch ( ReleaseExecutionException e )
+        {
+            assertNull( "Check no other cause", e.getCause() );
+        }
+    }
+
+    public void testSimulateTag()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
+        config.setUrl( "scm-url" );
+        MavenProject rootProject = (MavenProject) config.getReactorProjects().get( 0 );
+        config.setWorkingDirectory( rootProject.getFile().getParentFile() );
+        config.setReleaseLabel( "release-label" );
+
+        Mock scmProviderMock = new Mock( ScmProvider.class );
+        scmProviderMock.expects( new TestFailureMatcher( "Shouldn't have called tag" ) ).method(
"tag" );
+
+        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
+        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
+
+        phase.simulate( config );
+
+        assertTrue( true );
+    }
+
+    public void testSimulateTagNoReleaseLabel()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
+
+        try
+        {
+            phase.simulate( config );
+            fail( "Should have thrown an exception" );
+        }
+        catch ( ReleaseExecutionException e )
+        {
+            assertNull( "Check no other cause", e.getCause() );
+        }
+    }
+
+    public void testNoSuchScmProviderExceptionThrown()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+        Mock scmManagerMock = new Mock( ScmManager.class );
+        scmManagerMock.expects( new InvokeOnceMatcher() ).method( "makeScmRepository" ).with(
+            new IsEqual( "scm-url" ) ).will( new ThrowStub( new NoSuchScmProviderException(
"..." ) ) );
+
+        ScmManager scmManager = (ScmManager) scmManagerMock.proxy();
+        DefaultScmRepositoryConfigurator configurator =
+            (DefaultScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
+        configurator.setScmManager( scmManager );
+
+        try
+        {
+            phase.execute( releaseConfiguration );
+
+            fail( "Status check should have failed" );
+        }
+        catch ( ReleaseExecutionException e )
+        {
+            assertEquals( "check cause", NoSuchScmProviderException.class, e.getCause().getClass()
);
+        }
+    }
+
+    public void testScmRepositoryExceptionThrown()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+        Mock scmManagerMock = new Mock( ScmManager.class );
+        scmManagerMock.expects( new InvokeOnceMatcher() ).method( "makeScmRepository" ).with(
+            new IsEqual( "scm-url" ) ).will( new ThrowStub( new ScmRepositoryException( "..."
) ) );
+
+        ScmManager scmManager = (ScmManager) scmManagerMock.proxy();
+        DefaultScmRepositoryConfigurator configurator =
+            (DefaultScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
+        configurator.setScmManager( scmManager );
+
+        try
+        {
+            phase.execute( releaseConfiguration );
+
+            fail( "Status check should have failed" );
+        }
+        catch ( ReleaseScmRepositoryException e )
+        {
+            assertNull( "Check no additional cause", e.getCause() );
+        }
+    }
+
+    public void testScmExceptionThrown()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+        Mock scmProviderMock = new Mock( ScmProvider.class );
+        scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).will(
+            new ThrowStub( new ScmException( "..." ) ) );
+
+        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
+        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
+
+        try
+        {
+            phase.execute( releaseConfiguration );
+
+            fail( "Status check should have failed" );
+        }
+        catch ( ReleaseExecutionException e )
+        {
+            assertEquals( "check cause", ScmException.class, e.getCause().getClass() );
+        }
+    }
+
+    public void testScmResultFailure()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+        ScmManager scmManager = (ScmManager) lookup( ScmManager.ROLE );
+        ScmProviderStub providerStub = (ScmProviderStub) scmManager.getProviderByUrl( releaseConfiguration.getUrl()
);
+
+        providerStub.setTagScmResult( new TagScmResult( "", "", "", false ) );
+
+        try
+        {
+            phase.execute( releaseConfiguration );
+
+            fail( "Commit should have failed" );
+        }
+        catch ( ReleaseScmCommandException e )
+        {
+            assertNull( "check no other cause", e.getCause() );
+        }
+    }
+
+    private ReleaseConfiguration createReleaseConfiguration()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "scm-commit/", "single-pom",
false );
+        config.setUrl( "scm-url" );
+        config.setReleaseLabel( "release-label" );
+        config.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
+        return config;
+    }
+
+}

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

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

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml?rev=398873&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml
Tue May  2 02:01:52 2006
@@ -0,0 +1,29 @@
+<!--
+  ~ 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.
+  -->
+
+<component-set>
+  <components>
+    <!-- Turn off info messages -->
+    <component>
+      <role>org.codehaus.plexus.logging.LoggerManager</role>
+      <implementation>org.codehaus.plexus.logging.console.ConsoleLoggerManager</implementation>
+      <lifecycle-handler>basic</lifecycle-handler>
+      <configuration>
+        <threshold>ERROR</threshold>
+      </configuration>
+    </component>
+  </components>
+</component-set>

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/RunGoalsPhaseTest.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml?rev=398873&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml
Tue May  2 02:01:52 2006
@@ -0,0 +1,33 @@
+<!--
+  ~ 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.
+  -->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.scm.manager.ScmManager</role>
+      <implementation>org.apache.maven.scm.manager.ScmManagerStub</implementation>
+    </component>
+    <!-- Turn off info messages -->
+    <component>
+      <role>org.codehaus.plexus.logging.LoggerManager</role>
+      <implementation>org.codehaus.plexus.logging.console.ConsoleLoggerManager</implementation>
+      <lifecycle-handler>basic</lifecycle-handler>
+      <configuration>
+        <threshold>ERROR</threshold>
+      </configuration>
+    </component>
+  </components>
+</component-set>

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmTagPhaseTest.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message