public void testIsParityAdjusted(){
  try {
    DESKeySpec.isParityAdjusted(null,1);
    fail("Should raise an InvalidKeyException " + "in case of null byte array.");
  }
 catch (  NullPointerException e) {
    fail("Unexpected NullPointerException was thrown.");
  }
catch (  InvalidKeyException e) {
  }
  byte[] key={1,2,3,4,5,6,7,8};
  try {
    DESKeySpec.isParityAdjusted(key,1);
    fail("Should raise an InvalidKeyException " + "in case of short byte array.");
  }
 catch (  NullPointerException e) {
    fail("Unexpected NullPointerException was thrown.");
  }
catch (  InvalidKeyException e) {
  }
  byte[] key_not_pa={1,2,3,4,5,6,7,8};
  try {
    assertFalse("Method returns true when false is expected.",DESKeySpec.isParityAdjusted(key_not_pa,0));
  }
 catch (  NullPointerException e) {
    fail("Unexpected NullPointerException was thrown.");
  }
catch (  InvalidKeyException e) {
    fail("Unexpected InvalidKeyException was thrown.");
  }
  byte[] key_pa={(byte)128,(byte)131,(byte)133,(byte)134,(byte)137,(byte)138,(byte)140,(byte)143};
  try {
    assertTrue("Method returns false when true is expected.",DESKeySpec.isParityAdjusted(key_pa,0));
  }
 catch (  NullPointerException e) {
    fail("Unexpected NullPointerException was thrown.");
  }
catch (  InvalidKeyException e) {
    fail("Unexpected InvalidKeyException was thrown.");
  }
}

public void testIsParityAdjusted ( ) { try { DESKeySpec . isParityAdjusted ( null , 1 ) ; fail ( "Should raise an InvalidKeyException " + "in case of null byte array." ) ; } catch ( NullPointerException e ) { fail ( "Unexpected NullPointerException was thrown." ) ; } catch ( InvalidKeyException e ) { } byte [ ] key = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; try { DESKeySpec . isParityAdjusted ( key , 1 ) ; fail ( "Should raise an InvalidKeyException " + "in case of short byte array." ) ; } catch ( NullPointerException e ) { fail ( "Unexpected NullPointerException was thrown." ) ; } catch ( InvalidKeyException e ) { } byte [ ] key_not_pa = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; try { assertFalse ( "Method returns true when false is expected." , DESKeySpec . isParityAdjusted ( key_not_pa , 0 ) ) ; } catch ( NullPointerException e ) { fail ( "Unexpected NullPointerException was thrown." ) ; } catch ( InvalidKeyException e ) { fail ( "Unexpected InvalidKeyException was thrown." ) ; } byte [ ] key_pa = { ( byte ) 128 , ( byte ) 131 , ( byte ) 133 , ( byte ) 134 , ( byte ) 137 , ( byte ) 138 , ( byte ) 140 , ( byte ) 143 } ; try { assertTrue ( "Method returns false when true is expected." , DESKeySpec . isParityAdjusted ( key_pa , 0 ) ) ; } catch ( NullPointerException e ) { fail ( "Unexpected NullPointerException was thrown." ) ; } catch ( InvalidKeyException e ) { fail ( "Unexpected InvalidKeyException was thrown." ) ; } }
isparityadjusted ( byte [ ] key , offset ) method testing . tests if the method throws appropriate exceptions on incorrect byte array , if it returns false on the key which is not parity adjusted , and if it returns true on parity adjusted key .
