Code example for PermissionCollection

Methods: addsetReadOnly

0
    public void testAddCollection() { 
        ServicePermission sp = new ServicePermission("AAA", "accept");
        PermissionCollection pc  = sp.newPermissionCollection();
         
        try { 
            pc.add(new DelegationPermission("\"aaa\" \"bbb\""));
            fail("Should not add non DelegationPermission");
        } catch (IllegalArgumentException e) {
        } 
         
        try { 
            pc.add(null);
            fail("no expected IAE");
        } catch (IllegalArgumentException e) {
        } 
         
        pc.add(new ServicePermission("AAA", "accept"));
        pc.add(new ServicePermission("BBB", "accept, initiate"));
         
        pc.setReadOnly();
        try { 
            pc.add(sp);
            fail("read-only flag is ignored");
        } catch (SecurityException e) {
        } 
    } 
     
Stop searching for code, let great code find you!  Add Codota to your java IDE