maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r399128 - in /maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config: PropertiesReleaseConfigurationStoreTest.java ReleaseConfigurationTest.java
Date Wed, 03 May 2006 04:34:14 GMT
Author: brett
Date: Tue May  2 21:34:11 2006
New Revision: 399128

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

Modified:
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
    maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java?rev=399128&r1=399127&r2=399128&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
Tue May  2 21:34:11 2006
@@ -20,7 +20,6 @@
 import org.codehaus.plexus.PlexusTestCase;
 
 import java.io.File;
-import java.util.Map;
 
 /**
  * Test the properties store.
@@ -45,54 +44,23 @@
         File file = getTestFile( "target/test-classes/release.properties" );
 
         ReleaseConfiguration config = store.read( file );
-        assertEquals( "Expected completedPhase of 'step1'", "step1", config.getCompletedPhase()
);
-        assertEquals( "Expected url of 'scm-url'", "scm-url", config.getUrl() );
-        assertEquals( "Expected username of 'username'", "username", config.getUsername()
);
-        assertEquals( "Expected password of 'password'", "password", config.getPassword()
);
-        assertEquals( "Expected private key of 'private-key'", "private-key", config.getPrivateKey()
);
-        assertEquals( "Expected passphrase of 'passphrase'", "passphrase", config.getPassphrase()
);
-        assertEquals( "Expected tag base of 'tagBase'", "tagBase", config.getTagBase() );
-        assertEquals( "Expected tag 'tag'", "tag", config.getReleaseLabel() );
-        assertEquals( "Expected additional arguments 'additional-arguments'", "additional-arguments",
-                      config.getAdditionalArguments() );
-        assertEquals( "Expected preparation goals 'preparation-goals'", "preparation-goals",
-                      config.getPreparationGoals() );
-        assertEquals( "Expected POM file name 'my-pom.xml'", "pom-file-name", config.getPomFileName()
);
-        assertNull( "Expected no workingDirectory", config.getWorkingDirectory() );
-        assertNull( "Expected no settings", config.getSettings() );
-        assertFalse( "Expected default generateReleasePoms", config.isGenerateReleasePoms()
);
-        assertFalse( "Expected default useEditMode", config.isUseEditMode() );
-        assertTrue( "Expected default interactive", config.isInteractive() );
-        assertFalse( "Expected default addScema", config.isAddSchema() );
 
-        Map versions = config.getReleaseVersions();
-        assertEquals( "Expected 2 version mappings", 2, versions.size() );
-        assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId1"
) );
-        assertEquals( "Incorrect version mapping", "2.0", versions.get( "groupId:artifactId1"
) );
-        assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId2"
) );
-        assertEquals( "Incorrect version mapping", "3.0", versions.get( "groupId:artifactId2"
) );
-
-        versions = config.getDevelopmentVersions();
-        assertEquals( "Expected 2 version mappings", 2, versions.size() );
-        assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId1"
) );
-        assertEquals( "Incorrect version mapping", "2.1-SNAPSHOT", versions.get( "groupId:artifactId1"
) );
-        assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId2"
) );
-        assertEquals( "Incorrect version mapping", "3.0.1-SNAPSHOT", versions.get( "groupId:artifactId2"
) );
-
-        versions = config.getOriginalScmInfo();
-        assertEquals( "Expected 2 SCM mappings", 2, versions.size() );
-        assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId1"
) );
-        Scm scm = (Scm) versions.get( "groupId:artifactId1" );
-        assertEquals( "Incorrect SCM mapping", "connection", scm.getConnection() );
-        assertEquals( "Incorrect SCM mapping", "developerConnection", scm.getDeveloperConnection()
);
-        assertEquals( "Incorrect SCM mapping", "url", scm.getUrl() );
-        assertEquals( "Incorrect SCM mapping", "tag", scm.getTag() );
-        assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId2"
) );
-        scm = (Scm) versions.get( "groupId:artifactId2" );
-        assertEquals( "Incorrect SCM mapping", "connection2", scm.getConnection() );
-        assertNull( "Incorrect SCM mapping", scm.getDeveloperConnection() );
-        assertEquals( "Incorrect SCM mapping", "url2", scm.getUrl() );
-        assertNull( "Incorrect SCM mapping", scm.getTag() );
+        ReleaseConfiguration expected = createExcpectedReleaseConfiguration();
+
+        assertEquals( "check matches", expected, config );
+    }
+
+    public void testReadFromFileUsingWorkingDirectory()
+        throws ReleaseConfigurationStoreException
+    {
+        ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+        releaseConfiguration.setWorkingDirectory( getTestFile( "target/test-classes" ) );
+        ReleaseConfiguration config = store.read( releaseConfiguration );
+
+        ReleaseConfiguration expected = createExcpectedReleaseConfiguration();
+        expected.setWorkingDirectory( releaseConfiguration.getWorkingDirectory() );
+
+        assertEquals( "check matches", expected, config );
     }
 
     public void testReadFromEmptyFile()
@@ -286,4 +254,44 @@
 
         return releaseConfiguration;
     }
+
+    private ReleaseConfiguration createExcpectedReleaseConfiguration()
+    {
+        ReleaseConfiguration expected = new ReleaseConfiguration();
+        expected.setCompletedPhase( "step1" );
+        expected.setUrl( "scm-url" );
+        expected.setUsername( "username" );
+        expected.setPassword( "password" );
+        expected.setPrivateKey( "private-key" );
+        expected.setPassphrase( "passphrase" );
+        expected.setTagBase( "tagBase" );
+        expected.setReleaseLabel( "tag" );
+        expected.setAdditionalArguments( "additional-arguments" );
+        expected.setPreparationGoals( "preparation-goals" );
+        expected.setPomFileName( "pom-file-name" );
+        expected.setWorkingDirectory( null );
+        expected.setSettings( null );
+        expected.setGenerateReleasePoms( false );
+        expected.setUseEditMode( false );
+        expected.setInteractive( true );
+        expected.setAddSchema( false );
+        expected.mapReleaseVersion( "groupId:artifactId1", "2.0" );
+        expected.mapReleaseVersion( "groupId:artifactId2", "3.0" );
+        expected.mapDevelopmentVersion( "groupId:artifactId1", "2.1-SNAPSHOT" );
+        expected.mapDevelopmentVersion( "groupId:artifactId2", "3.0.1-SNAPSHOT" );
+        Scm scm = new Scm();
+        scm.setConnection( "connection" );
+        scm.setDeveloperConnection( "developerConnection" );
+        scm.setUrl( "url" );
+        scm.setTag( "tag" );
+        expected.mapOriginalScmInfo( "groupId:artifactId1", scm );
+        scm = new Scm();
+        scm.setConnection( "connection2" );
+        scm.setUrl( "url2" );
+        scm.setTag( null );
+        scm.setDeveloperConnection( null );
+        expected.mapOriginalScmInfo( "groupId:artifactId2", scm );
+        return expected;
+    }
+
 }

Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java?rev=399128&r1=399127&r2=399128&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/ReleaseConfigurationTest.java
Tue May  2 21:34:11 2006
@@ -17,9 +17,14 @@
  */
 
 import junit.framework.TestCase;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Scm;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Settings;
 
 import java.io.File;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * ReleaseConfiguration Tester.
@@ -46,7 +51,8 @@
         releaseConfiguration.merge( new ReleaseConfiguration() );
 
         ReleaseConfiguration expectedConfiguration = createReleaseConfiguration( releaseConfiguration.getSettings(),
-                                                                                 releaseConfiguration.getWorkingDirectory()
);
+                                                                                 releaseConfiguration.getWorkingDirectory(),
+                                                                                 releaseConfiguration.getReactorProjects()
);
         assertEquals( "Check merge", expectedConfiguration, releaseConfiguration );
     }
 
@@ -64,9 +70,206 @@
         ReleaseConfiguration expectedConfiguration = createMergeConfiguration( releaseConfiguration.getSettings(),
                                                                                releaseConfiguration.getWorkingDirectory(),
                                                                                releaseConfiguration.getCompletedPhase()
);
+        expectedConfiguration.setReactorProjects( releaseConfiguration.getReactorProjects()
);
         assertEquals( "Check merge", expectedConfiguration, releaseConfiguration );
     }
 
+    public void testEquals()
+    {
+        ReleaseConfiguration originalReleaseConfiguration = createReleaseConfiguration();
+        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration(
+            originalReleaseConfiguration.getSettings(), originalReleaseConfiguration.getWorkingDirectory(),
+            originalReleaseConfiguration.getReactorProjects() );
+        doEqualsAssertions( releaseConfiguration, originalReleaseConfiguration, "other",
Collections.EMPTY_LIST,
+                            new File( "f" ), new Settings() );
+        originalReleaseConfiguration = createReleaseConfiguration();
+        releaseConfiguration = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                                           originalReleaseConfiguration.getWorkingDirectory(),
+                                                           originalReleaseConfiguration.getReactorProjects()
);
+        doEqualsAssertions( originalReleaseConfiguration, releaseConfiguration, "other",
Collections.EMPTY_LIST,
+                            new File( "f" ), new Settings() );
+
+        originalReleaseConfiguration = createReleaseConfiguration();
+        releaseConfiguration = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                                           originalReleaseConfiguration.getWorkingDirectory(),
+                                                           originalReleaseConfiguration.getReactorProjects()
);
+        doEqualsAssertions( releaseConfiguration, originalReleaseConfiguration, null, null,
null, null );
+        originalReleaseConfiguration = createReleaseConfiguration();
+        releaseConfiguration = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                                           originalReleaseConfiguration.getWorkingDirectory(),
+                                                           originalReleaseConfiguration.getReactorProjects()
);
+        doEqualsAssertions( originalReleaseConfiguration, releaseConfiguration, null, null,
null, null );
+
+        assertEquals( "test ==", releaseConfiguration, releaseConfiguration );
+        Object obj = this;
+        assertFalse( "test class instance", releaseConfiguration.equals( obj ) );
+    }
+
+    private static void doEqualsAssertions( ReleaseConfiguration releaseConfiguration,
+                                            ReleaseConfiguration originalReleaseConfiguration,
String other,
+                                            List reactorProjects, File otherFile, Settings
otherSettings )
+    {
+        ReleaseConfiguration config = releaseConfiguration;
+        assertEquals( "Check original comparison", config, originalReleaseConfiguration );
+
+        config.setUrl( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setUrl( originalReleaseConfiguration.getUrl() );
+
+        config.setAdditionalArguments( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setAdditionalArguments( originalReleaseConfiguration.getAdditionalArguments()
);
+
+        config.setAddSchema( !originalReleaseConfiguration.isAddSchema() );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setAddSchema( originalReleaseConfiguration.isAddSchema() );
+
+        config.setGenerateReleasePoms( !originalReleaseConfiguration.isAddSchema() );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setGenerateReleasePoms( originalReleaseConfiguration.isGenerateReleasePoms()
);
+
+        config.setUseEditMode( !originalReleaseConfiguration.isUseEditMode() );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setUseEditMode( originalReleaseConfiguration.isUseEditMode() );
+
+        config.setInteractive( !originalReleaseConfiguration.isInteractive() );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setInteractive( originalReleaseConfiguration.isInteractive() );
+
+        config.setCompletedPhase( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setCompletedPhase( originalReleaseConfiguration.getCompletedPhase() );
+
+        config.setPassphrase( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setPassphrase( originalReleaseConfiguration.getPassphrase() );
+
+        config.setPassword( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setPassword( originalReleaseConfiguration.getPassword() );
+
+        config.setUsername( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setUsername( originalReleaseConfiguration.getUsername() );
+
+        config.setPrivateKey( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setPrivateKey( originalReleaseConfiguration.getPrivateKey() );
+
+        config.setPomFileName( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setPomFileName( originalReleaseConfiguration.getPomFileName() );
+
+        config.setPreparationGoals( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setPreparationGoals( originalReleaseConfiguration.getPreparationGoals() );
+
+        config.setReactorProjects( reactorProjects );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setReactorProjects( originalReleaseConfiguration.getReactorProjects() );
+
+        config.setSettings( otherSettings );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setSettings( originalReleaseConfiguration.getSettings() );
+
+        config.setReleaseLabel( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setReleaseLabel( originalReleaseConfiguration.getReleaseLabel() );
+
+        config.setTagBase( other );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setTagBase( originalReleaseConfiguration.getTagBase() );
+
+        config.setWorkingDirectory( otherFile );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config.setWorkingDirectory( originalReleaseConfiguration.getWorkingDirectory() );
+
+        // sanity check the test was resetting correctly
+        assertEquals( "Check original comparison", config, originalReleaseConfiguration );
+
+        config.mapDevelopmentVersion( "groupId:artifactId", "1.0-SNAPSHOT" );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapReleaseVersion( "groupId:artifactId", "1.0" );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", new Scm() );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", new Scm() );
+        originalReleaseConfiguration.mapOriginalScmInfo( "foo", new Scm() );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", new Scm() );
+        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", new Scm()
);
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url", "tag"
) );
+        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn",
"dev", "url", "tag" ) );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", getScm( "-", "dev", "url", "tag"
) );
+        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn",
"dev", "url", "tag" ) );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "-", "url", "tag"
) );
+        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn",
"dev", "url", "tag" ) );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "-", "tag"
) );
+        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn",
"dev", "url", "tag" ) );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                             originalReleaseConfiguration.getWorkingDirectory(),
+                                             originalReleaseConfiguration.getReactorProjects()
);
+
+        config.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url", "-"
) );
+        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn",
"dev", "url", "tag" ) );
+        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+    }
+
+    public void testHashCode()
+    {
+        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration();
+        assertEquals( "Check hash code", releaseConfiguration.hashCode(), createReleaseConfiguration(
+            releaseConfiguration.getSettings(), releaseConfiguration.getWorkingDirectory(),
+            releaseConfiguration.getReactorProjects() ).hashCode() );
+    }
+
+    private static Scm getScm( String connection, String developerConnection, String url,
String tag )
+    {
+        Scm scm = new Scm();
+        scm.setConnection( connection );
+        scm.setDeveloperConnection( developerConnection );
+        scm.setTag( tag );
+        scm.setUrl( url );
+        return scm;
+    }
+
     private static ReleaseConfiguration createMergeConfiguration( Settings settings, File
workingDirectory,
                                                                   String completedPhase )
     {
@@ -80,6 +283,9 @@
         mergeConfiguration.setTagBase( "tag-base-merge" );
         mergeConfiguration.setReleaseLabel( "tag-merge" );
         mergeConfiguration.setUsername( "username-merge" );
+        mergeConfiguration.setAdditionalArguments( "additional-arguments-merge" );
+        mergeConfiguration.setPomFileName( "pom-file-name-merge" );
+        mergeConfiguration.setPreparationGoals( "preparation-goals-merge" );
         mergeConfiguration.setWorkingDirectory( workingDirectory );
         return mergeConfiguration;
     }
@@ -88,11 +294,13 @@
     {
         Settings settings = new Settings();
         File workingDirectory = new File( "." );
+        MavenProject project = new MavenProject( new Model() );
 
-        return createReleaseConfiguration( settings, workingDirectory );
+        return createReleaseConfiguration( settings, workingDirectory, Collections.singletonList(
project ) );
     }
 
-    private static ReleaseConfiguration createReleaseConfiguration( Settings settings, File
workingDirectory )
+    private static ReleaseConfiguration createReleaseConfiguration( Settings settings, File
workingDirectory,
+                                                                    List list )
     {
         ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
         releaseConfiguration.setUrl( "scm-url" );
@@ -105,6 +313,10 @@
         releaseConfiguration.setReleaseLabel( "tag" );
         releaseConfiguration.setUsername( "username" );
         releaseConfiguration.setWorkingDirectory( workingDirectory );
+        releaseConfiguration.setAdditionalArguments( "additional-arguments" );
+        releaseConfiguration.setPomFileName( "pom-file-name" );
+        releaseConfiguration.setPreparationGoals( "preparation-goals" );
+        releaseConfiguration.setReactorProjects( list );
         return releaseConfiguration;
     }
 }



Mime
View raw message