Code example for PermissionCollection

Methods: add, setReadOnly

0
    public void testAddCollection()   { 
        DelegationPermission dp = new DelegationPermission("\"AAA\" \"BBB\"");
        PermissionCollection pc1 = dp.newPermissionCollection();
        PermissionCollection pc2 = dp.newPermissionCollection();
        assertNotSame(pc1, pc2);
        pc1.add(new DelegationPermission("\"BBB\" \"AAA\""));
        try { 
            pc1.add(new SecurityPermission("aaa"));
            fail("should not add non DelegationPermission");
        } catch (IllegalArgumentException e){
        } 
		try { 
		    pc1.add(null);
		    fail("permission is null");
		} catch (IllegalArgumentException e) {
		} 
        pc1.setReadOnly();
		try { 
			pc1.add(new DelegationPermission("\"CCC\" \"AAA\""));
			fail("read-only flag is ignored");
		} catch (SecurityException e) {
		} 
    }