maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r399143 - in /maven/plugins/trunk/maven-release-plugin/src/test: java/org/apache/maven/plugins/release/phase/ resources/org/apache/maven/plugins/release/phase/
Date Wed, 03 May 2006 05:20:49 GMT
Author: brett
Date: Tue May  2 22:20:45 2006
New Revision: 399143

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

Added:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.java
  (with props)
    maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.xml
  (with props)
Modified:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/AbstractRewritingReleasePhaseTestCase.java
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/CheckPomPhaseTest.java
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForDevelopmentPhaseTest.java
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/AbstractRewritingReleasePhaseTestCase.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/AbstractRewritingReleasePhaseTestCase.java?rev=399143&r1=399142&r2=399143&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/AbstractRewritingReleasePhaseTestCase.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/AbstractRewritingReleasePhaseTestCase.java
Tue May  2 22:20:45 2006
@@ -41,6 +41,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * Base class with tests for rewriting POMs.
@@ -75,6 +78,11 @@
         throws Exception
     {
         ReleaseConfiguration config = createConfigurationFromProjects( "pom-with-parent"
);
+
+        // Process the child first
+        List reactorProjects = new ArrayList( config.getReactorProjects() );
+        Collections.reverse( reactorProjects );
+        config.setReactorProjects( reactorProjects );
 
         mapAlternateNextVersion( config, "groupId:subproject1" );
 

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/CheckPomPhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/CheckPomPhaseTest.java?rev=399143&r1=399142&r2=399143&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/CheckPomPhaseTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/CheckPomPhaseTest.java
Tue May  2 22:20:45 2006
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Scm;
 import org.apache.maven.plugins.release.ReleaseFailureException;
 import org.apache.maven.plugins.release.config.ReleaseConfiguration;
 import org.apache.maven.project.MavenProject;
@@ -55,6 +56,68 @@
 
         // successful execution is verification enough
         assertTrue( true );
+    }
+
+    public void testGetUrlFromProjectConnection()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        MavenProject project = createProject( "1.0-SNAPSHOT" );
+        Scm scm = new Scm();
+        scm.setConnection( "conn-scm-url" );
+        project.setScm( scm );
+        releaseConfiguration.setReactorProjects( Collections.singletonList( project ) );
+
+        phase.execute( releaseConfiguration );
+
+        assertEquals( "Check URL", "conn-scm-url", releaseConfiguration.getUrl() );
+    }
+
+    public void testGetUrlFromProjectConnectionSimulate()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        MavenProject project = createProject( "1.0-SNAPSHOT" );
+        Scm scm = new Scm();
+        scm.setConnection( "conn-scm-url" );
+        project.setScm( scm );
+        releaseConfiguration.setReactorProjects( Collections.singletonList( project ) );
+
+        phase.simulate( releaseConfiguration );
+
+        assertEquals( "Check URL", "conn-scm-url", releaseConfiguration.getUrl() );
+    }
+
+    public void testGetUrlFromProjectDevConnection()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        MavenProject project = createProject( "1.0-SNAPSHOT" );
+        Scm scm = new Scm();
+        scm.setConnection( "conn-scm-url" );
+        scm.setDeveloperConnection( "dev-conn-scm-url" );
+        project.setScm( scm );
+        releaseConfiguration.setReactorProjects( Collections.singletonList( project ) );
+
+        phase.execute( releaseConfiguration );
+
+        assertEquals( "Check URL", "dev-conn-scm-url", releaseConfiguration.getUrl() );
+    }
+
+    public void testGetUrlFromProjectDevConnectionSimulate()
+        throws Exception
+    {
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        MavenProject project = createProject( "1.0-SNAPSHOT" );
+        Scm scm = new Scm();
+        scm.setConnection( "conn-scm-url" );
+        scm.setDeveloperConnection( "dev-conn-scm-url" );
+        project.setScm( scm );
+        releaseConfiguration.setReactorProjects( Collections.singletonList( project ) );
+
+        phase.simulate( releaseConfiguration );
+
+        assertEquals( "Check URL", "dev-conn-scm-url", releaseConfiguration.getUrl() );
     }
 
     public void testMissingUrl()

Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.java?rev=399143&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.java
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.java
Tue May  2 22:20:45 2006
@@ -0,0 +1,57 @@
+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.ReleaseFailureException;
+import org.apache.maven.plugins.release.config.ReleaseConfiguration;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * Test the the end release phase. Nothing to see here really, but we want to make sure it
is configured.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class EndReleasePhaseTest
+    extends PlexusTestCase
+{
+    private ReleasePhase phase;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "end-release" );
+    }
+
+    public void testExecute()
+        throws ReleaseExecutionException, ReleaseFailureException
+    {
+        phase.execute( new ReleaseConfiguration() );
+
+        assertTrue( true );
+    }
+
+    public void testSimulate()
+        throws ReleaseExecutionException, ReleaseFailureException
+    {
+        phase.simulate( new ReleaseConfiguration() );
+
+        assertTrue( true );
+    }
+}

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

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

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForDevelopmentPhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForDevelopmentPhaseTest.java?rev=399143&r1=399142&r2=399143&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForDevelopmentPhaseTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForDevelopmentPhaseTest.java
Tue May  2 22:20:45 2006
@@ -17,9 +17,11 @@
  */
 
 import org.apache.maven.model.Scm;
+import org.apache.maven.plugins.release.ReleaseExecutionException;
 import org.apache.maven.plugins.release.config.ReleaseConfiguration;
 import org.codehaus.plexus.util.FileUtils;
 
+import java.io.File;
 import java.io.IOException;
 
 /**
@@ -46,6 +48,82 @@
         phase = (ReleasePhase) lookup( ReleasePhase.ROLE, "rewrite-poms-for-development"
);
     }
 
+    public void testSimulateRewrite()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromBasicPom();
+        config.mapReleaseVersion( "groupId:artifactId", RELEASE_VERSION );
+        config.mapDevelopmentVersion( "groupId:artifactId", NEXT_VERSION );
+
+        String expected = readTestProjectFile( "basic-pom/pom.xml" );
+
+        phase.simulate( config );
+
+        String actual = readTestProjectFile( "basic-pom/pom.xml" );
+        assertEquals( "Check the original POM untouched", expected, actual );
+
+        expected = readTestProjectFile( "basic-pom/expected-pom.xml" );
+        actual = readTestProjectFile( "basic-pom/pom.xml.next" );
+        assertEquals( "Check the transformed POM", expected, actual );
+    }
+
+    public void testClean()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromBasicPom();
+        config.mapReleaseVersion( "groupId:artifactId", RELEASE_VERSION );
+        config.mapDevelopmentVersion( "groupId:artifactId", NEXT_VERSION );
+
+        File testFile =
+            getTestFile( "target/test-classes/projects/rewrite-for-development/" + "basic-pom/pom.xml.next"
);
+        testFile.delete();
+        assertFalse( testFile.exists() );
+
+        phase.simulate( config );
+
+        assertTrue( testFile.exists() );
+
+        phase.clean( config );
+
+        assertFalse( testFile.exists() );
+    }
+
+    public void testCleanNotExists()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromBasicPom();
+        config.mapReleaseVersion( "groupId:artifactId", RELEASE_VERSION );
+        config.mapDevelopmentVersion( "groupId:artifactId", NEXT_VERSION );
+
+        File testFile =
+            getTestFile( "target/test-classes/projects/rewrite-for-development/" + "basic-pom/pom.xml.next"
);
+        testFile.delete();
+        assertFalse( testFile.exists() );
+
+        phase.clean( config );
+
+        assertFalse( testFile.exists() );
+    }
+
+    public void testRewriteBasicPomUnmappedScm()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromProjects( "basic-pom", true
);
+
+        mapNextVersion( config, "groupId:artifactId" );
+
+        try
+        {
+            phase.execute( config );
+
+            fail( "Expected failure" );
+        }
+        catch ( ReleaseExecutionException e )
+        {
+            assertTrue( true );
+        }
+    }
+
     protected String readTestProjectFile( String fileName )
         throws IOException
     {
@@ -80,25 +158,6 @@
         scm.setDeveloperConnection( "scm:svn:file://localhost/tmp/scm-repo/trunk" );
         scm.setUrl( "file://localhost/tmp/scm-repo/trunk" );
         config.mapOriginalScmInfo( "groupId:artifactId", scm );
-    }
-
-    public void testSimulateRewrite()
-        throws Exception
-    {
-        ReleaseConfiguration config = createConfigurationFromBasicPom();
-        config.mapReleaseVersion( "groupId:artifactId", RELEASE_VERSION );
-        config.mapDevelopmentVersion( "groupId:artifactId", NEXT_VERSION );
-
-        String expected = readTestProjectFile( "basic-pom/pom.xml" );
-
-        phase.simulate( config );
-
-        String actual = readTestProjectFile( "basic-pom/pom.xml" );
-        assertEquals( "Check the original POM untouched", expected, actual );
-
-        expected = readTestProjectFile( "basic-pom/expected-pom.xml" );
-        actual = readTestProjectFile( "basic-pom/pom.xml.next" );
-        assertEquals( "Check the transformed POM", expected, actual );
     }
 
     protected void mapAlternateNextVersion( ReleaseConfiguration config, String projectId
)

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java?rev=399143&r1=399142&r2=399143&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/RewritePomsForReleasePhaseTest.java
Tue May  2 22:20:45 2006
@@ -19,6 +19,7 @@
 import org.apache.maven.plugins.release.config.ReleaseConfiguration;
 import org.codehaus.plexus.util.FileUtils;
 
+import java.io.File;
 import java.io.IOException;
 
 /**
@@ -81,6 +82,42 @@
         expected = readTestProjectFile( "basic-pom/expected-pom.xml" );
         actual = readTestProjectFile( "basic-pom/pom.xml.tag" );
         assertEquals( "Check the transformed POM", expected, actual );
+    }
+
+    public void testClean()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromBasicPom();
+        config.mapReleaseVersion( "groupId:artifactId", NEXT_VERSION );
+
+        File testFile =
+            getTestFile( "target/test-classes/projects/rewrite-for-development/" + "basic-pom/pom.xml.tag"
);
+        testFile.delete();
+        assertFalse( testFile.exists() );
+
+        phase.simulate( config );
+
+        assertTrue( testFile.exists() );
+
+        phase.clean( config );
+
+        assertFalse( testFile.exists() );
+    }
+
+    public void testCleanNotExists()
+        throws Exception
+    {
+        ReleaseConfiguration config = createConfigurationFromBasicPom();
+        config.mapReleaseVersion( "groupId:artifactId", NEXT_VERSION );
+
+        File testFile =
+            getTestFile( "target/test-classes/projects/rewrite-for-development/" + "basic-pom/pom.xml.tag"
);
+        testFile.delete();
+        assertFalse( testFile.exists() );
+
+        phase.clean( config );
+
+        assertFalse( testFile.exists() );
     }
 
     protected void mapAlternateNextVersion( ReleaseConfiguration config, String projectId
)

Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.xml?rev=399143&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.xml
(added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/EndReleasePhaseTest.xml
Tue May  2 22:20:45 2006
@@ -0,0 +1,29 @@
+<!--
+  ~ Copyright 2005-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<component-set>
+  <components>
+    <!-- Turn off info messages -->
+    <component>
+      <role>org.codehaus.plexus.logging.LoggerManager</role>
+      <implementation>org.codehaus.plexus.logging.console.ConsoleLoggerManager</implementation>
+      <lifecycle-handler>basic</lifecycle-handler>
+      <configuration>
+        <threshold>ERROR</threshold>
+      </configuration>
+    </component>
+  </components>
+</component-set>

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

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



Mime
View raw message