public void testEquals(){
  byte[] key=new byte[]{1,2,3,4,5};
  String algorithm="Algorithm";
  SecretKeySpec ks1=new SecretKeySpec(key,algorithm);
  SecretKeySpec ks2=new SecretKeySpec(key,algorithm);
  SecretKeySpec ks3=new SecretKeySpec(key,algorithm);
  assertTrue("The equivalence relation should be reflexive.",ks1.equals(ks1));
  assertTrue("Objects built on the same parameters should be equal.",ks1.equals(ks2));
  assertTrue("The equivalence relation should be symmetric.",ks2.equals(ks1));
  assertTrue("Objects built on the equal parameters should be equal.",ks2.equals(ks3));
  assertTrue("The equivalence relation should be transitive.",ks1.equals(ks3));
  assertFalse("Should not be equal to null object.",ks1.equals(null));
  ks2=new SecretKeySpec(new byte[]{1},algorithm);
  assertFalse("Objects should not be equal.",ks1.equals(ks2));
  ks2=new SecretKeySpec(key,"Another Algorithm");
  assertFalse("Objects should not be equal.",ks1.equals(ks2));
}

public void testEquals ( ) { byte [ ] key = new byte [ ] { 1 , 2 , 3 , 4 , 5 } ; String algorithm = "Algorithm" ; SecretKeySpec ks1 = new SecretKeySpec ( key , algorithm ) ; SecretKeySpec ks2 = new SecretKeySpec ( key , algorithm ) ; SecretKeySpec ks3 = new SecretKeySpec ( key , algorithm ) ; assertTrue ( "The equivalence relation should be reflexive." , ks1 . equals ( ks1 ) ) ; assertTrue ( "Objects built on the same parameters should be equal." , ks1 . equals ( ks2 ) ) ; assertTrue ( "The equivalence relation should be symmetric." , ks2 . equals ( ks1 ) ) ; assertTrue ( "Objects built on the equal parameters should be equal." , ks2 . equals ( ks3 ) ) ; assertTrue ( "The equivalence relation should be transitive." , ks1 . equals ( ks3 ) ) ; assertFalse ( "Should not be equal to null object." , ks1 . equals ( null ) ) ; ks2 = new SecretKeySpec ( new byte [ ] { 1 } , algorithm ) ; assertFalse ( "Objects should not be equal." , ks1 . equals ( ks2 ) ) ; ks2 = new SecretKeySpec ( key , "Another Algorithm" ) ; assertFalse ( "Objects should not be equal." , ks1 . equals ( ks2 ) ) ; }
equals ( object obj ) method testing . tests the correctness of equal operation : it should be reflexive , symmetric , transitive , consistent and should be false on null object .
