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) {
}
}
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) {
}
}
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) {
}
}
Aggregations