use of org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi in project robovm by robovm.
the class CertificateFactorySpiTest method testEngineGenerateCertPathLJava_util_List01.
/**
* Test for <code>engineGenerateCertPath(List<? extends Certificate>)</code>
* method Assertion: generates a <code>CertPath</code> object and
* initializes it with a <code>List</code> of <code>Certificates</code>
*/
public void testEngineGenerateCertPathLJava_util_List01() {
CertificateFactorySpi certFactorySpi = new MyCertificateFactorySpi();
MyCertificateFactorySpi.putMode(true);
List<Certificate> list = new ArrayList<Certificate>();
try {
assertNull(certFactorySpi.engineGenerateCertPath(list));
} catch (CertificateException e) {
fail("Unexpected CertificateException " + e.getMessage());
}
try {
certFactorySpi.engineGenerateCertPath((List<? extends Certificate>) null);
fail("expected NullPointerException");
} catch (NullPointerException e) {
// ok
} 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 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 org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi 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 org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory19.
@SuppressWarnings("cast")
public void testCertificateFactory19() {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactorySpi spi = new MyCertificateFactorySpi();
myCertificateFactory cf;
try {
cf = new myCertificateFactory(spi, defaultProvider, defaultType);
assertEquals("Incorrect type", cf.getType(), defaultType);
assertEquals("Incorrect provider", cf.getProvider(), defaultProvider);
assertTrue(cf instanceof CertificateFactory);
} catch (Exception e) {
fail("Unexpected exception" + e);
}
try {
cf = new myCertificateFactory(null, null, null);
} catch (Exception e) {
fail("Unexpected exception" + e);
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificateFactorySpi 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) {
}
}
Aggregations