use of org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi in project robovm by robovm.
the class CertificateFactorySpiTest method testEngineGenerateCertPathLjava_io_InputStream01.
/**
* Test for <code>engineGenerateCertPath(InputStream)</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_InputStream01() {
CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
MyCertificateFactorySpi.putMode(true);
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
DataInputStream dis = new DataInputStream(bais);
try {
assertNull(certFactorySpi.engineGenerateCertPath(dis));
} catch (CertificateException e) {
fail("Unexpected CertificateException " + e.getMessage());
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi in project robovm by robovm.
the class CertificateFactorySpiTest method testCertificateFactorySpi03.
/**
* Test for <code>CertificateFactorySpi</code> constructor
* Assertion: constructs CertificateFactorySpi
*/
public void testCertificateFactorySpi03() throws CertificateException, CRLException {
CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
MyCertificateFactorySpi.putMode(false);
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
DataInputStream dis = new DataInputStream(bais);
try {
certFactorySpi.engineGenerateCertPath(bais);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactorySpi.engineGenerateCertPath(dis);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
try {
certFactorySpi.engineGenerateCertPath(bais, "aa");
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
certFactorySpi.engineGenerateCertPath(dis, "");
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;
certFactorySpi.engineGenerateCertPath(list);
Iterator<String> enc = certFactorySpi.engineGetCertPathEncodings();
assertFalse("Incorrect Iterator", enc.hasNext());
}
Aggregations