Code example for Subject

Methods: doAsPrivileged

0
        } 
         
        try { 
            Subject s = new Subject(false, principal, pubCredentials, privCredentials);
            assertNotNull("Null object returned", s);
            assertFalse("Read-only object", s.isReadOnly());
            assertFalse("Set of principal is empty", s.getPrincipals().isEmpty());
            assertFalse("Set of private credentials is empty", s.getPrivateCredentials().isEmpty());
            assertFalse("Set of public credentials is empty", s.getPublicCredentials().isEmpty());
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        } 
         
        try { 
            Subject s = new Subject(true, null, pubCredentials, privCredentials);
            fail("NullPointerException wasn't thrown");
        } catch (NullPointerException npe) {
        } 
         
        try { 
            Subject s = new Subject(true, principal, null, privCredentials);
            fail("NullPointerException wasn't thrown");
        } catch (NullPointerException npe) {
        } 
         
        try { 
            Subject s = new Subject(true, principal, pubCredentials, null);
            fail("NullPointerException wasn't thrown");
        } catch (NullPointerException npe) {