use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateFactory2Test method checkResult.
private void checkResult(CertificateFactory certFactory, boolean mode) throws CertificateException, CRLException {
MyCertificateFactorySpi.putMode(mode);
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
DataInputStream dis = new DataInputStream(bais);
try {
certFactory.generateCertPath(bais);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactory.generateCertPath(dis);
if (!mode) {
fail("CertificateException must be thrown because encodings list is empty");
}
} catch (CertificateException e) {
if (mode) {
fail("Unexpected CertificateFactoryException was thrown");
}
}
try {
certFactory.generateCertPath(bais, "aa");
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactory.generateCertPath(dis, "");
if (mode) {
fail("IllegalArgumentException must be thrown");
}
} catch (IllegalArgumentException e) {
if (!mode) {
fail("Unexpected IllegalArgumentException was thrown");
}
}
certFactory.generateCertPath(dis, "ss");
try {
certFactory.generateCertificate(bais);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactory.generateCertificates(null);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
Certificate cert = certFactory.generateCertificate(dis);
assertNull("Result must be null", cert);
Collection<? extends Certificate> col = certFactory.generateCertificates(dis);
assertNull("Result must be null", col);
try {
certFactory.generateCRL(bais);
fail("CRLException must be thrown");
} catch (CRLException e) {
}
try {
certFactory.generateCRLs(null);
fail("CRLException must be thrown");
} catch (CRLException e) {
}
CRL crl = certFactory.generateCRL(dis);
assertNull("Result must be null", crl);
Collection<? extends CRL> colc = certFactory.generateCRLs(dis);
assertNull("Result must be null", colc);
List<Certificate> list = null;
CertPath cp;
try {
cp = certFactory.generateCertPath(list);
if (mode) {
fail("NullPointerException must be thrown");
} else {
assertNull("Must be null", cp);
}
} catch (NullPointerException e) {
if (!mode) {
fail("Unexpected NullPointerException was thrown");
}
}
Iterator<String> it = certFactory.getCertPathEncodings();
if (mode) {
assertTrue(it.hasNext());
} else {
assertFalse(it.hasNext());
}
}
use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateFactorySpiTest method testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String01.
/**
* Test for <code>engineGenerateCertPath(InputStream, String)</code>
* method. Assertion: generates a <code>CertPath</code> object and
* initializes it with the data read from the <code>InputStream</code>
*/
public void testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String01() {
CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
MyCertificateFactorySpi.putMode(true);
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
DataInputStream dis = new DataInputStream(bais);
try {
certFactorySpi.engineGenerateCertPath(dis, "");
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
// expected
} catch (CertificateException e) {
fail("Unexpected CertificateException " + e.getMessage());
}
try {
assertNull(certFactorySpi.engineGenerateCertPath(dis, "encoding"));
} catch (CertificateException e) {
fail("Unexpected CertificateException " + e.getMessage());
}
}
use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateFactorySpiTest method testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String02.
/**
* Test for <code>engineGenerateCertPath(InputStream, String)</code>
* method. Assertion: generates a <code>CertPath</code> object and
* initializes it with the data read from the <code>InputStream</code>
*/
public void testEngineGenerateCertPathLjava_io_InputStream_Ljava_lang_String02() {
CertificateFactorySpi certFactorySpi = new extCertificateFactorySpi();
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
DataInputStream dis = new DataInputStream(bais);
try {
certFactorySpi.engineGenerateCertPath(dis, "encoding");
fail("UnsupportedOperationException expected");
} catch (UnsupportedOperationException e) {
// expected
} catch (CertificateException e) {
fail("Unexpected CertificateException " + e.getMessage());
}
}
use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateFactorySpiTest method testCertificateFactorySpi02.
/**
* Test for <code>CertificateFactorySpi</code> constructor
* Assertion: constructs CertificateFactorySpi
*/
public void testCertificateFactorySpi02() throws CertificateException, CRLException {
CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
MyCertificateFactorySpi.putMode(true);
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
DataInputStream dis = new DataInputStream(bais);
try {
certFactorySpi.engineGenerateCertPath(bais);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
certFactorySpi.engineGenerateCertPath(dis);
try {
certFactorySpi.engineGenerateCertPath(bais, "aa");
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactorySpi.engineGenerateCertPath(dis, "");
fail("IllegalArgumentException must be thrown");
} catch (IllegalArgumentException e) {
}
certFactorySpi.engineGenerateCertPath(dis, "ss");
try {
certFactorySpi.engineGenerateCertificate(bais);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactorySpi.engineGenerateCertificates(null);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
Certificate cert = certFactorySpi.engineGenerateCertificate(dis);
assertNull("Result must be null", cert);
Collection<? extends Certificate> col = certFactorySpi.engineGenerateCertificates(dis);
assertNull("Result must be null", col);
try {
certFactorySpi.engineGenerateCRL(bais);
fail("CRLException must be thrown");
} catch (CRLException e) {
}
try {
certFactorySpi.engineGenerateCRLs(null);
fail("CRLException must be thrown");
} catch (CRLException e) {
}
CRL crl = certFactorySpi.engineGenerateCRL(dis);
assertNull("Result must be null", crl);
Collection<? extends CRL> colcrl = certFactorySpi.engineGenerateCRLs(dis);
assertNull("Result must be null", colcrl);
List<Certificate> list = null;
try {
certFactorySpi.engineGenerateCertPath(list);
fail("NullPointerException must be thrown");
} catch (NullPointerException e) {
}
Iterator<String> enc = certFactorySpi.engineGetCertPathEncodings();
assertTrue("Incorrect Iterator", enc.hasNext());
}
use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateExceptionTest method testCertificateException06.
/**
* Test for <code>CertificateException(String, Throwable)</code>
* constructor Assertion: constructs CertificateException when
* <code>cause</code> is null <code>msg</code> is null
*/
public void testCertificateException06() {
CertificateException tE = new CertificateException(null, null);
assertNull("getMessage() must return null", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
Aggregations