Class MockPrincipal


  • public static class MockPrincipal
    extends Object
    Mock implementation of a user principal. This class also provides convenient methods for specifying the user principal roles.

    Example usage with MockContext:

     MockContext mockContext = MockContext.initContext();
    
     // Create a new user principal with the roles "user" and "manager"
     MockPrincipal principal = new MockPrincipal("Bob", "user", "manager");
    
     // Set the user principal on the request object
     mockContext.getMockRequest().setUserPrincipal(principal); 

    Example usage with MockContainer:

     MockContainer container = new MockContainer("c:/dev/myapp/web");
    
     // Create a new user principal with the roles "user" and "manager"
     MockPrincipal principal = new MockPrincipal("Bob", "user", "manager");
    
     // Set the user principal on the request object
     container.getRequest().setUserPrincipal(principal); 
    Since:
    17.10.0
    See Also:
    Serialized Form