Code example for Subject

Methods: doAs

0
        super.setUp(); 
    } 
 
    @Override 
    protected void tearDown() throws Exception { 
        System.setSecurityManager(old);
        super.tearDown(); 
    } 
 
    /** 
     * @tests javax.security.auth.Subject#Subject()  
     */ 
    @TestTargetNew( 
        level = TestLevel.COMPLETE, 
        notes = "", 
        method = "Subject", 
        args = {} 
    ) 
    public void test_Constructor_01() { 
        try { 
            Subject s = new Subject();
            assertNotNull("Null object returned", s);
            assertTrue("Set of principal is not empty", s.getPrincipals().isEmpty());
            assertTrue("Set of private credentials is not empty", s.getPrivateCredentials().isEmpty());
            assertTrue("Set of public credentials is not empty", s.getPublicCredentials().isEmpty());
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        }