* Test for <code>KeyManagerFactorySpi</code> constructor
* Assertion: constructs KeyManagerFactorySpi
*/
public void testKeyManagerFactorySpi01()
throws Exception {
KeyManagerFactorySpi kmfSpi = new MyKeyManagerFactorySpi();
assertNull(kmfSpi.engineGetKeyManagers());
KeyStore kStore = null;
ManagerFactoryParameters mfp = null;
char[] pass = { 'a', 'b', 'c' };
try {
kmfSpi.engineInit(kStore, null);
fail("KeyStoreException must be thrown");
} catch (KeyStoreException e) {
}
try {
kmfSpi.engineInit(kStore, pass);
fail("UnrecoverableKeyException must be thrown");
} catch (UnrecoverableKeyException e) {
}
try {
kmfSpi.engineInit(mfp);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
assertNull("getKeyManagers() should return null object",
kmfSpi.engineGetKeyManagers());
try {
kStore = KeyStore.getInstance(KeyStore.getDefaultType());
kStore.load(null, null);
} catch (KeyStoreException e) {
fail("default keystore type is not supported");
return;
}
kmfSpi.engineInit(kStore, pass);
mfp = new MyKeyManagerFactorySpi.Parameters(kStore, null);
try {
kmfSpi.engineInit(mfp);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
mfp = new MyKeyManagerFactorySpi.Parameters(kStore, pass);
kmfSpi.engineInit(mfp);
}