Search in sources :

Example 1 with MyAlgorithmParameterGeneratorSpi

use of org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi in project robovm by robovm.

the class myAlgPG method testConstructor.

/**
     * Test for <code>AlgorithmParameterGenerator</code> constructor
     * Assertion: returns AlgorithmParameterGenerator object
     */
public void testConstructor() throws NoSuchAlgorithmException {
    if (!DSASupported) {
        fail(validAlgName + " algorithm is not supported");
        return;
    }
    AlgorithmParameterGeneratorSpi spi = new MyAlgorithmParameterGeneratorSpi();
    AlgorithmParameterGenerator apg = new myAlgPG(spi, validProvider, validAlgName);
    assertEquals("Incorrect algorithm", apg.getAlgorithm(), validAlgName);
    assertEquals("Incorrect provider", apg.getProvider(), validProvider);
    try {
        apg.init(-10, null);
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
    apg = new myAlgPG(null, null, null);
    assertNull("Incorrect algorithm", apg.getAlgorithm());
    assertNull("Incorrect provider", apg.getProvider());
    try {
        apg.init(-10, null);
        fail("NullPointerException must be thrown");
    } catch (NullPointerException e) {
    }
}
Also used : MyAlgorithmParameterGeneratorSpi(org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi) AlgorithmParameterGenerator(java.security.AlgorithmParameterGenerator) AlgorithmParameterGeneratorSpi(java.security.AlgorithmParameterGeneratorSpi) MyAlgorithmParameterGeneratorSpi(org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi)

Example 2 with MyAlgorithmParameterGeneratorSpi

use of org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi in project robovm by robovm.

the class AlgorithmParameterGeneratorSpiTest method testAlgorithmParameterGeneratorSpi01.

/**
     * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor
     * Assertion: constructs AlgorithmParameterGeneratorSpi
     */
public void testAlgorithmParameterGeneratorSpi01() throws InvalidAlgorithmParameterException {
    MyAlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi();
    AlgorithmParameters param = algParGen.engineGenerateParameters();
    assertNull("Not null parameters", param);
    AlgorithmParameterSpec pp = null;
    algParGen.engineInit(pp, new SecureRandom());
    try {
        algParGen.engineInit(pp, null);
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
    algParGen.engineInit(0, null);
    algParGen.engineInit(0, new SecureRandom());
    try {
        algParGen.engineInit(-10, null);
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
    try {
        algParGen.engineInit(-10, new SecureRandom());
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
}
Also used : MyAlgorithmParameterGeneratorSpi(org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi) SecureRandom(java.security.SecureRandom) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec) AlgorithmParameters(java.security.AlgorithmParameters)

Example 3 with MyAlgorithmParameterGeneratorSpi

use of org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi in project j2objc by google.

the class AlgorithmParameterGeneratorSpiTest method testAlgorithmParameterGeneratorSpi01.

/**
     * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor
     * Assertion: constructs AlgorithmParameterGeneratorSpi
     */
public void testAlgorithmParameterGeneratorSpi01() throws InvalidAlgorithmParameterException {
    MyAlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi();
    AlgorithmParameters param = algParGen.engineGenerateParameters();
    assertNull("Not null parameters", param);
    AlgorithmParameterSpec pp = null;
    algParGen.engineInit(pp, new SecureRandom());
    try {
        algParGen.engineInit(pp, null);
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
    algParGen.engineInit(0, null);
    algParGen.engineInit(0, new SecureRandom());
    try {
        algParGen.engineInit(-10, null);
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
    try {
        algParGen.engineInit(-10, new SecureRandom());
        fail("IllegalArgumentException must be thrown");
    } catch (IllegalArgumentException e) {
    }
}
Also used : MyAlgorithmParameterGeneratorSpi(org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi) SecureRandom(java.security.SecureRandom) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec) AlgorithmParameters(java.security.AlgorithmParameters)

Aggregations

MyAlgorithmParameterGeneratorSpi (org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi)3 AlgorithmParameters (java.security.AlgorithmParameters)2 SecureRandom (java.security.SecureRandom)2 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)2 AlgorithmParameterGenerator (java.security.AlgorithmParameterGenerator)1 AlgorithmParameterGeneratorSpi (java.security.AlgorithmParameterGeneratorSpi)1