You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/12/26 14:00:26 UTC

[maven-ear-plugin] branch comparable created (now ad680cc)

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

elharo pushed a change to branch comparable
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git.


      at ad680cc  compareTo should throw NullPointerException per spec

This branch includes the following new commits:

     new ad680cc  compareTo should throw NullPointerException per spec

The 1 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.



[maven-ear-plugin] 01/01: compareTo should throw NullPointerException per spec

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

elharo pushed a commit to branch comparable
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git

commit ad680cc34d43c73913b51338d625c1b04db96d78
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Dec 26 09:00:10 2020 -0500

    compareTo should throw NullPointerException per spec
---
 .../maven/plugins/ear/util/JavaEEVersion.java       |  4 ++--
 .../maven/plugins/ear/util/JavaEEVersionTest.java   | 21 +++++----------------
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java b/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
index cff3577..a681ab0 100644
--- a/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
+++ b/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
@@ -176,7 +176,7 @@ public class JavaEEVersion
     {
         if ( paramVersion == null )
         {
-            throw new IllegalArgumentException( "version could not be null." );
+            throw new NullPointerException( "version cannot be null." );
         }
         // @formatter:off
         return VERSION_1_3.equals( paramVersion ) 
@@ -193,7 +193,7 @@ public class JavaEEVersion
     {
         if ( otherVersion == null )
         {
-            throw new IllegalArgumentException( "other object to compare to could not be null." );
+            throw new NullPointerException( "other object to compare to could not be null." );
         }
         return index.compareTo( otherVersion.index );
     }
diff --git a/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java b/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
index 9933b08..ac3070d 100644
--- a/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
+++ b/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
@@ -103,16 +103,9 @@ public class JavaEEVersionTest
         assertEquals( "5", JavaEEVersion.FIVE.getVersion() );
     }
 
-    public void testGetJavaEEVersionValid()
+    public void testGetJavaEEVersionValid() throws InvalidJavaEEVersion
     {
-        try
-        {
-            assertEquals( JavaEEVersion.SIX, JavaEEVersion.getJavaEEVersion( "6" ) );
-        }
-        catch ( InvalidJavaEEVersion invalidJavaEEVersion )
-        {
-            fail( "No exception should have been thrown but got [" + invalidJavaEEVersion.getMessage() + "]" );
-        }
+        assertEquals( JavaEEVersion.SIX, JavaEEVersion.getJavaEEVersion( "6" ) );
     }
 
     public void testGetJavaEEVersionInvalid()
@@ -122,24 +115,20 @@ public class JavaEEVersionTest
             JavaEEVersion.getJavaEEVersion( "2.4" );
             fail( "Should have failed to get an invalid version." );
         }
-        catch ( InvalidJavaEEVersion e )
+        catch ( InvalidJavaEEVersion expected )
         {
             // OK
         }
     }
 
-    public void testGetJavaEEVersionNull()
+    public void testGetJavaEEVersionNull() throws InvalidJavaEEVersion
     {
         try
         {
             JavaEEVersion.getJavaEEVersion( null );
             fail( "Should have failed to get a 'null' version." );
         }
-        catch ( InvalidJavaEEVersion e )
-        {
-            fail( "Should have failed with an illegal argument exception instead." );
-        }
-        catch ( IllegalArgumentException e )
+        catch ( NullPointerException expected )
         {
             // OK
         }