Search in sources :

Example 1 with ExemptionMechanismSpi

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

the class ExemptionMechanismTest method testExemptionMechanism.

/**
     * Test for <code>ExemptionMechanism</code> constructor
     * Assertion: creates new object using provider and mechanism name
     */
public void testExemptionMechanism() throws Exception {
    Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", srvExemptionMechanism.concat(".").concat(defaultAlg), ExemptionMechanismProviderClass);
    ExemptionMechanismSpi spi = new MyExemptionMechanismSpi();
    ExemptionMechanism em = new ExemptionMechanism(spi, mProv, defaultAlg) {
    };
    assertEquals("Incorrect provider", em.getProvider(), mProv);
    assertEquals("Incorrect algorithm", em.getName(), defaultAlg);
    try {
        em.init(null);
        fail("InvalidKeyException must be thrown");
    } catch (InvalidKeyException e) {
    }
    try {
        em.getOutputSize(100);
        fail("IllegalStateException must be thrown");
    } catch (IllegalStateException e) {
    }
    em = new ExemptionMechanism(null, null, null) {
    };
    assertNull("Incorrect mechanism", em.getName());
    assertNull("Incorrect provider", em.getProvider());
    try {
        em.init(null);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
    try {
        em.getOutputSize(100);
        fail("IllegalStateException must be thrown");
    } catch (IllegalStateException e) {
    }
}
Also used : ExemptionMechanismSpi(javax.crypto.ExemptionMechanismSpi) MyExemptionMechanismSpi(org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi) SpiEngUtils(org.apache.harmony.security.tests.support.SpiEngUtils) InvalidKeyException(java.security.InvalidKeyException) MyExemptionMechanismSpi(org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi) ExemptionMechanism(javax.crypto.ExemptionMechanism) Provider(java.security.Provider)

Aggregations

InvalidKeyException (java.security.InvalidKeyException)1 Provider (java.security.Provider)1 ExemptionMechanism (javax.crypto.ExemptionMechanism)1 ExemptionMechanismSpi (javax.crypto.ExemptionMechanismSpi)1 MyExemptionMechanismSpi (org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi)1 SpiEngUtils (org.apache.harmony.security.tests.support.SpiEngUtils)1