use of java.security.NoSuchProviderException in project robovm by robovm.
the class CertPathValidator2Test method testGetInstance02.
/**
* Test for <code>getInstance(String algorithm, String provider)</code>
* method Assertions: throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not available throws
* IllegalArgumentException when provider is null or empty; throws
* NoSuchProviderException when provider is available; returns
* CertPathValidator object
*/
public void testGetInstance02() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, InvalidAlgorithmParameterException, CertPathValidatorException {
try {
CertPathValidator.getInstance(null, mProv.getName());
fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
} catch (NullPointerException e) {
} catch (NoSuchAlgorithmException e) {
}
for (int i = 0; i < invalidValues.length; i++) {
try {
CertPathValidator.getInstance(invalidValues[i], mProv.getName());
fail("NoSuchAlgorithmException must be thrown (type: ".concat(invalidValues[i]).concat(")"));
} catch (NoSuchAlgorithmException e) {
}
}
String prov = null;
for (int i = 0; i < validValues.length; i++) {
try {
CertPathValidator.getInstance(validValues[i], prov);
fail("IllegalArgumentException must be thrown when provider is null (type: ".concat(validValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
try {
CertPathValidator.getInstance(validValues[i], "");
fail("IllegalArgumentException must be thrown when provider is empty (type: ".concat(validValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
}
for (int i = 0; i < validValues.length; i++) {
for (int j = 1; j < invalidValues.length; j++) {
try {
CertPathValidator.getInstance(validValues[i], invalidValues[j]);
fail("NoSuchProviderException must be thrown (type: ".concat(validValues[i]).concat(" provider: ").concat(invalidValues[j]).concat(")"));
} catch (NoSuchProviderException e) {
}
}
}
CertPathValidator cerPV;
for (int i = 0; i < validValues.length; i++) {
cerPV = CertPathValidator.getInstance(validValues[i], mProv.getName());
assertEquals("Incorrect type", cerPV.getAlgorithm(), validValues[i]);
assertEquals("Incorrect provider", cerPV.getProvider().getName(), mProv.getName());
checkResult(cerPV);
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory18.
/**
* Test for <code>getType()</code> method
*/
public void testCertificateFactory18() throws CertificateException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
for (int i = 0; i < validValues.length; i++) {
try {
CertificateFactory certF = CertificateFactory.getInstance(validValues[i]);
assertEquals("Incorrect type: ", validValues[i], certF.getType());
certF = CertificateFactory.getInstance(validValues[i], defaultProviderName);
assertEquals("Incorrect type", certF.getType(), validValues[i]);
certF = CertificateFactory.getInstance(validValues[i], defaultProvider);
assertEquals("Incorrect provider", certF.getProvider(), defaultProvider);
assertEquals("Incorrect type", certF.getType(), validValues[i]);
} catch (NoSuchProviderException e) {
fail("Unexpected NoSuchProviderException " + e.getMessage());
}
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class invalidParams method testCertPathValidator14.
/**
* Test for <code>getProvider()</code> method
*/
public void testCertPathValidator14() throws NoSuchAlgorithmException {
if (!PKIXSupport) {
fail(NotSupportMsg);
return;
}
CertPathValidator certPV;
for (int i = 0; i < validValues.length; i++) {
try {
certPV = CertPathValidator.getInstance(validValues[i], defaultProviderName);
assertEquals("Incorrect provider", certPV.getProvider(), defaultProvider);
} catch (NoSuchProviderException e) {
fail("Unexpected NoSuchProviderException " + e.getMessage());
}
certPV = CertPathValidator.getInstance(validValues[i], defaultProvider);
assertEquals("Incorrect provider", certPV.getProvider(), defaultProvider);
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class KeyFactoryTest method testGetInstanceStringString.
@SuppressWarnings("unchecked")
public void testGetInstanceStringString() {
try {
KeyFactory factory = KeyFactory.getInstance(TEST_KEYFACTORY_NAME, TEST_PROVIDER_NAME);
assertNotNull(factory);
} catch (NoSuchAlgorithmException e) {
fail("unexpected exception: " + e);
} catch (NoSuchProviderException e) {
fail("unexpected exception: " + e);
}
String[][] combinations = { { "UnknownKeyFactory", TEST_PROVIDER_NAME }, { TEST_KEYFACTORY_NAME, "UnknownProvider" }, { TEST_KEYFACTORY_NAME, existingProvider.getName() }, { null, TEST_PROVIDER_NAME }, { TEST_KEYFACTORY_NAME, null }, { null, null } };
Class[] exceptions = { NoSuchAlgorithmException.class, NoSuchProviderException.class, NoSuchAlgorithmException.class, NullPointerException.class, IllegalArgumentException.class, IllegalArgumentException.class };
for (int i = 0; i < combinations.length; i++) {
String[] combination = combinations[i];
String message = "getInstance(\"" + combination[0] + "\", \"" + combination[1] + "\")";
exceptionThrown = false;
try {
KeyFactory.getInstance(combination[0], combination[1]);
} catch (Exception e) {
checkException(message, e, exceptions[i]);
} finally {
checkException(message, null, exceptions[i]);
}
}
}
use of java.security.NoSuchProviderException in project robovm by robovm.
the class CertPathBuilder2Test method testGetInstance02.
/**
* Test for <code>getInstance(String algorithm, String provider)</code> method
* Assertions:
* throws NullPointerException when algorithm is null
* throws NoSuchAlgorithmException when algorithm is not correct
* throws IllegalArgumentException when provider is null or empty;
* throws NoSuchProviderException when provider is available;
* returns CertPathBuilder object
*/
public void testGetInstance02() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, InvalidAlgorithmParameterException, CertPathBuilderException {
try {
CertPathBuilder.getInstance(null, mProv.getName());
fail("NullPointerException or NoSuchAlgorithmException must be thrown when algorithm is null");
} catch (NullPointerException e) {
} catch (NoSuchAlgorithmException e) {
}
for (int i = 0; i < invalidValues.length; i++) {
try {
CertPathBuilder.getInstance(invalidValues[i], mProv.getName());
fail("NoSuchAlgorithmException must be thrown (type: ".concat(invalidValues[i]).concat(")"));
} catch (NoSuchAlgorithmException e) {
}
}
String prov = null;
for (int i = 0; i < validValues.length; i++) {
try {
CertPathBuilder.getInstance(validValues[i], prov);
fail("IllegalArgumentException must be thrown when provider is null (type: ".concat(validValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
try {
CertPathBuilder.getInstance(validValues[i], "");
fail("IllegalArgumentException must be thrown when provider is empty (type: ".concat(validValues[i]).concat(")"));
} catch (IllegalArgumentException e) {
}
}
for (int i = 0; i < validValues.length; i++) {
for (int j = 1; j < invalidValues.length; j++) {
try {
CertPathBuilder.getInstance(validValues[i], invalidValues[j]);
fail("NoSuchProviderException must be thrown (type: ".concat(validValues[i]).concat(" provider: ").concat(invalidValues[j]).concat(")"));
} catch (NoSuchProviderException e) {
}
}
}
CertPathBuilder cerPB;
for (int i = 0; i < validValues.length; i++) {
cerPB = CertPathBuilder.getInstance(validValues[i], mProv.getName());
assertEquals("Incorrect type", cerPB.getAlgorithm(), validValues[i]);
assertEquals("Incorrect provider", cerPB.getProvider().getName(), mProv.getName());
checkResult(cerPB);
}
}
Aggregations