You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2020/04/23 20:13:45 UTC

[maven-gpg-plugin] branch MGPG-78 updated (92a78f7 -> 58a4a7c)

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a change to branch MGPG-78
in repository https://gitbox.apache.org/repos/asf/maven-gpg-plugin.git.


    from 92a78f7  [MGPG-78] gpg version parsing failure on Windows
     new 5e58759  added a test for GpgVersion.isBefore() in GpgVersionTest
     new 58a4a7c  make equals and compareTo consistent with Java requirements

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/maven/plugins/gpg/GpgVersion.java   | 24 +++++++++++++++++++++-
 .../apache/maven/plugins/gpg/GpgVersionTest.java   | 24 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)


[maven-gpg-plugin] 01/02: added a test for GpgVersion.isBefore() in GpgVersionTest

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch MGPG-78
in repository https://gitbox.apache.org/repos/asf/maven-gpg-plugin.git

commit 5e587594dbb0662bce82081ce59322196fd40034
Author: tibordigana <ti...@apache.org>
AuthorDate: Thu Apr 23 22:05:16 2020 +0200

    added a test for GpgVersion.isBefore() in GpgVersionTest
---
 src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java b/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
index 337416d..504f5a5 100644
--- a/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
+++ b/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.plugins.gpg;
 
 import org.junit.Test;
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -38,4 +39,13 @@ public class GpgVersionTest
                 .isAtLeast( GpgVersion.parse( "2.0.26" ) ) );
     }
 
+    @Test
+    public void testOpposite()
+    {
+        assertFalse( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).isBefore( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ) ) );
+        assertFalse( GpgVersion.parse( "gpg (GnuPG) 2.2.1" ).isBefore( GpgVersion.parse( "2.1" ) ) );
+        assertFalse( GpgVersion.parse( "gpg (GnuPG/MacGPG2) 2.2.10" ).isBefore( GpgVersion.parse( "2.2.10" ) ) );
+        assertFalse( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)" )
+                .isBefore( GpgVersion.parse( "2.0.26" ) ) );
+    }
 }


[maven-gpg-plugin] 02/02: make equals and compareTo consistent with Java requirements

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch MGPG-78
in repository https://gitbox.apache.org/repos/asf/maven-gpg-plugin.git

commit 58a4a7c9712f724bb5af7860a9e833f5e4fd2eac
Author: tibordigana <ti...@apache.org>
AuthorDate: Thu Apr 23 22:13:35 2020 +0200

    make equals and compareTo consistent with Java requirements
---
 .../org/apache/maven/plugins/gpg/GpgVersion.java   | 24 +++++++++++++++++++++-
 .../apache/maven/plugins/gpg/GpgVersionTest.java   | 14 +++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/gpg/GpgVersion.java b/src/main/java/org/apache/maven/plugins/gpg/GpgVersion.java
index 35b33e0..fa2a3d9 100644
--- a/src/main/java/org/apache/maven/plugins/gpg/GpgVersion.java
+++ b/src/main/java/org/apache/maven/plugins/gpg/GpgVersion.java
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
  * @author Robert Scholte
  * @since 3.0.0
  */
-public class GpgVersion implements Comparable<GpgVersion>
+public final class GpgVersion implements Comparable<GpgVersion>
 {
     private final String rawVersion;
 
@@ -140,4 +140,26 @@ public class GpgVersion implements Comparable<GpgVersion>
         return rawVersion;
     }
 
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        GpgVersion that = (GpgVersion) o;
+        return compareTo( that ) == 0;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return 1;
+    }
 }
diff --git a/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java b/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
index 504f5a5..57eb9c3 100644
--- a/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
+++ b/src/test/java/org/apache/maven/plugins/gpg/GpgVersionTest.java
@@ -21,7 +21,9 @@ package org.apache.maven.plugins.gpg;
 
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -48,4 +50,16 @@ public class GpgVersionTest
         assertFalse( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)" )
                 .isBefore( GpgVersion.parse( "2.0.26" ) ) );
     }
+
+    @Test
+    public void testEquals()
+    {
+        assertEquals( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)" ), GpgVersion.parse( "2.0.26" ) );
+    }
+
+    @Test
+    public void testNotEquals()
+    {
+        assertNotEquals( GpgVersion.parse( "gpg (GnuPG) 2.0.26 (Gpg4win 2.2.3)" ), GpgVersion.parse( "2.0" ) );
+    }
 }