Examples of IdentityStub


Examples of org.apache.harmony.security.tests.support.IdentityStub

    public IdentityTest(String name) {
        super(name);
    }

    public void testHashCode() {
        new IdentityStub("testHashCode").hashCode();
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    public void testHashCode() {
        new IdentityStub("testHashCode").hashCode();
    }

    public void testEquals() throws Exception {
        Identity i1 = new IdentityStub("testEquals");
        Object value[] {
                null, Boolean.FALSE,
                new Object(), Boolean.FALSE,
                i1, Boolean.TRUE,
                new IdentityStub(i1.getName()), Boolean.TRUE
        };
       
        for (int k=0; k<value.length; k+=2) {
            assertEquals(value[k+1], new Boolean(i1.equals(value[k])));
            if (Boolean.TRUE.equals(value[k+1])) assertEquals(i1.hashCode(), value[k].hashCode());
        }
        // check other cases
        Identity i2 = new IdentityStub("testEquals", IdentityScope.getSystemScope());
        assertEquals(i1.identityEquals(i2), i1.equals(i2));
        Identity i3 = new IdentityStub("testEquals3");
        assertEquals(i1.identityEquals(i3), i1.equals(i3));
       
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    public void testToString1() {
        MySecurityManager sm = new MySecurityManager();
        sm.denied.add(new SecurityPermission("printIdentity"));
        System.setSecurityManager(sm);
        try {
            new IdentityStub("testToString").toString();
            fail("SecurityException should be thrown");
        } catch (SecurityException ok) {
        } finally {
            System.setSecurityManager(null);
        }         
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    }
    /**
     * verify Identity.toString()
     */
    public void testToString2() {   
        assertNotNull(new IdentityStub("testToString2").toString());
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    /**
     * verify Identity() creates instance
     */
    public void testIdentity() {
        assertNotNull(new IdentityStub());
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    /*
     * 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());
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    /**
     * 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()));       
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

     * verify addCertificate(Certificate certificate) adds a certificate for this identity.
     * If the identity has a public key, the public key in the certificate must be the same
     * 
     */
    public void testAddCertificate1() throws Exception {
        Identity i = new IdentityStub("iii");
        PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", new byte[]{1,2,3,4,5});
        i.setPublicKey(pk1);
        // try with the same key
        CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
        i.addCertificate(c1);
        assertSame(c1, i.certificates()[0]);
        // try Certificate with different key
        try {
            i.addCertificate(new CertificateStub("ccc", null, null, new PublicKeyStub("k2", "fff", new byte[]{6,7,8,9,0})));
            fail("KeyManagementException should be thrown");
        } catch (KeyManagementException ok) {}       
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    /**
     * verify addCertificate(Certificate certificate) adds a certificate for this identity.
     * if the identity does not have a public key, the identity's public key is set to be that specified in the certificate.
     */
    public void testAddCertificate2() 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]);
        assertSame(pk1, i.getPublicKey());
         
    }
View Full Code Here

Examples of org.apache.harmony.security.tests.support.IdentityStub

    public void testAddCertificate3() throws Exception {
        MySecurityManager sm = new MySecurityManager();
        sm.denied.add(new SecurityPermission("addIdentityCertificate"));
        System.setSecurityManager(sm);
        try {
            new IdentityStub("iii").addCertificate(new CertificateStub("ccc", null, null, null));
            fail("SecurityException should be thrown");
        } catch (SecurityException ok) {
        } finally {
            System.setSecurityManager(null);
        }       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.