Search in sources :

Example 6 with IdentitySubclass

use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.

the class IdentityScope2Test method test_getIdentityLjava_security_Principal.

/**
     * java.security.IdentityScope#getIdentity(java.security.Principal)
     */
public void test_getIdentityLjava_security_Principal() throws Exception {
    Identity id = new IdentitySubclass("principal name");
    id.setPublicKey(getPubKey());
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    try {
        sub.getIdentity((java.security.Principal) null);
        fail("Test 1: NullPointerException expected.");
    } catch (NullPointerException expected) {
    }
    sub.addIdentity(id);
    Identity returnedId = sub.getIdentity(id);
    assertEquals("Test 2: Returned Identity not the same as the added one;", id, returnedId);
    Identity id2 = new IdentitySubclass("Another identity");
    id2.setPublicKey(getPubKey());
    assertNull("Test 3: Null value expected.", sub.getIdentity(id2));
    try {
        sub.getIdentity((java.security.Principal) null);
        fail("Test 4: NullPointerException expected.");
    } catch (NullPointerException expected) {
    }
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) Identity(java.security.Identity)

Example 7 with IdentitySubclass

use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.

the class IdentityScope2Test method test_size.

/**
     * java.security.IdentityScope#size()
     */
public void test_size() throws Exception {
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    Identity id = new IdentitySubclass();
    id.setPublicKey(getPubKey());
    sub.addIdentity(id);
    assertEquals("Wrong size", 1, sub.size());
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) Identity(java.security.Identity)

Example 8 with IdentitySubclass

use of org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass in project robovm by robovm.

the class IdentityScope2Test method test_getIdentityLjava_lang_String.

/**
     * java.security.IdentityScope#getIdentity(java.lang.String)
     */
public void test_getIdentityLjava_lang_String() throws Exception {
    IdentityScopeSubclass sub = new IdentityScopeSubclass("test", new IdentityScopeSubclass());
    Identity id = new IdentitySubclass("test");
    id.setPublicKey(getPubKey());
    sub.addIdentity(id);
    Identity returnedId = sub.getIdentity("test");
    assertEquals("Returned Identity not the same as the added one", id, returnedId);
}
Also used : IdentitySubclass(org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass) Identity(java.security.Identity)

Aggregations

Identity (java.security.Identity)8 IdentitySubclass (org.apache.harmony.security.tests.java.security.Identity2Test.IdentitySubclass)8 KeyManagementException (java.security.KeyManagementException)2 PublicKey (java.security.PublicKey)1