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/04/24 02:20:42 UTC
svn commit: r396352 [2/2] - in /maven/plugins/trunk/maven-release-plugin/src:
main/java/org/apache/maven/plugins/release/
main/java/org/apache/maven/plugins/release/config/
main/java/org/apache/maven/plugins/release/phase/
main/java/org/apache/maven/pl...
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/DefaultReleaseManagerTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/DefaultReleaseManagerTest.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/DefaultReleaseManagerTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/DefaultReleaseManagerTest.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,275 @@
+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.plugins.release.config.ReleaseConfiguration;
+import org.apache.maven.plugins.release.config.ReleaseConfigurationStore;
+import org.apache.maven.plugins.release.config.ReleaseConfigurationStoreException;
+import org.apache.maven.plugins.release.phase.ReleasePhase;
+import org.apache.maven.plugins.release.phase.ReleasePhaseStub;
+import org.codehaus.plexus.PlexusTestCase;
+import org.jmock.cglib.Mock;
+import org.jmock.core.constraint.IsSame;
+import org.jmock.core.matcher.InvokeOnceMatcher;
+import org.jmock.core.stub.ThrowStub;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Test the default release manager.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class DefaultReleaseManagerTest
+ extends PlexusTestCase
+{
+ private ReleaseConfigurationStore configStore;
+
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ configStore = (ReleaseConfigurationStore) lookup( ReleaseConfigurationStore.ROLE, "stub" );
+ }
+
+ public void testPrepareNoCompletedPhase()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( null );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertTrue( "step1 executed", phase.isExecuted() );
+ assertFalse( "step1 not simulated", phase.isSimulated() );
+ assertTrue( "step2 executed", phase.isExecuted() );
+ assertFalse( "step2 not simulated", phase.isSimulated() );
+ assertTrue( "step3 executed", phase.isExecuted() );
+ assertFalse( "step3 not simulated", phase.isSimulated() );
+ }
+
+ public void testPrepareCompletedPhase()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( "step1" );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertFalse( "step1 not executed", phase.isExecuted() );
+ assertFalse( "step1 not simulated", phase.isSimulated() );
+ phase = (ReleasePhaseStub) phases.get( "step2" );
+ assertTrue( "step2 executed", phase.isExecuted() );
+ assertFalse( "step2 not simulated", phase.isSimulated() );
+ phase = (ReleasePhaseStub) phases.get( "step3" );
+ assertTrue( "step3 executed", phase.isExecuted() );
+ assertFalse( "step3 not simulated", phase.isSimulated() );
+ }
+
+ public void testPrepareCompletedAllPhases()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( "step3" );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertFalse( "step1 not executed", phase.isExecuted() );
+ assertFalse( "step1 not simulated", phase.isSimulated() );
+ phase = (ReleasePhaseStub) phases.get( "step2" );
+ assertFalse( "step2 not executed", phase.isExecuted() );
+ assertFalse( "step2 not simulated", phase.isSimulated() );
+ phase = (ReleasePhaseStub) phases.get( "step3" );
+ assertFalse( "step3 not executed", phase.isExecuted() );
+ assertFalse( "step3 not simulated", phase.isSimulated() );
+ }
+
+ public void testPrepareInvalidCompletedPhase()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( "foo" );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertTrue( "step1 executed", phase.isExecuted() );
+ assertFalse( "step1 not simulated", phase.isSimulated() );
+ phase = (ReleasePhaseStub) phases.get( "step2" );
+ assertTrue( "step2 executed", phase.isExecuted() );
+ assertFalse( "step2 not simulated", phase.isSimulated() );
+ phase = (ReleasePhaseStub) phases.get( "step3" );
+ assertTrue( "step3 executed", phase.isExecuted() );
+ assertFalse( "step3 not simulated", phase.isSimulated() );
+ }
+
+ public void testPrepareSimulateNoCompletedPhase()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test-dryRun" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( null );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertTrue( "step1 simulated", phase.isSimulated() );
+ assertFalse( "step1 not executed", phase.isExecuted() );
+ assertTrue( "step2 simulated", phase.isSimulated() );
+ assertFalse( "step2 not executed", phase.isExecuted() );
+ assertTrue( "step3 simulated", phase.isSimulated() );
+ assertFalse( "step3 not executed", phase.isExecuted() );
+ }
+
+ public void testPrepareSimulateCompletedPhase()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test-dryRun" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( "step1" );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertFalse( "step1 not simulated", phase.isSimulated() );
+ assertFalse( "step1 not executed", phase.isExecuted() );
+ phase = (ReleasePhaseStub) phases.get( "step2" );
+ assertTrue( "step2 simulated", phase.isSimulated() );
+ assertFalse( "step2 not executed", phase.isExecuted() );
+ phase = (ReleasePhaseStub) phases.get( "step3" );
+ assertTrue( "step3 simulated", phase.isSimulated() );
+ assertFalse( "step3 not executed", phase.isExecuted() );
+ }
+
+ public void testPrepareSimulateCompletedAllPhases()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test-dryRun" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( "step3" );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertFalse( "step1 not simulated", phase.isSimulated() );
+ assertFalse( "step1 not executed", phase.isExecuted() );
+ phase = (ReleasePhaseStub) phases.get( "step2" );
+ assertFalse( "step2 not simulated", phase.isSimulated() );
+ assertFalse( "step2 not executed", phase.isExecuted() );
+ phase = (ReleasePhaseStub) phases.get( "step3" );
+ assertFalse( "step3 not simulated", phase.isSimulated() );
+ assertFalse( "step3 not executed", phase.isExecuted() );
+ }
+
+ public void testPrepareSimulateInvalidCompletedPhase()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "test-dryRun" );
+
+ ReleaseConfiguration releaseConfiguration = configStore.read();
+ releaseConfiguration.setCompletedPhase( "foo" );
+
+ releaseManager.prepare( releaseConfiguration );
+
+ Map phases = container.lookupMap( ReleasePhase.ROLE );
+
+ ReleasePhaseStub phase = (ReleasePhaseStub) phases.get( "step1" );
+ assertTrue( "step1 simulated", phase.isSimulated() );
+ assertFalse( "step1 not executed", phase.isExecuted() );
+ phase = (ReleasePhaseStub) phases.get( "step2" );
+ assertTrue( "step2 simulated", phase.isSimulated() );
+ assertFalse( "step2 not executed", phase.isExecuted() );
+ phase = (ReleasePhaseStub) phases.get( "step3" );
+ assertTrue( "step3 simulated", phase.isSimulated() );
+ assertFalse( "step3 not executed", phase.isExecuted() );
+ }
+
+ public void testPrepareUnknownPhaseConfigured()
+ throws Exception
+ {
+ ReleaseManager releaseManager = (ReleaseManager) lookup( ReleaseManager.ROLE, "bad-phase-configured" );
+
+ try
+ {
+ releaseManager.prepare( new ReleaseConfiguration() );
+ fail( "Should have failed to find a phase" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ // good
+ }
+ }
+
+ public void testReleaseConfigurationStoreFailure()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm-url" );
+ releaseConfiguration.setWorkingDirectory( getTestFile( "target/working-directory" ) );
+
+ DefaultReleaseManager releaseManager = (DefaultReleaseManager) lookup( ReleaseManager.ROLE, "test" );
+
+ Mock configStoreMock = new Mock( ReleaseConfigurationStore.class );
+ configStoreMock.expects( new InvokeOnceMatcher() ).method( "read" ).with(
+ new IsSame( releaseConfiguration ) ).will(
+ new ThrowStub( new ReleaseConfigurationStoreException( "message", new IOException( "ioExceptionMsg" ) ) ) );
+
+ releaseManager.setConfigStore( (ReleaseConfigurationStore) configStoreMock.proxy() );
+
+ try
+ {
+ releaseManager.prepare( releaseConfiguration );
+ fail( "Should have failed to read configuration" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ // good
+ assertEquals( "check cause", ReleaseConfigurationStoreException.class, e.getCause().getClass() );
+ }
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/DefaultReleaseManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/DefaultReleaseManagerTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,117 @@
+package org.apache.maven.plugins.release.config;
+
+/*
+ * 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.codehaus.plexus.PlexusTestCase;
+
+import java.io.File;
+
+/**
+ * Test the properties store.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class PropertiesReleaseConfigurationStoreTest
+ extends PlexusTestCase
+{
+ private PropertiesReleaseConfigurationStore store;
+
+ public void testReadFromFile()
+ throws ReleaseConfigurationStoreException
+ {
+ File file = getTestFile( "target/test-classes/release.properties" );
+ store.setPropertiesFile( file );
+
+ ReleaseConfiguration config = store.read();
+ assertEquals( "Expected completedPhase of 'step1'", "step1", config.getCompletedPhase() );
+
+ // TODO: assert other contents
+ }
+
+ public void testReadFromEmptyFile()
+ throws ReleaseConfigurationStoreException
+ {
+ File file = getTestFile( "target/test-classes/empty-release.properties" );
+ store.setPropertiesFile( file );
+
+ ReleaseConfiguration config = store.read();
+
+ assertDefaultReleaseConfiguration( config );
+ }
+
+ public void testReadMissingFile()
+ throws ReleaseConfigurationStoreException
+ {
+ File file = getTestFile( "target/test-classes/no-release.properties" );
+ store.setPropertiesFile( file );
+
+ ReleaseConfiguration config = store.read();
+
+ assertDefaultReleaseConfiguration( config );
+ }
+
+ public void testMergeFromEmptyFile()
+ throws ReleaseConfigurationStoreException
+ {
+ File file = getTestFile( "target/test-classes/empty-release.properties" );
+ store.setPropertiesFile( file );
+
+ ReleaseConfiguration mergeConfiguration = createMergeConfiguration();
+ ReleaseConfiguration config = store.read( mergeConfiguration );
+
+ assertEquals( "Check configurations merged", mergeConfiguration, config );
+ }
+
+ public void testMergeFromMissingFile()
+ throws ReleaseConfigurationStoreException
+ {
+ File file = getTestFile( "target/test-classes/no-release.properties" );
+ store.setPropertiesFile( file );
+
+ ReleaseConfiguration mergeConfiguration = createMergeConfiguration();
+ ReleaseConfiguration config = store.read( mergeConfiguration );
+
+ assertEquals( "Check configurations merged", mergeConfiguration, config );
+ }
+
+ private static void assertDefaultReleaseConfiguration( ReleaseConfiguration config )
+ {
+ assertNull( "Expected no completedPhase", config.getCompletedPhase() );
+
+ // TODO: assert other default contents
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ store = (PropertiesReleaseConfigurationStore) lookup( ReleaseConfigurationStore.ROLE, "properties" );
+ }
+
+ public ReleaseConfiguration createMergeConfiguration()
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+
+ releaseConfiguration.setUrl( "scm-url" );
+ releaseConfiguration.setUsername( "username" );
+ // Not setting other optional SCM settings for brevity
+ releaseConfiguration.setWorkingDirectory( getTestFile( "target/test-working-directory" ) );
+ // Not setting non-override setting completedPhase
+
+ return releaseConfiguration;
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationStoreStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationStoreStub.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationStoreStub.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationStoreStub.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,48 @@
+package org.apache.maven.plugins.release.config;
+
+/*
+ * 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.
+ */
+
+/**
+ * Test stub for the release configuration store that holds a single configuration in memory.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ReleaseConfigurationStoreStub
+ implements ReleaseConfigurationStore
+{
+ /**
+ * The release configuration to use.
+ */
+ private ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+
+ public ReleaseConfiguration read( ReleaseConfiguration mergeConfiguration )
+ {
+ releaseConfiguration.merge( mergeConfiguration );
+ return releaseConfiguration;
+ }
+
+ public ReleaseConfiguration read()
+ throws ReleaseConfigurationStoreException
+ {
+ return releaseConfiguration;
+ }
+
+ public void write( ReleaseConfiguration config )
+ {
+ this.releaseConfiguration = config;
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationStoreStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationStoreStub.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,108 @@
+package org.apache.maven.plugins.release.config;
+
+/*
+ * 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 junit.framework.TestCase;
+import org.apache.maven.settings.Settings;
+
+import java.io.File;
+
+/**
+ * ReleaseConfiguration Tester.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ReleaseConfigurationTest
+ extends TestCase
+{
+ public void testMergeConfigurationSourceEmpty()
+ {
+ ReleaseConfiguration mergeConfiguration = createReleaseConfiguration();
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.merge( mergeConfiguration );
+
+ assertEquals( "Check merge", mergeConfiguration, releaseConfiguration );
+ }
+
+ public void testMergeConfigurationDestEmpty()
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ releaseConfiguration.merge( new ReleaseConfiguration() );
+
+ ReleaseConfiguration expectedConfiguration = createReleaseConfiguration( releaseConfiguration.getSettings(),
+ releaseConfiguration.getWorkingDirectory() );
+ assertEquals( "Check merge", expectedConfiguration, releaseConfiguration );
+ }
+
+ public void testMergeConfiguration()
+ {
+ Settings settings = new Settings();
+ File workingDirectory = new File( "." );
+
+ ReleaseConfiguration mergeConfiguration =
+ createMergeConfiguration( settings, workingDirectory, "completed-phase-merge" );
+
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+ releaseConfiguration.merge( mergeConfiguration );
+
+ ReleaseConfiguration expectedConfiguration = createMergeConfiguration( releaseConfiguration.getSettings(),
+ releaseConfiguration.getWorkingDirectory(),
+ releaseConfiguration.getCompletedPhase() );
+ assertEquals( "Check merge", expectedConfiguration, releaseConfiguration );
+ }
+
+ private static ReleaseConfiguration createMergeConfiguration( Settings settings, File workingDirectory,
+ String completedPhase )
+ {
+ ReleaseConfiguration mergeConfiguration = new ReleaseConfiguration();
+ mergeConfiguration.setUrl( "scm-url-merge" );
+ mergeConfiguration.setCompletedPhase( completedPhase );
+ mergeConfiguration.setPassphrase( "passphrase-merge" );
+ mergeConfiguration.setPassword( "password-merge" );
+ mergeConfiguration.setPrivateKey( "private-key-merge" );
+ mergeConfiguration.setSettings( settings );
+ mergeConfiguration.setTagBase( "tag-base-merge" );
+ mergeConfiguration.setUsername( "username-merge" );
+ mergeConfiguration.setWorkingDirectory( workingDirectory );
+ return mergeConfiguration;
+ }
+
+ private static ReleaseConfiguration createReleaseConfiguration()
+ {
+ Settings settings = new Settings();
+ File workingDirectory = new File( "." );
+
+ return createReleaseConfiguration( settings, workingDirectory );
+ }
+
+ private static ReleaseConfiguration createReleaseConfiguration( Settings settings, File workingDirectory )
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm-url" );
+ releaseConfiguration.setCompletedPhase( "completed-phase" );
+ releaseConfiguration.setPassphrase( "passphrase" );
+ releaseConfiguration.setPassword( "password" );
+ releaseConfiguration.setPrivateKey( "private-key" );
+ releaseConfiguration.setSettings( settings );
+ releaseConfiguration.setTagBase( "tag-base" );
+ releaseConfiguration.setUsername( "username" );
+ releaseConfiguration.setWorkingDirectory( workingDirectory );
+ return releaseConfiguration;
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ReleasePhaseStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ReleasePhaseStub.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ReleasePhaseStub.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ReleasePhaseStub.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,63 @@
+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.config.ReleaseConfiguration;
+
+/**
+ * Test stub for testing if a phase is executed.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ReleasePhaseStub
+ implements ReleasePhase
+{
+ /**
+ * Whether the phase was simulated.
+ */
+ private boolean simulated;
+
+ /**
+ * Whether the phase was executed.
+ */
+ private boolean executed;
+
+ /**
+ * The name of the phase stubbed.
+ */
+ private String name;
+
+ public void execute( ReleaseConfiguration releaseConfiguration )
+ {
+ executed = true;
+ }
+
+ public void simulate( ReleaseConfiguration releaseConfiguration )
+ {
+ simulated = true;
+ }
+
+ public boolean isExecuted()
+ {
+ return executed;
+ }
+
+ public boolean isSimulated()
+ {
+ return simulated;
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ReleasePhaseStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ReleasePhaseStub.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,335 @@
+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.ScmRepositoryConfigurator;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.command.status.StatusScmResult;
+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.codehaus.plexus.PlexusTestCase;
+import org.jmock.cglib.Mock;
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.matcher.InvokeAtLeastOnceMatcher;
+import org.jmock.core.stub.ThrowStub;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Test the SCM modification check phase.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ScmCheckModificationsPhaseTest
+ extends PlexusTestCase
+{
+ private ReleasePhase phase;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "scm-check-modifications" );
+ }
+
+ public void testNoSuchScmProviderExceptionThrown()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm-url" );
+ releaseConfiguration.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
+
+ Mock scmManagerMock = new Mock( ScmManager.class );
+ scmManagerMock.expects( new InvokeAtLeastOnceMatcher() ).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() );
+ }
+
+ try
+ {
+ phase.simulate( 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 = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm-url" );
+ releaseConfiguration.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
+
+ Mock scmManagerMock = new Mock( ScmManager.class );
+ scmManagerMock.expects( new InvokeAtLeastOnceMatcher() ).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 ( ReleaseExecutionException e )
+ {
+ assertEquals( "check cause", ScmRepositoryException.class, e.getCause().getClass() );
+ }
+
+ try
+ {
+ phase.simulate( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ assertEquals( "check cause", ScmRepositoryException.class, e.getCause().getClass() );
+ }
+ }
+
+ public void testScmExceptionThrown()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm-url" );
+ releaseConfiguration.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
+
+ Mock scmProviderMock = new Mock( ScmProvider.class );
+ scmProviderMock.expects( new InvokeAtLeastOnceMatcher() ).method( "status" ).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() );
+ }
+
+ try
+ {
+ phase.simulate( 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.setStatusScmResult( new StatusScmResult( "", "", "", false ) );
+
+ try
+ {
+ phase.execute( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseScmCommandException e )
+ {
+ assertNull( "check no other cause", e.getCause() );
+ }
+
+ try
+ {
+ phase.simulate( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseScmCommandException e )
+ {
+ assertNull( "check no other cause", e.getCause() );
+ }
+ }
+
+ public void testNoModifications()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ setChangedFiles( releaseConfiguration, Collections.EMPTY_LIST );
+
+ phase.execute( releaseConfiguration );
+
+ phase.simulate( releaseConfiguration );
+
+ // successful execution is verification enough
+ assertTrue( true );
+ }
+
+ public void testModificationsToExcludedFilesOnly()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ setChangedFiles( releaseConfiguration, Arrays.asList( new String[]{"release.properties", "pom.xml",
+ "pom.xml.backup", "module/pom.xml", "pom.xml.tag", "pom.xml.release"} ) );
+
+ phase.execute( releaseConfiguration );
+
+ phase.simulate( releaseConfiguration );
+
+ // successful execution is verification enough
+ assertTrue( true );
+ }
+
+ public void testModificationsToIncludedFilesOnly()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ setChangedFiles( releaseConfiguration, Collections.singletonList( "something.txt" ) );
+
+ try
+ {
+ phase.execute( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ // verify no cause as an extra check that it is the right exception
+ assertNull( "check no cause", e.getCause() );
+ }
+
+ try
+ {
+ phase.simulate( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ // verify no cause as an extra check that it is the right exception
+ assertNull( "check no cause", e.getCause() );
+ }
+ }
+
+ public void testModificationsToIncludedAndExcludedFiles()
+ throws Exception
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ setChangedFiles( releaseConfiguration, Arrays.asList( new String[]{"release.properties", "pom.xml",
+ "pom.xml.backup", "module/pom.xml", "pom.xml.tag", "pom.xml.release", "something.txt"} ) );
+
+ try
+ {
+ phase.execute( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ // verify no cause as an extra check that it is the right exception
+ assertNull( "check no cause", e.getCause() );
+ }
+
+ try
+ {
+ phase.simulate( releaseConfiguration );
+
+ fail( "Status check should have failed" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ // verify no cause as an extra check that it is the right exception
+ assertNull( "check no cause", e.getCause() );
+ }
+ }
+
+ private void setChangedFiles( ReleaseConfiguration releaseConfiguration, List changedFiles )
+ throws Exception
+ {
+ ScmManager scmManager = (ScmManager) lookup( ScmManager.ROLE );
+ ScmProviderStub providerStub = (ScmProviderStub) scmManager.getProviderByUrl( releaseConfiguration.getUrl() );
+
+ providerStub.setStatusScmResult( new StatusScmResult( "", createScmFiles( changedFiles ) ) );
+ }
+
+ private static List createScmFiles( List changedFiles )
+ {
+ List files = new ArrayList( changedFiles.size() );
+ for ( Iterator i = changedFiles.iterator(); i.hasNext(); )
+ {
+ String fileName = (String) i.next();
+ files.add( new ScmFile( fileName, ScmFileStatus.MODIFIED ) );
+ }
+ return files;
+ }
+
+ private static ReleaseConfiguration createReleaseConfiguration()
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm:svn:file://localhost/tmp/scm-repo" );
+ releaseConfiguration.setWorkingDirectory( getTestFile( "target/test/checkout" ) );
+ return releaseConfiguration;
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/scm/DefaultScmRepositoryConfiguratorTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/scm/DefaultScmRepositoryConfiguratorTest.java?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/scm/DefaultScmRepositoryConfiguratorTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/scm/DefaultScmRepositoryConfiguratorTest.java Sun Apr 23 17:20:38 2006
@@ -0,0 +1,193 @@
+package org.apache.maven.plugins.release.scm;
+
+/*
+ * 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.config.ReleaseConfiguration;
+import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
+import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Test the default SCM repository configurator.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class DefaultScmRepositoryConfiguratorTest
+ extends PlexusTestCase
+{
+ private ScmRepositoryConfigurator scmRepositoryConfigurator;
+
+ private static final int CVS_PORT = 2401;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ scmRepositoryConfigurator = (ScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.ROLE );
+ }
+
+ public void testGetConfiguredRepository()
+ throws ScmRepositoryException, NoSuchScmProviderException
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ ScmRepository repository = scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ assertEquals( "check provider", "cvs", repository.getProvider() );
+ assertEquals( "check username", "anoncvs", repository.getProviderRepository().getUser() );
+ assertNull( "check password", repository.getProviderRepository().getPassword() );
+ }
+
+ public void testGetConfiguredRepositoryWithUsernameAndPassword()
+ throws ScmRepositoryException, NoSuchScmProviderException
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration( "username", "password" );
+
+ ScmRepository repository = scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ assertEquals( "check username", "username", repository.getProviderRepository().getUser() );
+ assertEquals( "check password", "password", repository.getProviderRepository().getPassword() );
+ }
+
+ public void testGetConfiguredRepositoryWithTagBase()
+ throws ScmRepositoryException, NoSuchScmProviderException
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm:svn:http://localhost/home/svn/module/trunk" );
+ releaseConfiguration.setTagBase( "http://localhost/home/svn/module/tags" );
+
+ ScmRepository repository = scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ SvnScmProviderRepository providerRepository = (SvnScmProviderRepository) repository.getProviderRepository();
+ assertEquals( "check tag base", "http://localhost/home/svn/module/tags", providerRepository.getTagBase() );
+ }
+
+ public void testGetConfiguredRepositoryWithHost()
+ throws ScmRepositoryException, NoSuchScmProviderException
+ {
+ Settings settings = new Settings();
+ Server server = new Server();
+ server.setId( "localhost:" + CVS_PORT );
+ server.setUsername( "settings-username" );
+ server.setPassword( "settings-password" );
+ server.setPrivateKey( "settings-private-key" );
+ server.setPassphrase( "settings-passphrase" );
+ settings.addServer( server );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm:cvs:pserver:anoncvs@localhost:/home/cvs:module" );
+ releaseConfiguration.setSettings( settings );
+
+ ScmRepository repository = scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ ScmProviderRepositoryWithHost providerRepository =
+ (ScmProviderRepositoryWithHost) repository.getProviderRepository();
+ assertEquals( "check host", "localhost", providerRepository.getHost() );
+ assertEquals( "check port", CVS_PORT, providerRepository.getPort() );
+ assertEquals( "check username", "settings-username", providerRepository.getUser() );
+ assertEquals( "check password", "settings-password", providerRepository.getPassword() );
+ assertEquals( "check private key", "settings-private-key", providerRepository.getPrivateKey() );
+ assertEquals( "check passphrase", "settings-passphrase", providerRepository.getPassphrase() );
+ }
+
+ public void testGetConfiguredRepositoryInvalidScmUrl()
+ throws NoSuchScmProviderException
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm-url" );
+
+ try
+ {
+ scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ fail( "Expected failure to get a repository with an invalid SCM URL" );
+ }
+ catch ( ScmRepositoryException e )
+ {
+ // expected
+ }
+ }
+
+ public void testGetConfiguredRepositoryInvalidScmProvider()
+ throws ScmRepositoryException
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm:url:" );
+
+ try
+ {
+ scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ fail( "Expected failure to get a repository with an invalid SCM URL" );
+ }
+ catch ( NoSuchScmProviderException e )
+ {
+ // expected
+ }
+ }
+
+ public void testGetConfiguredRepositoryInvalidScmUrlParameters()
+ throws NoSuchScmProviderException
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm:cvs:" );
+
+ try
+ {
+ scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ fail( "Expected failure to get a repository with an invalid SCM URL" );
+ }
+ catch ( ScmRepositoryException e )
+ {
+ // expected
+ }
+ }
+
+ public void testGetRepositoryProvider()
+ throws ScmRepositoryException, NoSuchScmProviderException
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+
+ ScmRepository repository = scmRepositoryConfigurator.getConfiguredRepository( releaseConfiguration );
+
+ ScmProvider provider = scmRepositoryConfigurator.getRepositoryProvider( repository );
+ assertEquals( "Check SCM provider", "cvs", provider.getScmType() );
+ }
+
+ private static ReleaseConfiguration createReleaseConfiguration()
+ {
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setUrl( "scm:cvs:pserver:anoncvs@localhost:/home/cvs:module" );
+ return releaseConfiguration;
+ }
+
+ private static ReleaseConfiguration createReleaseConfiguration( String username, String password )
+ {
+ ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+ releaseConfiguration.setUsername( username );
+ releaseConfiguration.setPassword( password );
+ return releaseConfiguration;
+ }
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/scm/DefaultScmRepositoryConfiguratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/scm/DefaultScmRepositoryConfiguratorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/empty-release.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/empty-release.properties?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/empty-release.properties (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/empty-release.properties Sun Apr 23 17:20:38 2006
@@ -0,0 +1,16 @@
+#
+# 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.
+#
+
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/empty-release.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/empty-release.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/DefaultReleaseManagerTest.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/DefaultReleaseManagerTest.xml?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/DefaultReleaseManagerTest.xml (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/DefaultReleaseManagerTest.xml Sun Apr 23 17:20:38 2006
@@ -0,0 +1,117 @@
+<!--
+ ~ 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.plugins.release.ReleaseManager</role>
+ <role-hint>test</role-hint>
+ <implementation>org.apache.maven.plugins.release.DefaultReleaseManager</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <field-name>releasePhases</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.plugins.release.config.ReleaseConfigurationStore</role>
+ <role-hint>stub</role-hint>
+ <field-name>configStore</field-name>
+ </requirement>
+ </requirements>
+ <configuration>
+ <phases>
+ <phase>step1</phase>
+ <phase>step2</phase>
+ <phase>step3</phase>
+ </phases>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.ReleaseManager</role>
+ <role-hint>test-dryRun</role-hint>
+ <implementation>org.apache.maven.plugins.release.DefaultReleaseManager</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <field-name>releasePhases</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.plugins.release.config.ReleaseConfigurationStore</role>
+ <role-hint>stub</role-hint>
+ <field-name>configStore</field-name>
+ </requirement>
+ </requirements>
+ <configuration>
+ <phases>
+ <phase>step1</phase>
+ <phase>step2</phase>
+ <phase>step3</phase>
+ </phases>
+ <dryRun>true</dryRun>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.ReleaseManager</role>
+ <role-hint>bad-phase-configured</role-hint>
+ <implementation>org.apache.maven.plugins.release.DefaultReleaseManager</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <field-name>releasePhases</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.plugins.release.config.ReleaseConfigurationStore</role>
+ <role-hint>stub</role-hint>
+ <field-name>configStore</field-name>
+ </requirement>
+ </requirements>
+ <configuration>
+ <phases>
+ <phase>foo</phase>
+ </phases>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.config.ReleaseConfigurationStore</role>
+ <role-hint>stub</role-hint>
+ <implementation>org.apache.maven.plugins.release.config.ReleaseConfigurationStoreStub</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>step1</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.ReleasePhaseStub</implementation>
+ <configuration>
+ <name>step1</name>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>step2</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.ReleasePhaseStub</implementation>
+ <configuration>
+ <name>step2</name>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>step3</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.ReleasePhaseStub</implementation>
+ <configuration>
+ <name>step3</name>
+ </configuration>
+ </component>
+ </components>
+</component-set>
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/DefaultReleaseManagerTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/DefaultReleaseManagerTest.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.xml?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.xml (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.xml Sun Apr 23 17:20:38 2006
@@ -0,0 +1,43 @@
+<!--
+ ~ 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.plugins.release.phase.ReleasePhase</role>
+ <role-hint>scm-check-modifications</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.ScmCheckModificationsPhase</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.plugins.release.scm.ScmRepositoryConfigurator</role>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.scm.ScmRepositoryConfigurator</role>
+ <implementation>org.apache.maven.plugins.release.scm.DefaultScmRepositoryConfigurator</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.scm.manager.ScmManager</role>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.apache.maven.scm.manager.ScmManager</role>
+ <implementation>org.apache.maven.scm.manager.ScmManagerStub</implementation>
+ </component>
+ </components>
+</component-set>
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/ScmCheckModificationsPhaseTest.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties?rev=396352&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties Sun Apr 23 17:20:38 2006
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+
+completedPhase=step1
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision