Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockHttpSession


  }

  @Test
  public void testNoTokensRemembered() {

    MockHttpSession mockHttpSession = new MockHttpSession();
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setSession(mockHttpSession);
View Full Code Here


  }

  @Test
  public void testStoreEverything() {

    MockHttpSession mockHttpSession = new MockHttpSession();
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setSession(mockHttpSession);
View Full Code Here

  }

  @Test
  public void testStoreRequestTokensOnly() {

    MockHttpSession mockHttpSession = new MockHttpSession();
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setSession(mockHttpSession);
View Full Code Here

    private HttpSession session;
   
    @BeforeMethod
    public void setUp() throws Exception {
        service = spy(new KaptchaPluginService(IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_LENGTH, POSSIBLE_SYMBOLS));
        session = new MockHttpSession();
        request = new MockHttpServletRequest();
        request.setSession(session);
    }
View Full Code Here

    @Test
    public void enterAdminModeShouldSetSessionAttributeAndReturnPreviousPageRedirect() {
        HttpServletRequest request = mock(HttpServletRequest.class);
        String initialPage = "/topics/2";
        when(request.getHeader("Referer")).thenReturn(initialPage);
        HttpSession session = new MockHttpSession();
        when(request.getSession()).thenReturn(session);

        String resultUrl = administrationController.enterAdministrationMode(request);

        Boolean attr = (Boolean) session.getAttribute(AdministrationController.ADMIN_ATTRIBUTE_NAME);
        assertTrue(attr);
        assertEquals(resultUrl, "redirect:" + initialPage);
    }
View Full Code Here

    @Test
    public void exitAdminModeShouldRemoveSessionAttributeAndReturnPreviousPageRedirect() {
        HttpServletRequest request = mock(HttpServletRequest.class);
        String initialPage = "/topics/2";
        when(request.getHeader("Referer")).thenReturn(initialPage);
        HttpSession session = new MockHttpSession();
        when(request.getSession()).thenReturn(session);

        String resultUrl = administrationController.exitAdministrationMode(request);

        Object attr = session.getAttribute(AdministrationController.ADMIN_ATTRIBUTE_NAME);

        assertNull(attr);
        assertEquals(resultUrl, "redirect:" + initialPage);
    }
View Full Code Here

        sessionTimeoutProperty.setPropertyDao(propertyDao);
        sessionTimeoutProperty.setName(PROPERTY_NAME);

        when(context.getBean(Mockito.anyString())).thenReturn(sessionTimeoutProperty);

        session = new MockHttpSession();
        session.getServletContext().setAttribute(
                WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
                context);

        event = new HttpSessionEvent(session);
View Full Code Here

    private SessionStatisticListener listener;
    private HttpSessionEvent event;

    @BeforeMethod
    public void initMethod() {
        event = new HttpSessionEvent(new MockHttpSession());
        listener = new SessionStatisticListener();
    }
View Full Code Here

    @Test
    public void anonymousUserRegisteredAndUnregistered() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockHttpSession httpSession = spy(new MockHttpSession());
        request.setSession(httpSession);
        MockFilterChain filterChain = new MockFilterChain();

        String userName = "";
        when(securityService.getCurrentUserUsername()).thenReturn(userName);
        when(httpSession.getId()).thenReturn("AF7823");

        loggingConfigurationFilter.doFilter(request, response, filterChain);

        verify(loggerMdc).registerUser("anonymous-7823");
        verify(loggerMdc).unregisterUser();
View Full Code Here

     */
    @Test
    public void anonymousUserWithoutSessionIdShouldNotRegister() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockHttpSession httpSession = spy(new MockHttpSession());
        request.setSession(httpSession);
        MockFilterChain filterChain = new MockFilterChain();

        when(securityService.getCurrentUserUsername()).thenReturn("");
        when(httpSession.getId()).thenReturn("");

        loggingConfigurationFilter.doFilter(request, response, filterChain);

        verify(loggerMdc, times(0)).registerUser(anyString());
        verify(loggerMdc, times(0)).unregisterUser();
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.MockHttpSession

Copyright © 2018 www.massapicom. 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.