use of java.security.AlgorithmParameterGenerator in project robovm by robovm.
the class myAlgPG method testAlgorithmParameterGenerator10.
/**
* Test for <code>generateParameters()</code> method
* Assertion: returns AlgorithmParameters object
*/
public void testAlgorithmParameterGenerator10() throws NoSuchAlgorithmException {
if (!DSASupported) {
fail(validAlgName + " algorithm is not supported");
return;
}
AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance(validAlgName);
apg.init(512);
AlgorithmParameters ap = apg.generateParameters();
assertEquals("Incorrect algorithm", ap.getAlgorithm().toUpperCase(), apg.getAlgorithm().toUpperCase());
}
use of java.security.AlgorithmParameterGenerator in project robovm by robovm.
the class myAlgPG method testAlgorithmParameterGenerator09.
/**
* Test for <code>getInstance(String algorithm, Provider provider)</code>
* method
* Assertion: returns AlgorithmParameterGenerator object
*/
public void testAlgorithmParameterGenerator09() throws NoSuchAlgorithmException {
if (!DSASupported) {
fail(validAlgName + " algorithm is not supported");
return;
}
AlgorithmParameterGenerator apg;
for (int i = 0; i < algs.length; i++) {
apg = AlgorithmParameterGenerator.getInstance(algs[i], validProvider);
assertEquals("Incorrect algorithm", apg.getAlgorithm(), algs[i]);
assertEquals("Incorrect provider", apg.getProvider(), validProvider);
}
}
use of java.security.AlgorithmParameterGenerator in project robovm by robovm.
the class myAlgPG method testAlgorithmParameterGenerator06.
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
* method
* Assertion: return AlgorithmParameterGenerator
*/
public void testAlgorithmParameterGenerator06() throws NoSuchAlgorithmException, NoSuchProviderException {
if (!DSASupported) {
fail(validAlgName + " algorithm is not supported");
return;
}
AlgorithmParameterGenerator apg;
for (int i = 0; i < algs.length; i++) {
apg = AlgorithmParameterGenerator.getInstance(algs[i], validProviderName);
assertEquals("Incorrect algorithm", algs[i], apg.getAlgorithm());
assertEquals("Incorrect provider", apg.getProvider().getName(), validProviderName);
}
}
use of java.security.AlgorithmParameterGenerator in project robovm by robovm.
the class myAlgPG method testAlgorithmParameterGenerator12.
/**
* Test for <code>init(AlgorithmParameterSpec param)</code> and
* <code>init(AlgorithmParameterSpec param, SecureRandom random<code>
* methods
* Assertion: throws InvalidAlgorithmParameterException when param is null
*/
public void testAlgorithmParameterGenerator12() {
if (!DSASupported) {
fail(validAlgName + " algorithm is not supported");
return;
}
SecureRandom random = new SecureRandom();
AlgorithmParameterSpec aps = null;
AlgorithmParameterGenerator[] apgs = createAPGen();
assertNotNull("AlgorithmParameterGenerator objects were not created", apgs);
for (int i = 0; i < apgs.length; i++) {
try {
apgs[i].init(aps);
fail("InvalidAlgorithmParameterException expected for null argument.");
} catch (InvalidAlgorithmParameterException e) {
//expected
}
try {
apgs[i].init(aps, random);
fail("InvalidAlgorithmParameterException expected for null argument.");
} catch (InvalidAlgorithmParameterException e) {
//expected
}
}
}
use of java.security.AlgorithmParameterGenerator 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) {
}
}
Aggregations