use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException16.
/**
* Test for <code>getIndex()</code>. Returns the index of the certificate
* in the certification path that caused the exception to be thrown. Note
* that the list of certificates in a CertPath is zero based. If no index
* has been set, -1 is returned.
*/
public void testCertPathValidatorException16() {
CertPathValidatorException tE = new CertPathValidatorException();
assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
for (int i = 0; i < msgs.length; i++) {
tE = new CertPathValidatorException(msgs[i]);
assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
}
Throwable cause = null;
tE = new CertPathValidatorException(cause);
assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
tE = new CertPathValidatorException(tCause);
assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
for (int i = 0; i < msgs.length; i++) {
tE = new CertPathValidatorException(msgs[i], tCause);
assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
}
tE = new CertPathValidatorException(null, null, null, -1);
assertEquals("getIndex() must be equals -1", -1, tE.getIndex());
myCertPath mcp = new myCertPath("X.509", "");
CertPath cp = mcp.get("X.509");
for (int i = 0; i < msgs.length; i++) {
try {
tE = new CertPathValidatorException(msgs[i], tCause, cp, -1);
assertNotNull("getIndex() must not return null", tE.getCertPath());
assertEquals("getIndex() must return ".concat(cp.toString()), tE.getCertPath(), cp);
} catch (IndexOutOfBoundsException e) {
fail("Unexpected IndexOutOfBoundsException was thrown. " + e.getMessage());
}
}
}
use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException02.
/**
* Test for <code>CertPathValidatorException(String)</code> constructor
* Assertion: constructs CertPathValidatorException with detail message msg.
* Parameter <code>msg</code> is not null.
*/
public void testCertPathValidatorException02() {
CertPathValidatorException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new CertPathValidatorException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException05.
/**
* Test for <code>CertPathValidatorException(Throwable)</code> constructor
* Assertion: constructs CertPathValidatorException when <code>cause</code>
* is not null
*/
public void testCertPathValidatorException05() {
CertPathValidatorException tE = new CertPathValidatorException(tCause);
if (tE.getMessage() != null) {
String toS = tCause.toString();
String getM = tE.getMessage();
assertTrue("getMessage() should contain ".concat(toS), (getM.indexOf(toS) != -1));
}
assertNotNull("getCause() must not return null", tE.getCause());
assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
}
use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException06.
/**
* Test for <code>CertPathValidatorException(String, Throwable)</code>
* constructor Assertion: constructs CertPathValidatorException when
* <code>cause</code> is null <code>msg</code> is null
*/
public void testCertPathValidatorException06() {
CertPathValidatorException tE = new CertPathValidatorException(null, null);
assertNull("getMessage() must return null", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorSpiTest method testCertPathValidatorSpi01.
/**
* Test for <code>CertPathValidatorSpi</code> constructor Assertion:
* constructs CertPathValidatorSpi
*/
public void testCertPathValidatorSpi01() throws CertPathValidatorException, InvalidAlgorithmParameterException {
CertPathValidatorSpi certPathValid = new MyCertPathValidatorSpi();
CertPathParameters params = null;
CertPath certPath = null;
CertPathValidatorResult cpvResult = certPathValid.engineValidate(certPath, params);
assertNull("Not null CertPathValidatorResult", cpvResult);
try {
certPathValid.engineValidate(certPath, params);
fail("CertPathValidatorException must be thrown");
} catch (CertPathValidatorException e) {
}
try {
certPathValid.engineValidate(certPath, params);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
}
Aggregations