Examples of MockPrincipal


Examples of org.apache.click.servlet.MockPrincipal

        MockContext mockContext = MockContext.initContext();
        MockRequest mockRequest = mockContext.getMockRequest();

        // Create a new user principal with the roles "user" and "manager"
        MockPrincipal principal = new MockPrincipal(user);

        // Set the user principal on the request object
        mockRequest.setUserPrincipal(principal);

        // Check user is in "user" and "manager" roles
View Full Code Here

Examples of org.apache.click.servlet.MockPrincipal

        MockContext mockContext = MockContext.initContext();
        MockRequest mockRequest = mockContext.getMockRequest();

        // 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
        mockRequest.setUserPrincipal(principal);

        // Check user is in "user" and "manager" roles
View Full Code Here

Examples of org.apache.click.servlet.MockPrincipal

    public void testHasAccess() {
        // Setup
        RoleAccessController controller = new RoleAccessController();
        MockRequest request = new MockRequest();
        String role = "userRole";
        MockPrincipal principal = new MockPrincipal("bob", role);
        request.setUserPrincipal(principal);

        // Perform tests
        assertTrue(controller.hasAccess(request, role));
    }
View Full Code Here

Examples of org.apache.click.servlet.MockPrincipal

    public void testNullRoles() {
        // Setup
        RoleAccessController controller = new RoleAccessController();
        MockRequest request = new MockRequest();
        String role = "userRole";
        MockPrincipal principal = new MockPrincipal("bob", role);
        request.setUserPrincipal(principal);

        role = null;

        // Perform tests
View Full Code Here

Examples of org.apache.click.servlet.MockPrincipal

        RoleAccessController controller = new RoleAccessController();
        menu.setAccessController(controller);

        MockRequest request = new MockRequest();
        String role = "userRole";
        MockPrincipal principal = new MockPrincipal("bob", role);
        request.setUserPrincipal(principal);

        // Perform tests
        assertTrue(menu.isUserInRoles());
    }
View Full Code Here

Examples of org.apache.click.servlet.MockPrincipal

        RoleAccessController controller = new RoleAccessController();
        menu.setAccessController(controller);

        MockContext context = MockContext.initContext();
        MockPrincipal principal = new MockPrincipal("bob", role);
        context.getMockRequest().setUserPrincipal(principal);

        // Perform tests
        assertTrue(menu.isUserInRoles());
    }
View Full Code Here

Examples of org.apache.roller.ui.MockPrincipal

    protected void authenticateUser(String username, String role)
        throws RollerException {
       
        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
        mockRequest.setRemoteUser(username);
        mockRequest.setUserPrincipal(new MockPrincipal(username));
        mockRequest.setUserInRole(role, true);
       
        HttpSession session = mockRequest.getSession(true);
        UserManager umgr = RollerFactory.getRoller().getUserManager();
        UserData user = umgr.getUserByUserName(username);
View Full Code Here

Examples of org.apache.roller.ui.MockPrincipal

    protected void authenticateUser(String username, String role)
        throws RollerException {
       
        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
        mockRequest.setRemoteUser(username);
        mockRequest.setUserPrincipal(new MockPrincipal(username));
        mockRequest.setUserInRole(role, true);
       
        HttpSession session = mockRequest.getSession(true);
        UserManager umgr = RollerFactory.getRoller().getUserManager();
        UserData user = umgr.getUserByUserName(username);
View Full Code Here

Examples of org.apache.struts.mock.MockPrincipal

    /* setUp method for test case */
    protected void setUp() throws Exception {
        this.request = new MockHttpServletRequest();
        this.principal =
            new MockPrincipal("Mr. Macri", new String[] { "administrator" });
        this.request.setUserPrincipal(principal);

        MockServletConfig servletConfig = new MockServletConfig();
        MockServletContext servletContext = new MockServletContext();
        MockActionServlet servlet =
View Full Code Here

Examples of org.apache.struts.mock.MockPrincipal

    /* setUp method for test case */
    protected void setUp() throws Exception {
        this.request = new MockHttpServletRequest();
        this.principal =
            new MockPrincipal("Mr. Macri", new String[] { "administrator" });
        this.request.setUserPrincipal(principal);

        MockServletConfig servletConfig = new MockServletConfig();
        MockServletContext servletContext = new MockServletContext();
        MockActionServlet servlet =
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.