use of javax.security.cert.CertificateNotYetValidException in project robovm by robovm.
the class CertificateNotYetValidExceptionTest method testCertificateNotYetValidException02.
/**
* Test for <code>CertificateNotYetValidException(String)</code>
* constructor Assertion: constructs CertificateNotYetValidException with
* detail message msg. Parameter <code>msg</code> is not null.
*/
public void testCertificateNotYetValidException02() {
CertificateNotYetValidException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new CertificateNotYetValidException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of javax.security.cert.CertificateNotYetValidException in project robovm by robovm.
the class CertificateNotYetValidExceptionTest method testCertificateNotYetValidException01.
/**
* Test for <code>CertificateNotYetValidException()</code> constructor
* Assertion: constructs CertificateNotYetValidException with no detail
* message
*/
public void testCertificateNotYetValidException01() {
CertificateNotYetValidException tE = new CertificateNotYetValidException();
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of javax.security.cert.CertificateNotYetValidException in project robovm by robovm.
the class X509CertificateTest method testCheckValidity2.
/**
* checkValidity(Date date) method testing.
* @throws CertificateNotYetValidException
* @throws CertificateExpiredException
*/
public void testCheckValidity2() throws CertificateNotYetValidException, CertificateExpiredException {
if (this.cert == null) {
// Test can not be applied.
return;
}
Date[] date = new Date[8];
Calendar calendar = Calendar.getInstance();
for (int i = 0; i < date.length; i++) {
calendar.set(i * 500, Calendar.JANUARY, 1);
date[i] = calendar.getTime();
}
Date nb_date = tbt_cert.getNotBefore();
Date na_date = tbt_cert.getNotAfter();
for (int i = 0; i < date.length; i++) {
try {
tbt_cert.checkValidity(date[i]);
assertFalse("CertificateExpiredException expected", date[i].compareTo(na_date) > 0);
assertFalse("CertificateNotYetValidException expected", date[i].compareTo(nb_date) < 0);
} catch (CertificateExpiredException e) {
assertTrue("Unexpected CertificateExpiredException was thrown", date[i].compareTo(na_date) > 0);
} catch (CertificateNotYetValidException e) {
assertTrue("Unexpected CertificateNotYetValidException " + "was thrown", date[i].compareTo(nb_date) < 0);
}
}
Calendar calendarNow = Calendar.getInstance();
try {
tbt_cert.checkValidity(calendarNow.getTime());
} catch (CertificateExpiredException e) {
//ok
}
Calendar calendarPast = GregorianCalendar.getInstance();
calendarPast.clear();
try {
tbt_cert.checkValidity(calendarPast.getTime());
} catch (CertificateNotYetValidException e) {
//ok
}
}
use of javax.security.cert.CertificateNotYetValidException in project robovm by robovm.
the class X509CertificateTest method testCheckValidity1.
/**
* checkValidity() method testing.
* @throws CertificateNotYetValidException
* @throws CertificateExpiredException
* @throws java.security.cert.CertificateExpiredException
* @throws java.security.cert.CertificateNotYetValidException
*/
public void testCheckValidity1() throws CertificateExpiredException, CertificateNotYetValidException, java.security.cert.CertificateExpiredException, java.security.cert.CertificateNotYetValidException {
if (this.cert == null) {
// Test can not be applied.
return;
}
Date date = new Date();
Date nb_date = tbt_cert.getNotBefore();
Date na_date = tbt_cert.getNotAfter();
try {
tbt_cert.checkValidity();
assertFalse("CertificateExpiredException expected", date.compareTo(na_date) > 0);
assertFalse("CertificateNotYetValidException expected", date.compareTo(nb_date) < 0);
} catch (CertificateExpiredException e) {
assertTrue("Unexpected CertificateExpiredException was thrown", date.compareTo(na_date) > 0);
} catch (CertificateNotYetValidException e) {
assertTrue("Unexpected CertificateNotYetValidException was thrown", date.compareTo(nb_date) < 0);
}
try {
tbt_cert.checkValidity();
} catch (CertificateExpiredException e) {
// ok
}
try {
cert.checkValidity();
} catch (java.security.cert.CertificateExpiredException e) {
// ok
}
}
use of javax.security.cert.CertificateNotYetValidException in project j2objc by google.
the class CertificateNotYetValidExceptionTest method testCertificateNotYetValidException02.
/**
* Test for <code>CertificateNotYetValidException(String)</code>
* constructor Assertion: constructs CertificateNotYetValidException with
* detail message msg. Parameter <code>msg</code> is not null.
*/
public void testCertificateNotYetValidException02() {
CertificateNotYetValidException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new CertificateNotYetValidException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
Aggregations