Class MockPrincipal

com.avoka.tm.test.MockPrincipal

public static class MockPrincipal
Mock implementation of a user
invalid reference
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: