Code example for Subject

Methods: getPrincipals

0
            { 
                return "otherprincipal"; 
            } 
        }; 
 
        final Subject subject = new Subject();
        subject.getPrincipals().add(expected);
        subject.getPrincipals().add(other);
 
        final UsernamePrincipal actual = UsernamePrincipal.getUsernamePrincipalFromSubject(subject);
        assertSame(expected, actual);
    } 
 
    public void testUsernamePrincipalNotInSubject() 
    { 
        try 
        { 
            UsernamePrincipal.getUsernamePrincipalFromSubject(new Subject());
            fail("Exception not thrown");
        } 
        catch (IllegalArgumentException iae)