mirror of https://github.com/apache/maven.git
[MNG-4227] DefaultArtifactVersion equals implementation does not handle null
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@790712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8380f2d92e
commit
553fce0f1a
|
@ -56,6 +56,16 @@ public class DefaultArtifactVersion
|
|||
@Override
|
||||
public boolean equals( Object other )
|
||||
{
|
||||
if ( this == other )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !( other instanceof ArtifactVersion ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return compareTo( other ) == 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,6 +177,16 @@ public class DefaultArtifactVersionTest
|
|||
assertEquals( v1.hashCode(), v2.hashCode() );
|
||||
}
|
||||
|
||||
public void testEqualsNullSafe()
|
||||
{
|
||||
assertFalse( newArtifactVersion( "1" ).equals( null ) );
|
||||
}
|
||||
|
||||
public void testEqualsTypeSafe()
|
||||
{
|
||||
assertFalse( newArtifactVersion( "1" ).equals( "non-an-artifact-version-instance" ) );
|
||||
}
|
||||
|
||||
private void assertVersionOlder( String left, String right )
|
||||
{
|
||||
assertTrue( left + " should be older than " + right,
|
||||
|
@ -192,4 +202,5 @@ public class DefaultArtifactVersionTest
|
|||
assertTrue( right + " should be equal to " + left,
|
||||
newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) == 0 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue