use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.
the class IdentityTest method testGetPublicKey.
/**
* verify Identity.getPublicKey() returns public key
*/
public void testGetPublicKey() throws Exception {
Identity i = new IdentityStub("testGetPublicKey");
assertNull(i.getPublicKey());
PublicKey pk = new PublicKeyStub("kkk", "Identity.testGetPublicKey", null);
i.setPublicKey(pk);
assertSame(pk, i.getPublicKey());
}
use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.
the class IdentityTest method testIdentityStringIdentityScope.
/**
* verify Identity(String, IdentityScope) creates instance with given name and in give scope
*/
public void testIdentityStringIdentityScope() throws Exception {
IdentityScope s = IdentityScope.getSystemScope();
Identity i = new IdentityStub("iii2", s);
assertNotNull(i);
assertEquals("iii2", i.getName());
assertSame(s, i.getScope());
assertSame(i, s.getIdentity(i.getName()));
}
use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.
the class IdentityTest method testGetInfo.
public void testGetInfo() {
Identity i = new IdentityStub("testGetInfo");
i.setInfo("some info");
assertEquals("some info", i.getInfo());
}
use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.
the class IdentityTest method testCertificates.
//
// Commented out since there will no be fix for the test failure
// /**
// * verify removeCertificate(Certificate certificate) removes certificate
// */
// public void testRemoveCertificate1() throws Exception{
// Identity i = new IdentityStub("iii");
// PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
// CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
// i.addCertificate(c1);
// assertSame(c1, i.certificates()[0]);
// i.removeCertificate(c1);
// assertEquals(0, i.certificates().length);
// // throw KeyManagementException if certificate not found
// try {
// i.removeCertificate(c1);
// fail("KeyManagementException should be thrown");
// } catch (KeyManagementException ok) {
// }
// try {
// i.removeCertificate(null);
// fail("KeyManagementException should be thrown");
// } catch (KeyManagementException ok) {
//
// }
// }
/**
* verify certificates() returns a copy of all certificates for this identity
*/
public void testCertificates() throws Exception {
Identity i = new IdentityStub("iii");
PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", null);
CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
CertificateStub c2 = new CertificateStub("zzz", null, null, pk1);
i.addCertificate(c1);
i.addCertificate(c2);
java.security.Certificate[] s = i.certificates();
assertEquals(2, s.length);
assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
s[0] = null;
s[1] = null;
// check that the copy was modified
s = i.certificates();
assertEquals(2, s.length);
assertTrue(c1.equals(s[0]) || c2.equals(s[0]));
assertTrue(c1.equals(s[1]) || c2.equals(s[1]));
}
use of org.apache.harmony.security.tests.support.IdentityStub in project robovm by robovm.
the class IdentityTest method testIdentityString.
/*
* verify Identity(String) creates instance with given name
*/
public void testIdentityString() {
Identity i = new IdentityStub("iii");
assertNotNull(i);
assertEquals("iii", i.getName());
i = new IdentityStub(null);
assertNotNull(i);
assertNull(i.getName());
}
Aggregations