use of java.security.cert.CRLException in project robovm by robovm.
the class CRLExceptionTest method testCRLException07.
/**
* Test for <code>CRLException(String, Throwable)</code> constructor
* Assertion: constructs CRLException when <code>cause</code> is null
* <code>msg</code> is not null
*/
public void testCRLException07() {
CRLException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new CRLException(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.CRLException in project robovm by robovm.
the class CRLExceptionTest method testCRLException04.
/**
* Test for <code>CRLException(Throwable)</code> constructor Assertion:
* constructs CRLException when <code>cause</code> is null
*/
public void testCRLException04() {
Throwable cause = null;
CRLException tE = new CRLException(cause);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.cert.CRLException in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory17.
/**
* Test for <code>CertificateFactory</code> constructor
* Assertion: returns CertificateFactory object
*/
public void testCertificateFactory17() throws CRLException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactorySpi spi = new MyCertificateFactorySpi();
CertificateFactory cf = new myCertificateFactory(spi, defaultProvider, defaultType);
assertEquals("Incorrect type", cf.getType(), defaultType);
assertEquals("Incorrect provider", cf.getProvider(), defaultProvider);
try {
cf.generateCRLs(null);
fail("CRLException must be thrown");
} catch (CRLException e) {
}
cf = new myCertificateFactory(null, null, null);
assertNull("Incorrect type", cf.getType());
assertNull("Incorrect provider", cf.getProvider());
try {
cf.generateCRLs(null);
fail("NullPointerException must be thrown");
} catch (NullPointerException e) {
}
}
use of java.security.cert.CRLException in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory10.
/**
* Test for <code>generateCertificate(InputStream inStream)</code>
* <code>generateCertificates(InputStream inStream)</code>
* <code>generateCRL(InputStream inStream)</code>
* <code>generateCRLs(InputStream inStream)</code>
* methods
* Assertion: throw CertificateException and CRLException when
* inStream is null or empty
*/
public void testCertificateFactory10() {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
byte[] bb = {};
InputStream is = new ByteArrayInputStream(bb);
Collection<?> colCer;
Collection<?> colCrl;
for (int i = 0; i < certFs.length; i++) {
try {
certFs[i].generateCertificate(null);
fail("generateCertificate must thrown CertificateException or NullPointerEXception when input stream is null");
} catch (CertificateException e) {
} catch (NullPointerException e) {
}
is = new ByteArrayInputStream(bb);
try {
certFs[i].generateCertificates(null);
fail("generateCertificates must throw CertificateException or NullPointerException when input stream is null");
} catch (CertificateException e) {
} catch (NullPointerException e) {
}
is = new ByteArrayInputStream(bb);
try {
certFs[i].generateCertificate(is);
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(bb);
try {
colCer = certFs[i].generateCertificates(is);
if (colCer != null) {
assertTrue("Not empty certificate collection", colCer.isEmpty());
}
} catch (CertificateException e) {
}
}
for (int i = 0; i < certFs.length; i++) {
try {
certFs[i].generateCRL(null);
} catch (CRLException e) {
} catch (NullPointerException e) {
}
try {
colCrl = certFs[i].generateCRLs(null);
if (colCrl != null) {
assertTrue("Not empty CRL collection was returned from null stream", colCrl.isEmpty());
}
} catch (CRLException e) {
} catch (NullPointerException e) {
}
is = new ByteArrayInputStream(bb);
try {
certFs[i].generateCRL(is);
} catch (CRLException e) {
}
is = new ByteArrayInputStream(bb);
try {
certFs[i].generateCRLs(is);
colCrl = certFs[i].generateCRLs(null);
if (colCrl != null) {
assertTrue("Not empty CRL collection was returned from empty stream", colCrl.isEmpty());
}
} catch (CRLException e) {
}
}
}
use of java.security.cert.CRLException in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory11.
/*
* Test for <code> generateCertificate(InputStream inStream) </code><code>
* generateCertificates(InputStream inStream) </code><code>
* generateCRL(InputStream inStream) </code><code>
* generateCRLs(InputStream inStream) </code>
* methods
* Assertion: throw CertificateException and CRLException when inStream
* contains incompatible datas
*/
public void testCertificateFactory11() throws IOException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
MyCertificate mc = createMC();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(mc);
oos.flush();
oos.close();
Certificate cer;
Collection<?> colCer;
CRL crl;
Collection<?> colCrl;
byte[] arr = os.toByteArray();
ByteArrayInputStream is;
for (int i = 0; i < certFs.length; i++) {
is = new ByteArrayInputStream(arr);
try {
cer = certFs[i].generateCertificate(is);
assertNull("Not null certificate was created", cer);
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCer = certFs[i].generateCertificates(is);
if (colCer != null) {
assertTrue("Not empty certificate Collection was created", colCer.isEmpty());
}
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
crl = certFs[i].generateCRL(is);
assertNull("Not null CRL was created", crl);
} catch (CRLException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCrl = certFs[i].generateCRLs(is);
if (colCrl != null) {
assertTrue("Not empty CRL Collection was created", colCrl.isEmpty());
}
} catch (CRLException e) {
}
}
}
Aggregations