use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException07.
/**
* Test for <code>CertPathValidatorException(String, Throwable)</code>
* constructor Assertion: constructs CertPathValidatorException when
* <code>cause</code> is null <code>msg</code> is not null
*/
public void testCertPathValidatorException07() {
CertPathValidatorException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new CertPathValidatorException(msgs[i], null);
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 testCertPathValidatorException14.
/**
* Test for
* <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
* constructor Assertion: constructs CertPathValidatorException when
* <code>cause</code> not null <code>msg</code> not null
* <code>certPath</code> not null <code>index</code><
* certPath.getCertificates().size()
*/
public void testCertPathValidatorException14() {
CertPathValidatorException tE;
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);
String getM = tE.getMessage();
String toS = tCause.toString();
if (msgs[i].length() > 0) {
assertTrue("getMessage() must contain ".concat(msgs[i]), getM.indexOf(msgs[i]) != -1);
if (!getM.equals(msgs[i])) {
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);
assertNotNull("getCertPath() must not return null", tE.getCertPath());
assertEquals("getCertPath() must return ".concat(cp.toString()), tE.getCertPath(), cp);
assertEquals("getIndex() must return -1", tE.getIndex(), -1);
} catch (IndexOutOfBoundsException e) {
fail("Unexpected IndexOutOfBoundsException was thrown. " + e.toString());
}
}
}
use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException04.
/**
* Test for <code>CertPathValidatorException(Throwable)</code> constructor
* Assertion: constructs CertPathValidatorException when <code>cause</code>
* is null
*/
public void testCertPathValidatorException04() {
Throwable cause = null;
CertPathValidatorException tE = new CertPathValidatorException(cause);
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 CertPathValidatorExceptionTest method testCertPathValidatorException15.
/**
* Test for <code>getCertPath()</code>. Returns the certification path
* that was being validated when the exception was thrown.
*/
public void testCertPathValidatorException15() {
CertPathValidatorException tE = new CertPathValidatorException();
assertNull("getCertPath() must return null.", tE.getCertPath());
for (int i = 0; i < msgs.length; i++) {
tE = new CertPathValidatorException(msgs[i]);
assertNull("getCertPath() must return null ", tE.getCertPath());
}
Throwable cause = null;
tE = new CertPathValidatorException(cause);
assertNull("getCertPath() must return null.", tE.getCertPath());
tE = new CertPathValidatorException(tCause);
assertNull("getCertPath() must return null.", tE.getCertPath());
for (int i = 0; i < msgs.length; i++) {
tE = new CertPathValidatorException(msgs[i], tCause);
assertNull("getCertPath() must return null", tE.getCertPath());
}
tE = new CertPathValidatorException(null, null, null, -1);
assertNull("getCertPath() must return null", tE.getCertPath());
for (int i = 0; i < msgs.length; i++) {
try {
tE = new CertPathValidatorException(msgs[i], tCause, null, -1);
assertNull("getCertPath() must return null", tE.getCertPath());
} catch (IndexOutOfBoundsException e) {
fail("Unexpected exception: " + e.getMessage());
}
}
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("getCertPath() must not return null", tE.getCertPath());
assertEquals("getCertPath() must return ".concat(cp.toString()), tE.getCertPath(), cp);
} catch (IndexOutOfBoundsException e) {
fail("Unexpected IndexOutOfBoundsException was thrown. " + e.toString());
}
}
}
use of java.security.cert.CertPathValidatorException in project robovm by robovm.
the class CertPathValidatorExceptionTest method testCertPathValidatorException13.
/**
* Test for
* <code>CertPathValidatorException(String, Throwable, CertPath, int)</code>
* constructor Assertion: constructs CertPathValidatorException when
* <code>cause</code> not null <code>msg</code> not null
* <code>certPath</code> not null <code>index</code>< -1 || >=
* certPath.getCertificates().size() throws: IndexOutOfBoundsException
*/
public void testCertPathValidatorException13() {
myCertPath mcp = new myCertPath("X.509", "");
CertPath cp = mcp.get("X.509");
int[] indx = { -2, -100, 0, 1, 100, Integer.MAX_VALUE, Integer.MIN_VALUE };
for (int j = 0; j < indx.length; j++) {
for (int i = 0; i < msgs.length; i++) {
try {
new CertPathValidatorException(msgs[i], tCause, cp, indx[j]);
fail("IndexOutOfBoundsException was not thrown as expected. " + " msg: " + msgs[i] + ", certPath is null and index is " + indx[j]);
} catch (IndexOutOfBoundsException e) {
}
}
}
}
Aggregations