maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r399137 - 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:49:13 GMT
Author: brett
Date: Tue May  2 21:49:13 2006
New Revision: 399137

URL: http://svn.apache.org/viewcvs?rev=399137&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=399137&r1=399136&r2=399137&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:49:13 2006
@@ -20,6 +20,7 @@
 import org.codehaus.plexus.PlexusTestCase;
 
 import java.io.File;
+import java.io.IOException;
 
 /**
  * Test the properties store.
@@ -121,6 +122,25 @@
         assertEquals( "compare configuration", config, rereadConfiguration );
     }
 
+    public void testWriteToWorkingDirectory()
+        throws ReleaseConfigurationStoreException
+    {
+        File file = getTestFile( "target/test-classes/new/release.properties" );
+        file.delete();
+        assertFalse( "Check file doesn't exist", file.exists() );
+        file.getParentFile().mkdirs();
+
+        ReleaseConfiguration config = createReleaseConfigurationForWriting();
+        config.setWorkingDirectory( file.getParentFile() );
+
+        store.write( config );
+
+        ReleaseConfiguration rereadConfiguration = store.read( file );
+        rereadConfiguration.setWorkingDirectory( file.getParentFile() );
+
+        assertEquals( "compare configuration", config, rereadConfiguration );
+    }
+
     public void testWriteToNewFileRequiredOnly()
         throws ReleaseConfigurationStoreException
     {
@@ -180,6 +200,38 @@
         ReleaseConfiguration rereadConfiguration = store.read( file );
 
         assertEquals( "compare configuration", config, rereadConfiguration );
+    }
+
+    public void testDeleteFile()
+        throws ReleaseConfigurationStoreException, IOException
+    {
+        File file = getTestFile( "target/test-classes/delete/release.properties" );
+        file.getParentFile().mkdirs();
+        file.createNewFile();
+        assertTrue( "Check file already exists", file.exists() );
+
+        ReleaseConfiguration config = createReleaseConfigurationForWriting();
+        config.setWorkingDirectory( file.getParentFile() );
+
+        store.delete( config );
+
+        assertFalse( "Check file already exists", file.exists() );
+    }
+
+    public void testMissingDeleteFile()
+        throws ReleaseConfigurationStoreException, IOException
+    {
+        File file = getTestFile( "target/test-classes/delete/release.properties" );
+        file.getParentFile().mkdirs();
+        file.delete();
+        assertFalse( "Check file already exists", file.exists() );
+
+        ReleaseConfiguration config = createReleaseConfigurationForWriting();
+        config.setWorkingDirectory( file.getParentFile() );
+
+        store.delete( config );
+
+        assertFalse( "Check file already exists", file.exists() );
     }
 
     private ReleaseConfiguration createReleaseConfigurationForWriting()

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=399137&r1=399136&r2=399137&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:49:13 2006
@@ -50,9 +50,7 @@
 
         releaseConfiguration.merge( new ReleaseConfiguration() );
 
-        ReleaseConfiguration expectedConfiguration = createReleaseConfiguration( releaseConfiguration.getSettings(),
-                                                                                 releaseConfiguration.getWorkingDirectory(),
-                                                                                 releaseConfiguration.getReactorProjects()
);
+        ReleaseConfiguration expectedConfiguration = copyReleaseConfiguration( releaseConfiguration
);
         assertEquals( "Check merge", expectedConfiguration, releaseConfiguration );
     }
 
@@ -77,27 +75,19 @@
     public void testEquals()
     {
         ReleaseConfiguration originalReleaseConfiguration = createReleaseConfiguration();
-        ReleaseConfiguration releaseConfiguration = createReleaseConfiguration(
-            originalReleaseConfiguration.getSettings(), originalReleaseConfiguration.getWorkingDirectory(),
-            originalReleaseConfiguration.getReactorProjects() );
+        ReleaseConfiguration releaseConfiguration = copyReleaseConfiguration( originalReleaseConfiguration
);
         doEqualsAssertions( releaseConfiguration, originalReleaseConfiguration, "other",
Collections.EMPTY_LIST,
                             new File( "f" ), new Settings() );
         originalReleaseConfiguration = createReleaseConfiguration();
-        releaseConfiguration = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
-                                                           originalReleaseConfiguration.getWorkingDirectory(),
-                                                           originalReleaseConfiguration.getReactorProjects()
);
+        releaseConfiguration = copyReleaseConfiguration( originalReleaseConfiguration );
         doEqualsAssertions( originalReleaseConfiguration, releaseConfiguration, "other",
Collections.EMPTY_LIST,
                             new File( "f" ), new Settings() );
 
         originalReleaseConfiguration = createReleaseConfiguration();
-        releaseConfiguration = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
-                                                           originalReleaseConfiguration.getWorkingDirectory(),
-                                                           originalReleaseConfiguration.getReactorProjects()
);
+        releaseConfiguration = copyReleaseConfiguration( originalReleaseConfiguration );
         doEqualsAssertions( releaseConfiguration, originalReleaseConfiguration, null, null,
null, null );
         originalReleaseConfiguration = createReleaseConfiguration();
-        releaseConfiguration = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
-                                                           originalReleaseConfiguration.getWorkingDirectory(),
-                                                           originalReleaseConfiguration.getReactorProjects()
);
+        releaseConfiguration = copyReleaseConfiguration( originalReleaseConfiguration );
         doEqualsAssertions( originalReleaseConfiguration, releaseConfiguration, null, null,
null, null );
 
         assertEquals( "test ==", releaseConfiguration, releaseConfiguration );
@@ -109,147 +99,136 @@
                                             ReleaseConfiguration originalReleaseConfiguration,
String other,
                                             List reactorProjects, File otherFile, Settings
otherSettings )
     {
+        ReleaseConfiguration origConfig = originalReleaseConfiguration;
         ReleaseConfiguration config = releaseConfiguration;
-        assertEquals( "Check original comparison", config, originalReleaseConfiguration );
+        assertEquals( "Check original comparison", config, origConfig );
 
         config.setUrl( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setUrl( originalReleaseConfiguration.getUrl() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setUrl( origConfig.getUrl() );
 
         config.setAdditionalArguments( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setAdditionalArguments( originalReleaseConfiguration.getAdditionalArguments()
);
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setAdditionalArguments( origConfig.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.setAddSchema( !origConfig.isAddSchema() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setAddSchema( origConfig.isAddSchema() );
+
+        config.setGenerateReleasePoms( !origConfig.isAddSchema() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setGenerateReleasePoms( origConfig.isGenerateReleasePoms() );
+
+        config.setUseEditMode( !origConfig.isUseEditMode() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setUseEditMode( origConfig.isUseEditMode() );
+
+        config.setInteractive( !origConfig.isInteractive() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setInteractive( origConfig.isInteractive() );
 
         config.setCompletedPhase( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setCompletedPhase( originalReleaseConfiguration.getCompletedPhase() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setCompletedPhase( origConfig.getCompletedPhase() );
 
         config.setPassphrase( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setPassphrase( originalReleaseConfiguration.getPassphrase() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setPassphrase( origConfig.getPassphrase() );
 
         config.setPassword( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setPassword( originalReleaseConfiguration.getPassword() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setPassword( origConfig.getPassword() );
 
         config.setUsername( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setUsername( originalReleaseConfiguration.getUsername() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setUsername( origConfig.getUsername() );
 
         config.setPrivateKey( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setPrivateKey( originalReleaseConfiguration.getPrivateKey() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setPrivateKey( origConfig.getPrivateKey() );
 
         config.setPomFileName( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setPomFileName( originalReleaseConfiguration.getPomFileName() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setPomFileName( origConfig.getPomFileName() );
 
         config.setPreparationGoals( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setPreparationGoals( originalReleaseConfiguration.getPreparationGoals() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setPreparationGoals( origConfig.getPreparationGoals() );
 
         config.setReactorProjects( reactorProjects );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setReactorProjects( originalReleaseConfiguration.getReactorProjects() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setReactorProjects( origConfig.getReactorProjects() );
 
         config.setSettings( otherSettings );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setSettings( originalReleaseConfiguration.getSettings() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setSettings( origConfig.getSettings() );
 
         config.setReleaseLabel( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setReleaseLabel( originalReleaseConfiguration.getReleaseLabel() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setReleaseLabel( origConfig.getReleaseLabel() );
 
         config.setTagBase( other );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setTagBase( originalReleaseConfiguration.getTagBase() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setTagBase( origConfig.getTagBase() );
 
         config.setWorkingDirectory( otherFile );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config.setWorkingDirectory( originalReleaseConfiguration.getWorkingDirectory() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config.setWorkingDirectory( origConfig.getWorkingDirectory() );
 
         // sanity check the test was resetting correctly
-        assertEquals( "Check original comparison", config, originalReleaseConfiguration );
+        assertEquals( "Check original comparison", config, origConfig );
 
         config.mapDevelopmentVersion( "groupId:artifactId", "1.0-SNAPSHOT" );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
-                                             originalReleaseConfiguration.getWorkingDirectory(),
-                                             originalReleaseConfiguration.getReactorProjects()
);
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config = copyReleaseConfiguration( origConfig );
 
         config.mapReleaseVersion( "groupId:artifactId", "1.0" );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
-                                             originalReleaseConfiguration.getWorkingDirectory(),
-                                             originalReleaseConfiguration.getReactorProjects()
);
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config = copyReleaseConfiguration( origConfig );
 
         config.mapOriginalScmInfo( "groupId:artifactId", new Scm() );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
-        config = createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
-                                             originalReleaseConfiguration.getWorkingDirectory(),
-                                             originalReleaseConfiguration.getReactorProjects()
);
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        config = copyReleaseConfiguration( origConfig );
 
         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()
);
+        origConfig.mapOriginalScmInfo( "foo", new Scm() );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        origConfig = createReleaseConfiguration();
+        config = copyReleaseConfiguration( origConfig );
 
         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()
);
+        origConfig.mapOriginalScmInfo( "groupId:artifactId", new Scm() );
+        assertEquals( "Check original comparison", config, origConfig );
+        origConfig = createReleaseConfiguration();
+        config = copyReleaseConfiguration( origConfig );
 
         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()
);
+        origConfig.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url",
"tag" ) );
+        assertEquals( "Check original comparison", config, origConfig );
+        origConfig = createReleaseConfiguration();
+        config = copyReleaseConfiguration( origConfig );
 
         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()
);
+        origConfig.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url",
"tag" ) );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        origConfig = createReleaseConfiguration();
+        config = copyReleaseConfiguration( origConfig );
 
         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()
);
+        origConfig.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url",
"tag" ) );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        origConfig = createReleaseConfiguration();
+        config = copyReleaseConfiguration( origConfig );
 
         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()
);
+        origConfig.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url",
"tag" ) );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
+        origConfig = createReleaseConfiguration();
+        config = copyReleaseConfiguration( origConfig );
 
         config.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url", "-"
) );
-        originalReleaseConfiguration.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn",
"dev", "url", "tag" ) );
-        assertFalse( "Check original comparison", config.equals( originalReleaseConfiguration
) );
+        origConfig.mapOriginalScmInfo( "groupId:artifactId", getScm( "conn", "dev", "url",
"tag" ) );
+        assertFalse( "Check original comparison", config.equals( origConfig ) );
     }
 
     public void testHashCode()
@@ -258,6 +237,13 @@
         assertEquals( "Check hash code", releaseConfiguration.hashCode(), createReleaseConfiguration(
             releaseConfiguration.getSettings(), releaseConfiguration.getWorkingDirectory(),
             releaseConfiguration.getReactorProjects() ).hashCode() );
+    }
+
+    private static ReleaseConfiguration copyReleaseConfiguration( ReleaseConfiguration originalReleaseConfiguration
)
+    {
+        return createReleaseConfiguration( originalReleaseConfiguration.getSettings(),
+                                           originalReleaseConfiguration.getWorkingDirectory(),
+                                           originalReleaseConfiguration.getReactorProjects()
);
     }
 
     private static Scm getScm( String connection, String developerConnection, String url,
String tag )



Mime
View raw message