Search in sources :

Example 1 with SecretKeyFactorySpi

use of javax.crypto.SecretKeyFactorySpi in project robovm by robovm.

the class mySecretKeyFactory method testSecretKeyFactory01.

/**
     * Test for <code>SecretKeyFactory</code> constructor
     * Assertion: returns SecretKeyFactory object
     */
public void testSecretKeyFactory01() throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
    if (!DEFSupported) {
        fail(NotSupportMsg);
        return;
    }
    SecretKeyFactorySpi spi = new MySecretKeyFactorySpi();
    SecretKeyFactory secKF = new mySecretKeyFactory(spi, defaultProvider, defaultAlgorithm);
    assertEquals("Incorrect algorithm", secKF.getAlgorithm(), defaultAlgorithm);
    assertEquals("Incorrect provider", secKF.getProvider(), defaultProvider);
    assertNull("Incorrect result", secKF.generateSecret(null));
    assertNull("Incorrect result", secKF.getKeySpec(null, null));
    assertNull("Incorrect result", secKF.translateKey(null));
    secKF = new mySecretKeyFactory(null, null, null);
    assertNull("Algorithm must be null", secKF.getAlgorithm());
    assertNull("Provider must be null", secKF.getProvider());
    try {
        secKF.translateKey(null);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
}
Also used : MySecretKeyFactorySpi(org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi) SecretKeyFactorySpi(javax.crypto.SecretKeyFactorySpi) MySecretKeyFactorySpi(org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi) SecretKeyFactory(javax.crypto.SecretKeyFactory)

Aggregations

SecretKeyFactory (javax.crypto.SecretKeyFactory)1 SecretKeyFactorySpi (javax.crypto.SecretKeyFactorySpi)1 MySecretKeyFactorySpi (org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi)1