use of org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi in project j2objc by google.
the class KeyPairGeneratorSpiTest method testKeyPairGeneratorSpi01.
/**
* Test for <code>KeyPairGeneratorSpi</code> constructor
* Assertion: constructs KeyPairGeneratorSpi
*/
public void testKeyPairGeneratorSpi01() throws InvalidAlgorithmParameterException, InvalidParameterException {
KeyPairGeneratorSpi keyPairGen = new MyKeyPairGeneratorSpi();
AlgorithmParameterSpec pp = null;
try {
keyPairGen.initialize(pp, null);
fail("UnsupportedOperationException must be thrown");
} catch (UnsupportedOperationException e) {
}
keyPairGen.initialize(pp, new SecureRandom());
keyPairGen.initialize(1024, new SecureRandom());
try {
keyPairGen.initialize(-1024, new SecureRandom());
fail("IllegalArgumentException must be thrown for incorrect keysize");
} catch (IllegalArgumentException e) {
}
try {
keyPairGen.initialize(1024, null);
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
assertEquals("Incorrect exception", e.getMessage(), "Invalid random");
}
KeyPair kp = keyPairGen.generateKeyPair();
assertNull("Not null KeyPair", kp);
}
use of org.apache.harmony.security.tests.support.MyKeyPairGeneratorSpi in project robovm by robovm.
the class KeyPairGeneratorSpiTest method testKeyPairGeneratorSpi01.
/**
* Test for <code>KeyPairGeneratorSpi</code> constructor
* Assertion: constructs KeyPairGeneratorSpi
*/
public void testKeyPairGeneratorSpi01() throws InvalidAlgorithmParameterException, InvalidParameterException {
KeyPairGeneratorSpi keyPairGen = new MyKeyPairGeneratorSpi();
AlgorithmParameterSpec pp = null;
try {
keyPairGen.initialize(pp, null);
fail("UnsupportedOperationException must be thrown");
} catch (UnsupportedOperationException e) {
}
keyPairGen.initialize(pp, new SecureRandom());
keyPairGen.initialize(1024, new SecureRandom());
try {
keyPairGen.initialize(-1024, new SecureRandom());
fail("IllegalArgumentException must be thrown for incorrect keysize");
} catch (IllegalArgumentException e) {
}
try {
keyPairGen.initialize(1024, null);
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
assertEquals("Incorrect exception", e.getMessage(), "Invalid random");
}
KeyPair kp = keyPairGen.generateKeyPair();
assertNull("Not null KeyPair", kp);
}
Aggregations