public void testHashCode(){
  byte[] key=new byte[]{1,2,3,4,5};
  String algorithm="Algorithm";
  SecretKeySpec ks1=new SecretKeySpec(key,algorithm);
  SecretKeySpec ks2=new SecretKeySpec(key,algorithm);
  assertTrue("Equal objects should have the same hash codes.",ks1.hashCode() == ks2.hashCode());
}

public void testHashCode ( ) { byte [ ] key = new byte [ ] { 1 , 2 , 3 , 4 , 5 } ; String algorithm = "Algorithm" ; SecretKeySpec ks1 = new SecretKeySpec ( key , algorithm ) ; SecretKeySpec ks2 = new SecretKeySpec ( key , algorithm ) ; assertTrue ( "Equal objects should have the same hash codes." , ks1 . hashCode ( ) == ks2 . hashCode ( ) ) ; }
hashcode ( ) method testing . tests that for equal objects hash codes are equal .
