question: public static void checkEqualsAndHashCodeMethods ( String message , Object lhs , Object rhs , boolean expectedResult ) { if ( ( lhs == null ) && ( rhs == null ) ) { Assert . assertTrue ( "Your check is dubious...why would you expect null != null?" , expectedResult ) ; return ; } if ( ( lhs == null ) || ( rhs == null ) ) { Assert . assertFalse ( "Your check is dubious...why would you expect an object " + "to be equal to null?" , expectedResult ) ; } if ( lhs != null ) { Assert . assertEquals ( message , expectedResult , lhs . equals ( rhs ) ) ; } if ( rhs != null ) { Assert . assertEquals ( message , expectedResult , rhs . equals ( lhs ) ) ; } if ( expectedResult ) { String hashMessage = "hashCode() values for equal objects should be the same" ; if ( message != null ) { hashMessage += ": " + message ; } Assert . assertTrue ( hashMessage , lhs . hashCode ( ) == rhs . hashCode ( ) ) ; } }
target:  Utility for testing equals() and hashCode() results at once. Tests that lhs.equals(rhs) matches expectedResult, as well as rhs.equals(lhs).  Also tests that hashCode() return values are equal if expectedResult is true.  (hashCode() is not tested if expectedResult is false, as unequal objects can have equal hashCodes.)