compareTo should throw NullPointerException per spec (#35)
* compareTo should throw NullPointerException per spec
* consistent spelling
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..8283822 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
@@ -114,12 +114,12 @@
/**
* Specifies if this version is greater or equal to the specified version.
*
- * @param parmVersion the version to check
+ * @param paramVersion the version to check
* @return true if this version is greater or equal to <tt>version</tt>
*/
- public boolean ge( JavaEEVersion parmVersion )
+ public boolean ge( JavaEEVersion paramVersion )
{
- return this.compareTo( parmVersion ) >= 0;
+ return this.compareTo( paramVersion ) >= 0;
}
/**
@@ -176,7 +176,7 @@
{
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 @@
{
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 @@
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 @@
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
}