use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class CollectionCertStoreParametersTest method testClone01.
/**
* Test #1 for <code>clone()</code> method<br>
*/
public final void testClone01() {
Vector<Certificate> certificates = new Vector<Certificate>();
certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
CollectionCertStoreParameters cp1 = new CollectionCertStoreParameters(certificates);
CollectionCertStoreParameters cp2 = (CollectionCertStoreParameters) cp1.clone();
// check that that we have new object
assertTrue(cp1 != cp2);
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class KSTrustedCertificateEntryTest method testToString.
/**
* Test for <codfe>toString()</code> method
* Assertion: returns non null string
*/
public void testToString() {
Certificate cert = new MyCertificate("TEST", new byte[10]);
KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert);
assertNotNull("toString() returns null string", ksTCE.toString());
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class KSTrustedCertificateEntryTest method testGetTrustedCertificate.
/**
* Test for <codfe>getTrustedCertificate()</code> method
* Assertion: returns trusted Certificate from goven entry
*/
public void testGetTrustedCertificate() {
Certificate cert = new MyCertificate("TEST", new byte[10]);
KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert);
assertEquals("Incorrect certificate", cert, ksTCE.getTrustedCertificate());
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class KSPrivateKeyEntryTest method testPrivateKeyEntry01.
/**
* Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
* constructor
* Assertion: throws NullPointerException when privateKey is null
*/
public void testPrivateKeyEntry01() {
//new Certificate[1];
Certificate[] certs = new MyCertificate[1];
PrivateKey pk = null;
try {
new KeyStore.PrivateKeyEntry(pk, certs);
fail("NullPointerException must be thrown when privateKey is null");
} catch (NullPointerException e) {
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class KeyStore4Test method testGetCertificateAlias.
public void testGetCertificateAlias() {
try {
String alias = keyStore.getCertificateAlias(TestKeyStoreSpi.CERT);
assertNotNull("alias is null", alias);
assertEquals("alias is not expected", "certalias", alias);
} catch (KeyStoreException e) {
fail("unexpected exception: " + e);
}
try {
uninitialized.getCertificateAlias(TestKeyStoreSpi.CERT);
fail("expected KeyStoreException");
} catch (KeyStoreException e) {
// ok
}
try {
keyStore.getCertificateAlias(null);
fail("expected NullPointerException");
} catch (KeyStoreException e) {
fail("unexpected exception: " + e);
} catch (NullPointerException e) {
// ok
}
try {
String certificateAlias = keyStore.getCertificateAlias(new MyCertificate("dummy", null));
assertNull("alias was not null", certificateAlias);
} catch (KeyStoreException e) {
fail("unexpected exception: " + e);
}
}
Aggregations