From 1b21701df33d7af6700a9f969ab38a13c7a64e37 Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Sat, 21 May 2016 08:40:38 +0000 Subject: [PATCH] Introduce PlexusJUnit4TestCase to be able to use advanced JUnit features git-svn-id: https://svn.apache.org/repos/asf/maven/release/trunk@1744874 13f79535-47bb-0310-9956-ffa450edef68 --- .../shared/release/PlexusJUnit4TestCase.java | 259 ++++++++++++ .../release/phase/EndReleasePhaseTest.java | 20 +- .../phase/InputVariablesPhaseTest.java | 45 ++- .../release/phase/MapVersionsPhaseTest.java | 368 ++++++++++++------ .../phase/RunCompleteGoalsPhaseTest.java | 91 ++--- .../phase/RunPerformGoalsPhaseTest.java | 11 +- .../phase/RunPrepareGoalsPhaseTest.java | 91 ++--- .../phase/ScmCheckModificationsPhaseTest.java | 88 +++-- 8 files changed, 698 insertions(+), 275 deletions(-) create mode 100644 maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java new file mode 100644 index 000000000..5f9d52cc2 --- /dev/null +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java @@ -0,0 +1,259 @@ +package org.apache.maven.shared.release; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 static org.junit.Assert.fail; + +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.context.Context; +import org.junit.After; +import org.junit.Before; + +/** + * Based on PlexusTestCase from org.codehaus.plexus:plexus-container-default + * + * @author Robert Scholte + */ +public abstract class PlexusJUnit4TestCase +{ + private PlexusContainer container; + + private static String basedir; + + @Before + public void setUp() + throws Exception + { + InputStream configuration = null; + + try + { + configuration = getCustomConfiguration(); + + if ( configuration == null ) + { + configuration = getConfiguration(); + } + } + catch ( Exception e ) + { + System.out.println( "Error with configuration:" ); + + System.out.println( "configuration = " + configuration ); + + fail( e.getMessage() ); + } + + basedir = getBasedir(); + + container = createContainerInstance(); + + container.addContextValue( "basedir", getBasedir() ); + + // this method was deprecated + customizeContext(); + + customizeContext( getContext() ); + + boolean hasPlexusHome = getContext().contains( "plexus.home" ); + + if ( !hasPlexusHome ) + { + File f = getTestFile( "target/plexus-home" ); + + if ( !f.isDirectory() ) + { + f.mkdir(); + } + + getContext().put( "plexus.home", f.getAbsolutePath() ); + } + + if ( configuration != null ) + { + container.setConfigurationResource( new InputStreamReader( configuration ) ); + } + + container.initialize(); + + container.start(); + } + + protected PlexusContainer createContainerInstance() + { + return new DefaultPlexusContainer(); + } + + private Context getContext() + { + return container.getContext(); + } + + //!!! this should probably take a context as a parameter so that the + // user is not forced to do getContainer().addContextValue(..) + // this would require a change to PlexusContainer in order to get + // hold of the context ... + // @deprecated use void customizeContext( Context context ) + protected void customizeContext() + throws Exception + { + } + + + protected void customizeContext( Context context ) + throws Exception + { + } + + + protected InputStream getCustomConfiguration() + throws Exception + { + return null; + } + + @After + public void tearDown() + throws Exception + { + container.dispose(); + + container = null; + } + + protected PlexusContainer getContainer() + { + return container; + } + + protected InputStream getConfiguration() + throws Exception + { + return getConfiguration( null ); + } + + protected InputStream getConfiguration( String subname ) + throws Exception + { + String className = getClass().getName(); + + String base = className.substring( className.lastIndexOf( "." ) + 1 ); + + String config = null; + + if ( subname == null || subname.equals( "" ) ) + { + config = base + ".xml"; + } + else + { + config = base + "-" + subname + ".xml"; + } + + InputStream configStream = getResourceAsStream( config ); + + return configStream; + } + + protected InputStream getResourceAsStream( String resource ) + { + return getClass().getResourceAsStream( resource ); + } + + protected ClassLoader getClassLoader() + { + return getClass().getClassLoader(); + } + + // ---------------------------------------------------------------------- + // Container access + // ---------------------------------------------------------------------- + + protected Object lookup( String componentKey ) + throws Exception + { + return getContainer().lookup( componentKey ); + } + + protected Object lookup( String role, String id ) + throws Exception + { + return getContainer().lookup( role, id ); + } + + protected void release( Object component ) + throws Exception + { + getContainer().release( component ); + } + + // ---------------------------------------------------------------------- + // Helper methods for sub classes + // ---------------------------------------------------------------------- + + public static File getTestFile( String path ) + { + return new File( getBasedir(), path ); + } + + public static File getTestFile( String basedir, String path ) + { + File basedirFile = new File( basedir ); + + if ( ! basedirFile.isAbsolute() ) + { + basedirFile = getTestFile( basedir ); + } + + return new File( basedirFile, path ); + } + + public static String getTestPath( String path ) + { + return getTestFile( path ).getAbsolutePath(); + } + + public static String getTestPath( String basedir, String path ) + { + return getTestFile( basedir, path ).getAbsolutePath(); + } + + public static String getBasedir() + { + if ( basedir != null ) + { + return basedir; + } + + basedir = System.getProperty( "basedir" ); + + if ( basedir == null ) + { + basedir = new File( "" ).getAbsolutePath(); + } + + return basedir; + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/EndReleasePhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/EndReleasePhaseTest.java index fb8112a85..379c39d45 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/EndReleasePhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/EndReleasePhaseTest.java @@ -19,11 +19,15 @@ * under the License. */ +import static org.junit.Assert.assertEquals; + +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; /** * Test the the end release phase. Nothing to see here really, but we want to make sure it is configured. @@ -31,11 +35,11 @@ * @author Brett Porter */ public class EndReleasePhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private ReleasePhase phase; - protected void setUp() + public void setUp() throws Exception { super.setUp(); @@ -43,19 +47,21 @@ protected void setUp() phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "end-release" ); } + @Test public void testExecute() throws ReleaseExecutionException, ReleaseFailureException { - phase.execute( new ReleaseDescriptor(), new DefaultReleaseEnvironment(), null ); + ReleaseResult result = phase.execute( new ReleaseDescriptor(), new DefaultReleaseEnvironment(), null ); - assertTrue( true ); + assertEquals( ReleaseResult.SUCCESS, result.getResultCode() ); } + @Test public void testSimulate() throws ReleaseExecutionException, ReleaseFailureException { - phase.simulate( new ReleaseDescriptor(), new DefaultReleaseEnvironment(), null ); + ReleaseResult result = phase.simulate( new ReleaseDescriptor(), new DefaultReleaseEnvironment(), null ); - assertTrue( true ); + assertEquals( ReleaseResult.SUCCESS, result.getResultCode() ); } } diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java index 917474f67..b59a84eb5 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java @@ -19,6 +19,7 @@ * under the License. */ +import static org.junit.Assert.*; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.mock; @@ -32,12 +33,13 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; -import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; +import org.junit.Test; /** * Test the variable input phase. @@ -45,23 +47,25 @@ * @author Brett Porter */ public class InputVariablesPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private InputVariablesPhase phase; - protected void setUp() + public void setUp() throws Exception { super.setUp(); phase = (InputVariablesPhase) lookup( ReleasePhase.ROLE, "input-variables" ); } + @Test public void testInputVariablesInteractive() throws Exception { // prepare Prompter mockPrompter = mock( Prompter.class ); - when( mockPrompter.prompt( isA( String.class ), eq( "artifactId-1.0" ) ) ).thenReturn( "tag-value", "simulated-tag-value" ); + when( mockPrompter.prompt( isA( String.class ), eq( "artifactId-1.0" ) ) ).thenReturn( "tag-value", + "simulated-tag-value" ); phase.setPrompter( mockPrompter ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -84,13 +88,14 @@ public void testInputVariablesInteractive() // execute phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); - //verify + // verify assertEquals( "Check tag", "simulated-tag-value", releaseDescriptor.getScmReleaseLabel() ); - + verify( mockPrompter, times( 2 ) ).prompt( isA( String.class ), eq( "artifactId-1.0" ) ); verifyNoMoreInteractions( mockPrompter ); } + @Test public void testUnmappedVersion() throws Exception { @@ -123,6 +128,7 @@ public void testUnmappedVersion() } } + @Test public void testInputVariablesNonInteractive() throws Exception { @@ -154,11 +160,12 @@ public void testInputVariablesNonInteractive() // verify assertEquals( "Check tag", "artifactId-1.0", releaseDescriptor.getScmReleaseLabel() ); - + // never use prompter verifyNoMoreInteractions( mockPrompter ); } + @Test public void testInputVariablesNonInteractiveConfigured() throws Exception { @@ -188,11 +195,12 @@ public void testInputVariablesNonInteractiveConfigured() // verify assertEquals( "Check tag", "simulated-tag-value", releaseDescriptor.getScmReleaseLabel() ); - + // never use prompter verifyNoMoreInteractions( mockPrompter ); } + @Test public void testInputVariablesInteractiveConfigured() throws Exception { @@ -220,17 +228,19 @@ public void testInputVariablesInteractiveConfigured() // verify assertEquals( "Check tag", "simulated-tag-value", releaseDescriptor.getScmReleaseLabel() ); - + // never use prompter verifyNoMoreInteractions( mockPrompter ); } + @Test public void testPrompterException() throws Exception { // prepare Prompter mockPrompter = mock( Prompter.class ); - when( mockPrompter.prompt( isA( String.class ), isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); + when( mockPrompter.prompt( isA( String.class ), + isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); phase.setPrompter( mockPrompter ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -267,13 +277,14 @@ public void testPrompterException() { assertEquals( "check cause", PrompterException.class, e.getCause().getClass() ); } - - //verify + + // verify verify( mockPrompter, times( 2 ) ).prompt( isA( String.class ), isA( String.class ) ); verifyNoMoreInteractions( mockPrompter ); } - //MRELEASE-110 + // MRELEASE-110 + @Test public void testCvsTag() throws Exception { @@ -305,12 +316,13 @@ public void testCvsTag() // verify assertEquals( "Check tag", "artifactId-1_0", releaseConfiguration.getScmReleaseLabel() ); - + // never use prompter verifyNoMoreInteractions( mockPrompter ); } - //MRELEASE-159 + // MRELEASE-159 + @Test public void testCustomTagFormat() throws Exception { @@ -342,7 +354,7 @@ public void testCustomTagFormat() // verify assertEquals( "Check tag", "simulated-artifactId-1.0", releaseDescriptor.getScmReleaseLabel() ); - + // never use prompter verifyNoMoreInteractions( mockPrompter ); } @@ -355,5 +367,4 @@ private static MavenProject createProject( String artifactId, String version ) model.setVersion( version ); return new MavenProject( model ); } - } \ No newline at end of file diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java index 9502cd3bf..f25a3fc7f 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java @@ -19,6 +19,9 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Matchers.startsWith; @@ -35,13 +38,14 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; +import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -51,11 +55,14 @@ * @author Brett Porter */ public class MapVersionsPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private static final String TEST_MAP_BRANCH_VERSIONS = "test-map-branch-versions"; + private static final String TEST_MAP_DEVELOPMENT_VERSIONS = "test-map-development-versions"; + private static final String TEST_MAP_RELEASE_VERSIONS = "test-map-release-versions"; + @Mock private Prompter mockPrompter; @@ -67,13 +74,14 @@ public void setUp() } @Override - protected void tearDown() + public void tearDown() throws Exception { super.tearDown(); verifyNoMoreInteractions( mockPrompter ); } + @Test public void testExecuteSnapshot_MapRelease() throws Exception { @@ -81,8 +89,7 @@ public void testExecuteSnapshot_MapRelease() MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0-SNAPSHOT" ); - when( - mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), eq( "1.0" ) ) ).thenReturn( "2.0" ); phase.setPrompter( mockPrompter ); @@ -97,10 +104,11 @@ public void testExecuteSnapshot_MapRelease() assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0" ), releaseDescriptor.getReleaseVersions() ); - verify( mockPrompter ).prompt( startsWith( "What is the release version for \"" + project.getName() - + "\"?" ), eq( "1.0" ) ); + verify( mockPrompter ).prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + eq( "1.0" ) ); } + @Test public void testSimulateSnapshot_MapReleaseVersions() throws Exception { @@ -108,8 +116,7 @@ public void testSimulateSnapshot_MapReleaseVersions() MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0-SNAPSHOT" ); - when( - mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), eq( "1.0" ) ) ).thenReturn( "2.0" ); phase.setPrompter( mockPrompter ); @@ -123,11 +130,12 @@ public void testSimulateSnapshot_MapReleaseVersions() // verify assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0" ), releaseDescriptor.getReleaseVersions() ); - verify( mockPrompter ).prompt( startsWith( "What is the release version for \"" + project.getName() - + "\"?" ), eq( "1.0" ) ); + verify( mockPrompter ).prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + eq( "1.0" ) ); } // MRELEASE-403: Release plugin ignores given version number + @Test public void testMapReleaseVersionsInteractiveAddZeroIncremental() throws Exception { @@ -135,8 +143,7 @@ public void testMapReleaseVersionsInteractiveAddZeroIncremental() MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0-SNAPSHOT" ); - when( - mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), eq( "1.0" ) ) ).thenReturn( "1.0.0" ); phase.setPrompter( mockPrompter ); @@ -160,13 +167,15 @@ public void testMapReleaseVersionsInteractiveAddZeroIncremental() // verify assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "1.0.0" ), releaseDescriptor.getReleaseVersions() ); - verify( mockPrompter, times( 2 ) ).prompt( startsWith( "What is the release version for \"" + project.getName() - + "\"?" ), eq( "1.0" ) ); + verify( mockPrompter, + times( 2 ) ).prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + eq( "1.0" ) ); } /** * Test to release "SNAPSHOT" version MRELEASE-90 */ + @Test public void testMapReleaseVersionsInteractiveWithSnaphotVersion() throws Exception { @@ -174,8 +183,7 @@ public void testMapReleaseVersionsInteractiveWithSnaphotVersion() MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "SNAPSHOT" ); - when( - mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), eq( "1.0" ) ) ).thenReturn( "2.0" ); phase.setPrompter( mockPrompter ); @@ -200,13 +208,15 @@ public void testMapReleaseVersionsInteractiveWithSnaphotVersion() assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0" ), releaseDescriptor.getReleaseVersions() ); - verify( mockPrompter, times( 2 ) ).prompt( startsWith( "What is the release version for \"" + project.getName() - + "\"?" ), eq( "1.0" ) ); + verify( mockPrompter, + times( 2 ) ).prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), + eq( "1.0" ) ); } /** * MRELEASE-524: ignores commandline versions in batch mode */ + @Test public void testMapReleaseVersionsNonInteractiveWithExplicitVersion() throws Exception { @@ -239,6 +249,7 @@ public void testMapReleaseVersionsNonInteractiveWithExplicitVersion() releaseDescriptor.getReleaseVersions() ); } + @Test public void testExecuteSnapshotNonInteractive_MapRelease() throws Exception { @@ -258,6 +269,7 @@ public void testExecuteSnapshotNonInteractive_MapRelease() releaseDescriptor.getReleaseVersions() ); } + @Test public void testSimulateSnapshotNonInteractive_MapReleaseVersions() throws Exception { @@ -277,6 +289,7 @@ public void testSimulateSnapshotNonInteractive_MapReleaseVersions() releaseDescriptor.getReleaseVersions() ); } + @Test public void testMapDevVersionsInteractive() throws Exception { @@ -284,9 +297,8 @@ public void testMapDevVersionsInteractive() MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0" ); - when( - mockPrompter.prompt( startsWith( "What is the new development version for \"" + project.getName() + "\"?" ), - eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the new development version for \"" + project.getName() + + "\"?" ), eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); List reactorProjects = Collections.singletonList( project ); @@ -311,12 +323,13 @@ public void testMapDevVersionsInteractive() releaseDescriptor.getDevelopmentVersions() ); verify( mockPrompter, times( 2 ) ).prompt( startsWith( "What is the new development version for \"" - + project.getName() + "\"?" ), eq( "1.1-SNAPSHOT" ) ); + + project.getName() + "\"?" ), eq( "1.1-SNAPSHOT" ) ); } /** * MRELEASE-760: updateWorkingCopyVersions=false still bumps up pom versions to next development version */ + @Test public void testMapDevVersionsInteractiveDoNotUpdateWorkingCopy() throws Exception { @@ -350,6 +363,7 @@ public void testMapDevVersionsInteractiveDoNotUpdateWorkingCopy() releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testMapDevVersionsNonInteractive() throws Exception { @@ -385,6 +399,7 @@ public void testMapDevVersionsNonInteractive() /** * MRELEASE-524: ignores commandline versions in batch mode */ + @Test public void testMapDevVersionsNonInteractiveWithExplicitVersion() throws Exception { @@ -418,13 +433,15 @@ public void testMapDevVersionsNonInteractiveWithExplicitVersion() releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testPrompterException() throws Exception { // prepare MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); - when( mockPrompter.prompt( isA( String.class ), isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); + when( mockPrompter.prompt( isA( String.class ), + isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); phase.setPrompter( mockPrompter ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -462,6 +479,7 @@ public void testPrompterException() verify( mockPrompter, times( 2 ) ).prompt( isA( String.class ), isA( String.class ) ); } + @Test public void testAdjustVersionInteractive() throws Exception { @@ -469,9 +487,8 @@ public void testAdjustVersionInteractive() MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); MavenProject project = createProject( "artifactId", "foo" ); - when( - mockPrompter.prompt( startsWith( "What is the new development version for \"" + project.getName() + "\"?" ), - eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the new development version for \"" + project.getName() + + "\"?" ), eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); List reactorProjects = Collections.singletonList( project ); @@ -494,11 +511,12 @@ public void testAdjustVersionInteractive() // verify assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); - + verify( mockPrompter, times( 2 ) ).prompt( startsWith( "What is the new development version for \"" - + project.getName() + "\"?" ), eq( "1.1-SNAPSHOT" ) ); + + project.getName() + "\"?" ), eq( "1.1-SNAPSHOT" ) ); } + @Test public void testAdjustVersionNonInteractive() throws Exception { @@ -534,7 +552,8 @@ public void testAdjustVersionNonInteractive() assertEquals( "check cause", VersionParseException.class, e.getCause().getClass() ); } } - + + @Test public void testExecuteSnapshotBranchCreation_DefaultDevelopmentVersion_MapDevelopment() throws Exception { @@ -552,9 +571,11 @@ public void testExecuteSnapshotBranchCreation_DefaultDevelopmentVersion_MapDevel // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotBranchCreation_DefaultDevelopmentVersion_MapDevelopment() throws Exception { @@ -572,9 +593,11 @@ public void testSimulateSnapshotBranchCreation_DefaultDevelopmentVersion_MapDeve // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), + releaseDescriptor.getDevelopmentVersions() ); } - + + @Test public void testExecuteSnapshotBranchCreation_DefaultDevelopmentVersion_NonInteractive_MapDevelopment() throws Exception { @@ -597,6 +620,7 @@ public void testExecuteSnapshotBranchCreation_DefaultDevelopmentVersion_NonInter releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotBranchCreation_DefaultDevelopmentVersion_NonInteractive_MapDevelopment() throws Exception { @@ -618,7 +642,8 @@ public void testSimulateSnapshotBranchCreation_DefaultDevelopmentVersion_NonInte assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); } - + + @Test public void testExecuteSnapshotBranchCreation_NonInteractive_MapDevelopment() throws Exception { @@ -640,6 +665,7 @@ public void testExecuteSnapshotBranchCreation_NonInteractive_MapDevelopment() releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotBranchCreation_NonInteractive_MapDevelopment() throws Exception { @@ -661,7 +687,7 @@ public void testSimulateSnapshotBranchCreation_NonInteractive_MapDevelopment() releaseDescriptor.getDevelopmentVersions() ); } - + @Test public void testExecuteSnapshotDefaultDevelopmentVersion_MapDevelopment() throws Exception { @@ -678,9 +704,11 @@ public void testExecuteSnapshotDefaultDevelopmentVersion_MapDevelopment() // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotDefaultDevelopmentVersion_MapDevelopment() throws Exception { @@ -697,9 +725,11 @@ public void testSimulateSnapshotDefaultDevelopmentVersion_MapDevelopment() // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), + releaseDescriptor.getDevelopmentVersions() ); } - + + @Test public void testExecuteSnapshotDefaultDevelopmentVersion_NonInteractive_MapDevelopment() throws Exception { @@ -721,6 +751,7 @@ public void testExecuteSnapshotDefaultDevelopmentVersion_NonInteractive_MapDevel releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotDefaultDevelopmentVersion_NonInteractive_MapDevelopment() throws Exception { @@ -741,7 +772,8 @@ public void testSimulateSnapshotDefaultDevelopmentVersion_NonInteractive_MapDeve assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.1.1-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); } - + + @Test public void testExecuteSnapshotNonInteractive_MapDevelopment() throws Exception { @@ -762,6 +794,7 @@ public void testExecuteSnapshotNonInteractive_MapDevelopment() releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotNonInteractive_MapDevelopment() throws Exception { @@ -782,6 +815,7 @@ public void testSimulateSnapshotNonInteractive_MapDevelopment() releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testExecuteSnapshotAutoVersionSubmodules_NotInteractive_MapDevelopment() throws Exception { @@ -803,6 +837,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_NotInteractive_MapDevelopme assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotAutoVersionSubmodules_NotInteractive_MapDevelopment() throws Exception { @@ -824,6 +859,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_NotInteractive_MapDevelopm assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteReleaseAutoVersionSubmodules_NotInteractive_MapDevelopment() throws Exception { @@ -845,6 +881,7 @@ public void testExecuteReleaseAutoVersionSubmodules_NotInteractive_MapDevelopmen assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseAutoVersionSubmodules_NotInteractive_MapDevelopment() throws Exception { @@ -866,6 +903,7 @@ public void testSimulateReleaseAutoVersionSubmodules_NotInteractive_MapDevelopme assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { @@ -884,9 +922,11 @@ public void testExecuteSnapshotAutoVersionSubmodules_NotInteractive_MapRelease() // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { @@ -905,9 +945,11 @@ public void testSimulateSnapshotAutoVersionSubmodules_NotInteractive_MapRelease( // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteReleaseAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { @@ -926,9 +968,11 @@ public void testExecuteReleaseAutoVersionSubmodules_NotInteractive_MapRelease() // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { @@ -947,9 +991,11 @@ public void testSimulateReleaseAutoVersionSubmodules_NotInteractive_MapRelease() // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotAutoVersionSubmodules_BranchCreation_NotInteractive_MapDevelopment() throws Exception { @@ -972,6 +1018,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_BranchCreation_NotInteracti assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotAutoVersionSubmodules_BranchCreation_NotInteractive_MapDevelopment() throws Exception { @@ -994,6 +1041,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_BranchCreation_NotInteract assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteReleaseAutoVersionSubmodules_BranchCreation_NotInteractive_MapDevelopment() throws Exception { @@ -1016,6 +1064,7 @@ public void testExecuteReleaseAutoVersionSubmodules_BranchCreation_NotInteractiv assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseAutoVersionSubmodules_BranchCreation_NotInteractive_MapDevelopment() throws Exception { @@ -1038,6 +1087,7 @@ public void testSimulateReleaseAutoVersionSubmodules_BranchCreation_NotInteracti assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotAutoVersionSubmodules_BranchCreation_NotInteractive_MapBranch() throws Exception { @@ -1057,9 +1107,11 @@ public void testExecuteSnapshotAutoVersionSubmodules_BranchCreation_NotInteracti // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotAutoVersionSubmodules_BranchCreation_NotInteractive_MapBranch() throws Exception { @@ -1079,9 +1131,11 @@ public void testSimulateSnapshotAutoVersionSubmodules_BranchCreation_NotInteract // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteReleaseAutoVersionSubmodules_BranchCreation_NotInteractive_MapBranch() throws Exception { @@ -1106,9 +1160,11 @@ public void testExecuteReleaseAutoVersionSubmodules_BranchCreation_NotInteractiv */ assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseAutoVersionSubmodules_BranchCreation_NotInteractive_MapBranch() throws Exception { @@ -1133,9 +1189,11 @@ public void testSimulateReleaseAutoVersionSubmodules_BranchCreation_NotInteracti */ assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_NonInteractive_UpdateBranchVersions_MapBranch() throws Exception { @@ -1158,9 +1216,11 @@ public void testExecuteSnapshotBranchCreation_NonInteractive_UpdateBranchVersion // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.3-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotBranchCreation_NonInteractive_UpdateBranchVersions_MapBranch() throws Exception { @@ -1183,9 +1243,11 @@ public void testSimulateSnapshotBranchCreation_NonInteractive_UpdateBranchVersio // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.3-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_DefaultReleaseVersion_NonInteractive_UpdateBranchVersions_MapBranch() throws Exception { @@ -1206,9 +1268,11 @@ public void testExecuteSnapshotBranchCreation_DefaultReleaseVersion_NonInteracti // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "2.1-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotBranchCreation_DefaultReleaseVersion_NonInteractive_UpdateBranchVersions_MapBranch() throws Exception { @@ -1229,9 +1293,11 @@ public void testSimulateSnapshotBranchCreation_DefaultReleaseVersion_NonInteract // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "2.1-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_DefaultReleaseVersion_UpdateBranchVersions_MapBranch() throws Exception { @@ -1251,9 +1317,11 @@ public void testExecuteSnapshotBranchCreation_DefaultReleaseVersion_UpdateBranch // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "2.1-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotBranchCreation_DefaultReleaseVersion_UpdateBranchVersions_MapBranch() throws Exception { @@ -1273,9 +1341,11 @@ public void testSimulateSnapshotBranchCreation_DefaultReleaseVersion_UpdateBranc // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "2.1-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { @@ -1288,21 +1358,23 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_MapBranch() releaseDescriptor.setBranchCreation( true ); releaseDescriptor.setUpdateBranchVersions( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); // verify - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT verify( mockPrompter ).prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ); } + @Test public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { @@ -1315,21 +1387,23 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_MapBranch() releaseDescriptor.setBranchCreation( true ); releaseDescriptor.setUpdateBranchVersions( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); // verify - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT verify( mockPrompter ).prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ); } - + + @Test public void testExecuteReleaseBranchCreation_UpdateBranchVersions_UpdateVersionsToSnapshot_MapBranch() throws Exception { @@ -1343,10 +1417,11 @@ public void testExecuteReleaseBranchCreation_UpdateBranchVersions_UpdateVersions releaseDescriptor.setUpdateBranchVersions( true ); releaseDescriptor.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version + // updateBranchVersions is set to true, so suggest the next snapshot version // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT (yes, one step back!) // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test @@ -1358,9 +1433,11 @@ public void testExecuteReleaseBranchCreation_UpdateBranchVersions_UpdateVersions verify( mockPrompter ).prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ); assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "2.1-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseBranchCreation_UpdateBranchVersions_UpdateVersionsToSnapshot_MapBranch() throws Exception { @@ -1374,10 +1451,11 @@ public void testSimulateReleaseBranchCreation_UpdateBranchVersions_UpdateVersion releaseDescriptor.setUpdateBranchVersions( true ); releaseDescriptor.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version + // updateBranchVersions is set to true, so suggest the next snapshot version // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT (yes, one step back!) // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test @@ -1389,9 +1467,11 @@ public void testSimulateReleaseBranchCreation_UpdateBranchVersions_UpdateVersion verify( mockPrompter ).prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ); assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "2.1-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_UpdateVersionsToSnapshot_MapBranch() throws Exception { @@ -1405,10 +1485,11 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_UpdateVersion releaseDescriptor.setUpdateBranchVersions( true ); releaseDescriptor.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version + // updateBranchVersions is set to true, so suggest the next snapshot version // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test @@ -1420,6 +1501,7 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_UpdateVersion verify( mockPrompter ).prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ); } + @Test public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_UpdateVersionsToSnapshot_MapBranch() throws Exception { @@ -1433,10 +1515,11 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_UpdateVersio releaseDescriptor.setUpdateBranchVersions( true ); releaseDescriptor.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version + // updateBranchVersions is set to true, so suggest the next snapshot version // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test @@ -1447,7 +1530,8 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_UpdateVersio // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT verify( mockPrompter ).prompt( startsWith( "What is the branch version for" ), eq( "1.3-SNAPSHOT" ) ); } - + + @Test public void testExecuteReleaseBranchCreation_MapBranch() throws Exception { @@ -1470,9 +1554,11 @@ public void testExecuteReleaseBranchCreation_MapBranch() */ assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseBranchCreation_MapBranch() throws Exception { @@ -1495,9 +1581,11 @@ public void testSimulateReleaseBranchCreation_MapBranch() */ assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } - + + @Test public void testExecuteReleaseBranchCreation_NonUpdateWorkingCopyVersions_MapDevelopment() throws Exception { @@ -1515,9 +1603,11 @@ public void testExecuteReleaseBranchCreation_NonUpdateWorkingCopyVersions_MapDev // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateReleaseBranchCreation_NonUpdateWorkingCopyVersions_MapDevelopment() throws Exception { @@ -1535,9 +1625,11 @@ public void testSimulateReleaseBranchCreation_NonUpdateWorkingCopyVersions_MapDe // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testExecuteReleaseBranchCreation_MapDevelopment() throws Exception { @@ -1553,12 +1645,13 @@ public void testExecuteReleaseBranchCreation_MapDevelopment() releaseDescriptor.setInteractive( false ); phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); - // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateReleaseBranchCreation_MapDevelopment() throws Exception { @@ -1578,9 +1671,11 @@ public void testSimulateReleaseBranchCreation_MapDevelopment() // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testExecuteSnapshotBranchCreation_MapBranch() throws Exception { @@ -1598,9 +1693,11 @@ public void testExecuteSnapshotBranchCreation_MapBranch() // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotBranchCreation_MapBranch() throws Exception { @@ -1618,9 +1715,11 @@ public void testSimulateSnapshotBranchCreation_MapBranch() // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_NonUpdateWorkingCopyVersions_MapDevelopment() throws Exception { @@ -1638,9 +1737,11 @@ public void testExecuteSnapshotBranchCreation_NonUpdateWorkingCopyVersions_MapDe // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testSimulateSnapshotBranchCreation_NonUpdateWorkingCopyVersions_MapDevelopment() throws Exception { @@ -1658,9 +1759,11 @@ public void testSimulateSnapshotBranchCreation_NonUpdateWorkingCopyVersions_MapD // verify assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); + assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "1.2-SNAPSHOT" ), + releaseDescriptor.getDevelopmentVersions() ); } + @Test public void testExecuteReleaseBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { @@ -1675,16 +1778,18 @@ public void testExecuteReleaseBranchCreation_UpdateBranchVersions_MapBranch() // org.apache.maven.release:maven-release-manager:(,2.4) > true // org.apache.maven.release:maven-release-manager:[2.4,) > false releaseDescriptor.setInteractive( false ); - + // test phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateReleaseBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { @@ -1699,16 +1804,18 @@ public void testSimulateReleaseBranchCreation_UpdateBranchVersions_MapBranch() // org.apache.maven.release:maven-release-manager:(,2.4) > true // org.apache.maven.release:maven-release-manager:[2.4,) > false releaseDescriptor.setInteractive( false ); - + // test phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); // verify assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "1.2" ), releaseDescriptor.getReleaseVersions() ); - assertNull( "Check development versions", releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); + assertNull( "Check development versions", + releaseDescriptor.getDevelopmentVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDevelopment() throws Exception { @@ -1721,7 +1828,8 @@ public void testExecuteSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDevel releaseDescriptor.setBranchCreation( true ); releaseDescriptor.setUpdateWorkingCopyVersions( true ); - when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test @@ -1731,6 +1839,7 @@ public void testExecuteSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDevel verify( mockPrompter ).prompt( startsWith( "What is the new working copy version for" ), eq( "1.3-SNAPSHOT" ) ); } + @Test public void testSimulateSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDevelopment() throws Exception { @@ -1743,7 +1852,8 @@ public void testSimulateSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDeve releaseDescriptor.setBranchCreation( true ); releaseDescriptor.setUpdateWorkingCopyVersions( true ); - when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test @@ -1753,6 +1863,7 @@ public void testSimulateSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDeve verify( mockPrompter ).prompt( startsWith( "What is the new working copy version for" ), eq( "1.3-SNAPSHOT" ) ); } + @Test public void testExecuteMultiModuleAutoVersionSubmodules__MapDevelopment() throws Exception { @@ -1778,6 +1889,7 @@ public void testExecuteMultiModuleAutoVersionSubmodules__MapDevelopment() assertEquals( "Check release versions", 0, releaseDescriptor.getReleaseVersions().size() ); } + @Test public void testSimulateMultiModuleAutoVersionSubmodules__MapDevelopment() throws Exception { @@ -1803,6 +1915,7 @@ public void testSimulateMultiModuleAutoVersionSubmodules__MapDevelopment() assertEquals( "Check release versions", 0, releaseDescriptor.getReleaseVersions().size() ); } + @Test public void testExecuteSnapshotAutoVersionSubmodules_DefaultReleaseVersion_NonInteractive_MapDevelopment() throws Exception { @@ -1826,6 +1939,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_DefaultReleaseVersion_NonIn assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotAutoVersionSubmodules_DefaultReleaseVersion_NonInteractive_MapDevelopment() throws Exception { @@ -1849,6 +1963,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_DefaultReleaseVersion_NonI assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testExecuteSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_NonInteractive_MapDevelopment() throws Exception { @@ -1872,6 +1987,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_N assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } + @Test public void testSimulateSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_NonInteractive_MapDevelopment() throws Exception { @@ -1894,33 +2010,39 @@ public void testSimulateSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_ releaseDescriptor.getDevelopmentVersions() ); assertNull( "Check release versions", releaseDescriptor.getReleaseVersions().get( "groupId:artifactId" ) ); } - + // MRELEASE-511 - public void testUnusualVersions1() throws Exception + @Test + public void testUnusualVersions1() + throws Exception { MapVersionsPhase mapReleasephase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_RELEASE_VERSIONS ); - MapVersionsPhase mapDevelopmentphase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); - + MapVersionsPhase mapDevelopmentphase = + (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); + List reactorProjects = Collections.singletonList( createProject( "artifactId", "MYB_200909-SNAPSHOT" ) ); - + ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor(); releaseDescriptor.setDefaultReleaseVersion( "PPX" ); releaseDescriptor.setDefaultDevelopmentVersion( "MYB_200909-SNAPSHOT" ); - + // test mapReleasephase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); mapDevelopmentphase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); - + // verify - assertEquals( "Check development versions", Collections.singletonMap( "groupId:artifactId", "MYB_200909-SNAPSHOT" ), + assertEquals( "Check development versions", + Collections.singletonMap( "groupId:artifactId", "MYB_200909-SNAPSHOT" ), releaseDescriptor.getDevelopmentVersions() ); - assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "PPX" ), + assertEquals( "Check release versions", Collections.singletonMap( "groupId:artifactId", "PPX" ), releaseDescriptor.getReleaseVersions() ); } // MRELEASE-269 - public void testContinuousSnapshotCheck() throws Exception + @Test + public void testContinuousSnapshotCheck() + throws Exception { // prepare MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); @@ -1929,20 +2051,23 @@ public void testContinuousSnapshotCheck() throws Exception ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor(); - when( mockPrompter.prompt( startsWith( "What is the new development version for " ), eq( "1.12-SNAPSHOT" ) ) ) - .thenReturn( "2.0" ) // wrong, expected SNAPSHOT - .thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the new development version for " ), + eq( "1.12-SNAPSHOT" ) ) ).thenReturn( "2.0" ) // wrong, expected SNAPSHOT + .thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); // verify - verify( mockPrompter, times( 2 ) ).prompt( startsWith( "What is the new development version for " ), eq( "1.12-SNAPSHOT" ) ); + verify( mockPrompter, times( 2 ) ).prompt( startsWith( "What is the new development version for " ), + eq( "1.12-SNAPSHOT" ) ); } - - //MRELEASE-734 - public void testEmptyDefaultDevelopmentVersion() throws Exception + + // MRELEASE-734 + @Test + public void testEmptyDefaultDevelopmentVersion() + throws Exception { // prepare MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_DEVELOPMENT_VERSIONS ); @@ -1952,18 +2077,21 @@ public void testEmptyDefaultDevelopmentVersion() throws Exception ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor(); releaseDescriptor.setDefaultDevelopmentVersion( "" ); - when( mockPrompter.prompt( startsWith( "What is the new development version for " ), eq( "1.12-SNAPSHOT" ) ) ) - .thenReturn( "2.0-SNAPSHOT" ); + when( mockPrompter.prompt( startsWith( "What is the new development version for " ), + eq( "1.12-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); phase.setPrompter( mockPrompter ); // test phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects ); // verify - verify( mockPrompter ).prompt( startsWith( "What is the new development version for " ), eq( "1.12-SNAPSHOT" ) ); + verify( mockPrompter ).prompt( startsWith( "What is the new development version for " ), + eq( "1.12-SNAPSHOT" ) ); } - - public void testEmptyDefaultReleaseVersion() throws Exception + + @Test + public void testEmptyDefaultReleaseVersion() + throws Exception { // prepare MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, TEST_MAP_RELEASE_VERSIONS ); @@ -1973,8 +2101,8 @@ public void testEmptyDefaultReleaseVersion() throws Exception ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor(); releaseDescriptor.setDefaultReleaseVersion( "" ); - when( mockPrompter.prompt( startsWith( "What is the release version for " ), eq( "1.11" ) ) ) - .thenReturn( "2.0" ); + when( mockPrompter.prompt( startsWith( "What is the release version for " ), + eq( "1.11" ) ) ).thenReturn( "2.0" ); phase.setPrompter( mockPrompter ); // test @@ -1984,7 +2112,6 @@ public void testEmptyDefaultReleaseVersion() throws Exception verify( mockPrompter ).prompt( startsWith( "What is the release version for " ), eq( "1.11" ) ); } - private static MavenProject createProject( String artifactId, String version ) { Model model = new Model(); @@ -1993,5 +2120,4 @@ private static MavenProject createProject( String artifactId, String version ) model.setVersion( version ); return new MavenProject( model ); } - } \ No newline at end of file diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.java index 9c35a2d9b..7d31d4bb5 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.java @@ -19,6 +19,8 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Matchers.isNull; @@ -32,6 +34,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; import org.apache.maven.shared.release.ReleaseResult; @@ -40,7 +43,7 @@ import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.exec.MavenExecutor; import org.apache.maven.shared.release.exec.MavenExecutorException; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; /** * Test the simple test running phase. @@ -48,11 +51,11 @@ * @author Brett Porter */ public class RunCompleteGoalsPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private RunCompleteGoalsPhase phase; - protected void setUp() + public void setUp() throws Exception { super.setUp(); @@ -60,6 +63,7 @@ protected void setUp() phase = (RunCompleteGoalsPhase) lookup( ReleasePhase.ROLE, "run-completion-goals" ); } + @Test public void testExecute() throws ReleaseExecutionException, ReleaseFailureException, MavenExecutorException { @@ -72,22 +76,19 @@ public void testExecute() MavenExecutor mock = mock( MavenExecutor.class ); - phase.setMavenExecutor(ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); + phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); // execute phase.execute( config, (Settings) null, (List) null ); // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } + @Test public void testSimulate() throws ReleaseExecutionException, MavenExecutorException { @@ -106,15 +107,13 @@ public void testSimulate() phase.simulate( config, new DefaultReleaseEnvironment(), null ); // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), isA( ReleaseResult.class ) ); + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), + isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } + @Test public void testExecuteException() throws ReleaseFailureException, MavenExecutorException { @@ -126,15 +125,16 @@ public void testExecuteException() config.setWorkingDirectory( testFile.getAbsolutePath() ); MavenExecutor mock = mock( MavenExecutor.class ); - doThrow( new MavenExecutorException( "...", new Exception() ) ).when( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), - isA( ReleaseResult.class ) ); + doThrow( new MavenExecutorException( "...", + new Exception() ) ).when( mock ).executeGoals( eq( testFile ), + eq( "clean integration-test" ), + isA( ReleaseEnvironment.class ), + eq( true ), + isNull( String.class ), + isNull( String.class ), + isA( ReleaseResult.class ) ); - phase.setMavenExecutor(ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); + phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); // execute try @@ -147,19 +147,17 @@ public void testExecuteException() { assertEquals( "Check cause", MavenExecutorException.class, e.getCause().getClass() ); } - + // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } - public void testSimulateException() throws MavenExecutorException + @Test + public void testSimulateException() + throws MavenExecutorException { // prepare File testFile = getTestFile( "target/working-directory" ); @@ -169,14 +167,14 @@ public void testSimulateException() throws MavenExecutorException config.setWorkingDirectory( testFile.getAbsolutePath() ); MavenExecutor mock = mock( MavenExecutor.class ); - doThrow( new MavenExecutorException( "...", new Exception() ) ).when( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), - isA( ReleaseResult.class ) ); - + doThrow( new MavenExecutorException( "...", + new Exception() ) ).when( mock ).executeGoals( eq( testFile ), + eq( "clean integration-test" ), + isA( ReleaseEnvironment.class ), + eq( true ), + isNull( String.class ), + isNull( String.class ), + isA( ReleaseResult.class ) ); phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); @@ -191,18 +189,15 @@ public void testSimulateException() throws MavenExecutorException { assertEquals( "Check cause", MavenExecutorException.class, e.getCause().getClass() ); } - + // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } + @Test public void testEmptyGoals() throws Exception { @@ -215,7 +210,7 @@ public void testEmptyGoals() MavenExecutor mock = mock( MavenExecutor.class ); - phase.setMavenExecutor(ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); + phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); // execute phase.execute( config, (Settings) null, (List) null ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.java index 00b643a14..ec305078f 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.java @@ -19,6 +19,8 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Matchers.isNull; @@ -32,24 +34,25 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.exec.MavenExecutor; import org.apache.maven.shared.release.exec.MavenExecutorException; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; /** * @author Emmanuel Venisse * @version $Id$ */ public class RunPerformGoalsPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private RunPerformGoalsPhase phase; - protected void setUp() + public void setUp() throws Exception { super.setUp(); @@ -57,6 +60,7 @@ protected void setUp() phase = (RunPerformGoalsPhase) lookup( ReleasePhase.ROLE, "run-perform-goals" ); } + @Test public void testExecuteException() throws Exception { @@ -102,6 +106,7 @@ public void testExecuteException() verifyNoMoreInteractions( mock ); } + @Test public void testCustomPomFile() throws Exception { //prepare diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.java index a2420acf9..e45e4a678 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.java @@ -19,6 +19,8 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Matchers.isNull; @@ -32,6 +34,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; import org.apache.maven.shared.release.ReleaseResult; @@ -40,7 +43,7 @@ import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.exec.MavenExecutor; import org.apache.maven.shared.release.exec.MavenExecutorException; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; /** * Test the simple test running phase. @@ -48,11 +51,11 @@ * @author Brett Porter */ public class RunPrepareGoalsPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private RunPrepareGoalsPhase phase; - protected void setUp() + public void setUp() throws Exception { super.setUp(); @@ -60,6 +63,7 @@ protected void setUp() phase = (RunPrepareGoalsPhase) lookup( ReleasePhase.ROLE, "run-preparation-goals" ); } + @Test public void testExecute() throws ReleaseExecutionException, ReleaseFailureException, MavenExecutorException { @@ -72,22 +76,19 @@ public void testExecute() MavenExecutor mock = mock( MavenExecutor.class ); - phase.setMavenExecutor(ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); + phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); // execute phase.execute( config, (Settings) null, (List) null ); // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class), - eq( true), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } + @Test public void testSimulate() throws ReleaseExecutionException, MavenExecutorException { @@ -100,22 +101,19 @@ public void testSimulate() MavenExecutor mock = mock( MavenExecutor.class ); - phase.setMavenExecutor(ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, (MavenExecutor) mock ); + phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, (MavenExecutor) mock ); // execute phase.simulate( config, new DefaultReleaseEnvironment(), null ); // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class), - eq( true), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } + @Test public void testExecuteException() throws ReleaseFailureException, MavenExecutorException { @@ -127,13 +125,14 @@ public void testExecuteException() config.setWorkingDirectory( testFile.getAbsolutePath() ); MavenExecutor mock = mock( MavenExecutor.class ); - doThrow( new MavenExecutorException( "...", new Exception() ) ).when( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), - isA( ReleaseResult.class ) ); + doThrow( new MavenExecutorException( "...", + new Exception() ) ).when( mock ).executeGoals( eq( testFile ), + eq( "clean integration-test" ), + isA( ReleaseEnvironment.class ), + eq( true ), + isNull( String.class ), + isNull( String.class ), + isA( ReleaseResult.class ) ); phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); @@ -148,19 +147,17 @@ public void testExecuteException() { assertEquals( "Check cause", MavenExecutorException.class, e.getCause().getClass() ); } - + // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); } - public void testSimulateException() throws MavenExecutorException + @Test + public void testSimulateException() + throws MavenExecutorException { // prepare File testFile = getTestFile( "target/working-directory" ); @@ -170,13 +167,14 @@ public void testSimulateException() throws MavenExecutorException config.setWorkingDirectory( testFile.getAbsolutePath() ); MavenExecutor mock = mock( MavenExecutor.class ); - doThrow( new MavenExecutorException( "...", new Exception() ) ).when( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), - isA( ReleaseResult.class ) ); + doThrow( new MavenExecutorException( "...", + new Exception() ) ).when( mock ).executeGoals( eq( testFile ), + eq( "clean integration-test" ), + isA( ReleaseEnvironment.class ), + eq( true ), + isNull( String.class ), + isNull( String.class ), + isA( ReleaseResult.class ) ); phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); @@ -191,19 +189,16 @@ public void testSimulateException() throws MavenExecutorException { assertEquals( "Check cause", MavenExecutorException.class, e.getCause().getClass() ); } - + // verify - verify( mock ).executeGoals( eq( testFile ), - eq( "clean integration-test" ), - isA( ReleaseEnvironment.class ), - eq( true ), - isNull( String.class ), - isNull( String.class ), + verify( mock ).executeGoals( eq( testFile ), eq( "clean integration-test" ), isA( ReleaseEnvironment.class ), + eq( true ), isNull( String.class ), isNull( String.class ), isA( ReleaseResult.class ) ); verifyNoMoreInteractions( mock ); - + } + @Test public void testEmptyGoals() throws Exception { @@ -216,7 +211,7 @@ public void testEmptyGoals() MavenExecutor mock = mock( MavenExecutor.class ); - phase.setMavenExecutor(ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); + phase.setMavenExecutor( ReleaseEnvironment.DEFAULT_MAVEN_EXECUTOR_ID, mock ); // execute phase.execute( config, (Settings) null, (List) null ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.java index 744a5e3af..e7b8ec38c 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.java @@ -19,6 +19,10 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.mock; @@ -45,6 +49,7 @@ import org.apache.maven.scm.provider.ScmProviderStub; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.repository.ScmRepositoryException; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; import org.apache.maven.shared.release.ReleaseResult; @@ -53,7 +58,7 @@ import org.apache.maven.shared.release.scm.DefaultScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ReleaseScmCommandException; import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; import org.mockito.internal.util.reflection.Whitebox; /** @@ -62,11 +67,11 @@ * @author Brett Porter */ public class ScmCheckModificationsPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private ReleasePhase phase; - protected void setUp() + public void setUp() throws Exception { super.setUp(); @@ -74,6 +79,7 @@ protected void setUp() phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "scm-check-modifications" ); } + @Test public void testNoSuchScmProviderExceptionThrown() throws Exception { @@ -111,12 +117,13 @@ public void testNoSuchScmProviderExceptionThrown() { assertEquals( "check cause", NoSuchScmProviderException.class, e.getCause().getClass() ); } - + // verify verify( scmManagerMock, times( 2 ) ).makeScmRepository( eq( "scm-url" ) ); verifyNoMoreInteractions( scmManagerMock ); } + @Test public void testScmRepositoryExceptionThrown() throws Exception { @@ -154,12 +161,13 @@ public void testScmRepositoryExceptionThrown() { assertNull( "Check no additional cause", e.getCause() ); } - + // verify verify( scmManagerMock, times( 2 ) ).makeScmRepository( eq( "scm-url" ) ); verifyNoMoreInteractions( scmManagerMock ); } + @Test public void testScmExceptionThrown() throws Exception { @@ -169,7 +177,8 @@ public void testScmExceptionThrown() releaseDescriptor.setWorkingDirectory( getTestFile( "target/test/checkout" ).getAbsolutePath() ); ScmProvider scmProviderMock = mock( ScmProvider.class ); - when( scmProviderMock.status( isA( ScmRepository.class ), isA( ScmFileSet.class ) ) ).thenThrow( new ScmException( "..." ) ); + when( scmProviderMock.status( isA( ScmRepository.class ), + isA( ScmFileSet.class ) ) ).thenThrow( new ScmException( "..." ) ); ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE ); stub.setScmProvider( scmProviderMock ); @@ -196,12 +205,13 @@ public void testScmExceptionThrown() { assertEquals( "check cause", ScmException.class, e.getCause().getClass() ); } - + // verify verify( scmProviderMock, times( 2 ) ).status( isA( ScmRepository.class ), isA( ScmFileSet.class ) ); verifyNoMoreInteractions( scmProviderMock ); } + @Test public void testScmResultFailure() throws Exception { @@ -236,6 +246,7 @@ public void testScmResultFailure() } } + @Test public void testNoModifications() throws Exception { @@ -251,13 +262,14 @@ public void testNoModifications() assertTrue( true ); } + @Test public void testModificationsToExcludedFilesOnly() throws Exception { ReleaseDescriptor releaseDescriptor = createReleaseDescriptor(); - setChangedFiles( releaseDescriptor, Arrays.asList( "release.properties", "pom.xml.backup", - "pom.xml.tag", "pom.xml.next" ) ); + setChangedFiles( releaseDescriptor, + Arrays.asList( "release.properties", "pom.xml.backup", "pom.xml.tag", "pom.xml.next" ) ); phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ); @@ -266,23 +278,28 @@ public void testModificationsToExcludedFilesOnly() // successful execution is verification enough assertTrue( true ); } - + // MRELEASE-645: Allow File/Directory Patterns for the checkModificationExcludes Option + @Test public void testModificationsToCustomExcludedFilesOnly() throws Exception { ReleaseDescriptor releaseDescriptor = createReleaseDescriptor(); - + releaseDescriptor.setCheckModificationExcludes( Collections.singletonList( "**/keep.me" ) ); - - setChangedFiles( releaseDescriptor, Arrays.asList( "release.properties", "pom.xml.backup", - "pom.xml.tag", "pom.xml.next", "keep.me", "src/app/keep.me", "config\\keep.me" ) ); - - assertEquals( ReleaseResult.SUCCESS, phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); - - assertEquals( ReleaseResult.SUCCESS, phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); + + setChangedFiles( releaseDescriptor, + Arrays.asList( "release.properties", "pom.xml.backup", "pom.xml.tag", "pom.xml.next", + "keep.me", "src/app/keep.me", "config\\keep.me" ) ); + + assertEquals( ReleaseResult.SUCCESS, + phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); + + assertEquals( ReleaseResult.SUCCESS, + phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); } + @Test public void testModificationsToPoms() throws Exception { @@ -313,6 +330,7 @@ public void testModificationsToPoms() } } + @Test public void testModificationsToIncludedFilesOnly() throws Exception { @@ -343,13 +361,14 @@ public void testModificationsToIncludedFilesOnly() } } + @Test public void testModificationsToIncludedAndExcludedFiles() throws Exception { ReleaseDescriptor releaseDescriptor = createReleaseDescriptor(); - setChangedFiles( releaseDescriptor, Arrays.asList( "release.properties", "pom.xml.backup", - "pom.xml.tag", "pom.xml.release", "something.txt" ) ); + setChangedFiles( releaseDescriptor, Arrays.asList( "release.properties", "pom.xml.backup", "pom.xml.tag", + "pom.xml.release", "something.txt" ) ); try { @@ -373,7 +392,8 @@ public void testModificationsToIncludedAndExcludedFiles() assertTrue( true ); } } - + + @Test public void testModificationsToAdditionalExcludedFiles() throws Exception { @@ -382,23 +402,29 @@ public void testModificationsToAdditionalExcludedFiles() setChangedFiles( releaseDescriptor, Collections.singletonList( "something.txt" ) ); - assertEquals( ReleaseResult.SUCCESS, phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); - - assertEquals( ReleaseResult.SUCCESS, phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); + assertEquals( ReleaseResult.SUCCESS, + phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); + + assertEquals( ReleaseResult.SUCCESS, + phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); } // MRELEASE-775 - public void testMultipleExclusionPatternMatch() throws Exception + @Test + public void testMultipleExclusionPatternMatch() + throws Exception { ReleaseDescriptor releaseDescriptor = createReleaseDescriptor(); - + releaseDescriptor.setCheckModificationExcludes( Collections.singletonList( "release.properties" ) ); - + setChangedFiles( releaseDescriptor, Arrays.asList( "release.properties" ) ); - - assertEquals( ReleaseResult.SUCCESS, phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); - - assertEquals( ReleaseResult.SUCCESS, phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); + + assertEquals( ReleaseResult.SUCCESS, + phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); + + assertEquals( ReleaseResult.SUCCESS, + phase.simulate( releaseDescriptor, new DefaultReleaseEnvironment(), null ).getResultCode() ); } private void setChangedFiles( ReleaseDescriptor releaseDescriptor, List changedFiles )