Package org.apache.harmony.security.tests.support

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


    /**
     * Class under test for String toString()
     */
    public final void testToString() {
        assertNotNull(new IdentityScopeStub("Aleksei Semenov").toString());
    }
View Full Code Here


    /**
     * test default constructor void IdentityScope()
     */
    public final void testIdentityScope() {
        assertNotNull(new IdentityScopeStub());
    }
View Full Code Here

    /**
     * check that void IdentityScope(String) creates instance with given name
     */
    public final void testIdentityScopeString() {
        is = new IdentityScopeStub("Aleksei Semenov");
        assertNotNull(is);
        assertEquals("Aleksei Semenov", is.getName());
    }
View Full Code Here

    /**
     * check that void IdentityScope(String, IdentityScope) creates instance with given name and within given scope
     */
    public final void testIdentityScopeStringIdentityScope() throws Exception {
        IdentityScope scope = new IdentityScopeStub("my scope");
        is = new IdentityScopeStub("Aleksei Semenov", scope);
        assertNotNull(is);
        assertEquals("Aleksei Semenov", is.getName());
        assertEquals(scope.getName(), is.getScope().getName());
    }
View Full Code Here

//      default implementation is specified by security property system.scope
        IdentityScope systemScope = IdentityScope.getSystemScope();
       
        try {
            // all permissions are granted - sm is not installed
            is = new IdentityScopeStub("Aleksei Semenov");
            IdentityScopeStub.mySetSystemScope(is);
            assertSame(is, IdentityScope.getSystemScope());
            // all permissions are granted - sm is installed
            MySecurityManager sm = new MySecurityManager();
            System.setSecurityManager(sm);
            try {
                is = new IdentityScopeStub("aaa");
                IdentityScopeStub.mySetSystemScope(is);
                assertSame(is, IdentityScope.getSystemScope());      
                // permission is denied
                sm.denied.add(new SecurityPermission("setSystemScope"));
                IdentityScope is2 = new IdentityScopeStub("bbb");
                try{
                    IdentityScopeStub.mySetSystemScope(is2);
                    fail("SecurityException should be thrown");
                } catch (SecurityException e){
                    assertSame(is, IdentityScope.getSystemScope());
View Full Code Here

    /**
     * Class under test for Identity getIdentity(Principal)
     */
    public final void testGetIdentityPrincipal() {
        is = new IdentityScopeStub("Aleksei Semenov");
        IdentityScope sc2 = new IdentityScopeStub("aaa");
        assertSame(is, is.getIdentity(sc2));
    }
View Full Code Here

     */
   
    public void testSize() throws Exception {
        //SystemScope ss = new SystemScope("SystemScope");
        assertEquals(0, ss.size());
        ss.addIdentity(new IdentityScopeStub("aaa"));
        assertEquals(1, ss.size());
        ss.addIdentity(new IdentityScopeStub("bbb"));
        assertEquals(2, ss.size());
    }
View Full Code Here

     */
    public void testGetIdentityString() throws Exception {
        //SystemScope ss = new SystemScope("SystemScope");
        assertNull(ss.getIdentity("aaa"));
       
        java.security.Identity aaa = new IdentityScopeStub("aaa");
        ss.addIdentity(aaa);
        assertSame(aaa, ss.getIdentity(aaa.getName()));
        assertNull(ss.getIdentity("bbb"));
       
    }
View Full Code Here

     */
    public void testGetIdentityPublicKey() throws Exception {
        //SystemScope ss = new SystemScope("SystemScope");
        java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);
        assertNull(ss.getIdentity(kkk));
        java.security.Identity aaa = new IdentityScopeStub("aaa");
        aaa.setPublicKey(kkk);
        ss.addIdentity(aaa);
       
        assertSame(aaa, ss.getIdentity(kkk));               
    }
View Full Code Here

     * i.e. KeyManagementException is thrown
     */
    public void testAddIdentity() throws Exception {
//        SystemScope ss = new SystemScope("SystemScope");
        java.security.PublicKey kkk = new PublicKeyStub("kkk", "fff", null);       
        java.security.Identity aaa = new IdentityScopeStub("aaa");
        aaa.setPublicKey(kkk);
        ss.addIdentity(aaa);
       
        java.security.Identity bbb = new IdentityScopeStub("aaa");
        try {
            ss.addIdentity(bbb);
            fail("KeyManagementException should be thrown for already used name");
        } catch (KeyManagementException ok) {}
       
        java.security.Identity ccc = new IdentityScopeStub("ccc");
        ccc.setPublicKey(kkk);
        try {
            ss.addIdentity(ccc);
            fail("KeyManagementException should be thrown for already used key");
        } catch (KeyManagementException ok) {}           
               
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.tests.support.IdentityScopeStub

Copyright © 2018 www.massapicom. 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.