* Constructors testing. Tests behavior of each of two constructors
* in the cases of: null array, short array, normal array.
*/
public void testDESKeySpec() {
try {
new DESKeySpec((byte []) null);
fail("Should raise an NullPointerException "
+ "in case of null byte array.");
} catch (NullPointerException e) {
} catch (InvalidKeyException e) {
fail("Should raise an NullPointerException "
+ "in case of null byte array.");
}
try {
new DESKeySpec(new byte [] {1, 2, 3});
fail("Should raise an InvalidKeyException on a short byte array.");
} catch (NullPointerException e) {
fail("Unexpected NullPointerException was thrown.");
} catch (InvalidKeyException e) {
}
try {
new DESKeySpec(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});
} catch (NullPointerException e) {
fail("Unexpected NullPointerException was thrown.");
} catch (InvalidKeyException e) {
fail("Unexpected InvalidKeyException was thrown.");
}
try {
new DESKeySpec((byte []) null, 1);
fail("Should raise an NullPointerException "
+ "in case of null byte array.");
} catch (NullPointerException e) {
} catch (InvalidKeyException e) {
fail("Should raise an NullPointerException "
+ "in case of null byte array.");
}
try {
new DESKeySpec(new byte [] {1, 2, 3, 4, 5, 6, 7, 8}, 1);
fail("Should raise an InvalidKeyException on a short byte array.");
} catch (NullPointerException e) {
fail("Unexpected NullPointerException was thrown.");
} catch (InvalidKeyException e) {
}
try {
new DESKeySpec(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9}, 1);
} catch (NullPointerException e) {
fail("Unexpected NullPointerException was thrown.");
} catch (InvalidKeyException e) {
fail("Unexpected InvalidKeyException was thrown.");
}