Code example for SecurityPermission

0
 
    /** 
     * Tests that policy is really resetted on refresh().  
     */ 
    public void testRefresh() { 
        Permission sp = new SecurityPermission("sdf");
        PolicyEntry[] pe = new PolicyEntry[] { new PolicyEntry(null, null,
            Arrays.asList(new Permission[] { sp })) };
        TestParser tp = new TestParser(pe);
        DefaultPolicy policy = new DefaultPolicy(tp);
        CodeSource cs = new CodeSource(null, (Certificate[])null);
        assertTrue(policy.getPermissions(cs).implies(sp));
 
        tp.content = new PolicyEntry[0];
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));
 
        tp.content = null;
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));
    } 
 
    /** 
     * Tests that refresh() does not fail on failing parser. 
     */ 
Connect your IDE to all the code out there  Get Codota for Java