use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.
the class IdentityScope2Test method test_removeIdentityLjava_security_Identity.
/**
* java.security.IdentityScope#removeIdentity(java.security.Identity)
*/
public void test_removeIdentityLjava_security_Identity() throws Exception {
IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
Identity id = new IdentitySubclass();
id.setPublicKey(getPubKey());
sub.addIdentity(id);
sub.removeIdentity(id);
try {
sub.removeIdentity(id);
fail("KeyManagementException should have been thrown");
} catch (KeyManagementException expected) {
}
}
use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.
the class IdentityScope2Test method test_toString.
/**
* java.security.IdentityScope#toString()
*/
public void test_toString() throws Exception {
IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
Identity id = new IdentitySubclass();
id.setPublicKey(getPubKey());
sub.addIdentity(id);
assertNotNull("toString returned a null", sub.toString());
assertTrue("Not a valid String ", sub.toString().length() > 0);
}
use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.
the class IdentityScope2Test method test_identities.
/**
* java.security.IdentityScope#identities()
*/
public void test_identities() throws Exception {
IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
Identity id = new IdentitySubclass();
id.setPublicKey(getPubKey());
sub.addIdentity(id);
Enumeration<Identity> en = sub.identities();
assertEquals("Wrong object contained in identities", en.nextElement(), id);
assertFalse("Contains too many elements", en.hasMoreElements());
}
use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.
the class IdentityScope2Test method test_getIdentityLjava_security_PublicKey.
/**
* java.security.IdentityScope#getIdentity(java.security.PublicKey)
*/
public void test_getIdentityLjava_security_PublicKey() throws Exception {
IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
Identity id = new IdentitySubclass();
id.setPublicKey(getPubKey());
sub.addIdentity(id);
Identity returnedId = sub.getIdentity(getPubKey());
assertEquals("Test 1: Returned Identity not the same as the added one;", id, returnedId);
assertNull("Test 2: Null value expected.", sub.getIdentity((PublicKey) null));
PublicKey anotherKey = KeyPairGenerator.getInstance("DSA").genKeyPair().getPublic();
assertNull("Test 3: Null value expected.", sub.getIdentity(anotherKey));
}
use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.
the class IdentityScope2Test method test_addIdentityLjava_security_Identity.
/**
* java.security.IdentityScope#addIdentity(java.security.Identity)
*/
public void test_addIdentityLjava_security_Identity() throws Exception {
IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
Identity id = new IdentitySubclass("id1");
id.setPublicKey(getPubKey());
sub.addIdentity(id);
try {
Identity id2 = new IdentitySubclass("id2");
id2.setPublicKey(getPubKey());
sub.addIdentity(id2);
fail("KeyManagementException should have been thrown");
} catch (KeyManagementException e) {
// Expected
}
}
Aggregations