Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockHttpSession


    public void testSetLocaleInSessionWhenSessionNotNull() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addParameter("locale", "es");

        MockHttpServletResponse response = new MockHttpServletResponse();
        request.setSession(new MockHttpSession(null));
       
        filter.doFilter(request, response, new MockFilterChain());
       
        // session not null, should result in not null
        Locale locale = (Locale) request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY);
View Full Code Here


    public void testSetInvalidLocale() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addParameter("locale", "foo");

        MockHttpServletResponse response = new MockHttpServletResponse();
        request.setSession(new MockHttpSession(null));
       
        filter.doFilter(request, response, new MockFilterChain());
       
        // a locale will get set regardless - there's no such thing as an invalid one
        assertNotNull(request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY));
View Full Code Here

    public void testJstlLocaleIsSet() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addParameter("locale", "es");

        MockHttpServletResponse response = new MockHttpServletResponse();
        request.setSession(new MockHttpSession(null));
       
        filter.doFilter(request, response, new MockFilterChain());
       
        assertNotNull(Config.get(request.getSession(), Config.FMT_LOCALE));
    }
View Full Code Here

        assertNotNull(Config.get(request.getSession(), Config.FMT_LOCALE));
    }

    public void testLocaleAndCountry() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setSession(new MockHttpSession());
        request.addParameter("locale", "zh_TW");

        MockHttpServletResponse response = new MockHttpServletResponse();
        filter.doFilter(request, response, new MockFilterChain());
View Full Code Here

    }

    protected void initSession(ActionContext actionContext) {
        if (actionContext.getSession() == null) {
            actionContext.setSession(new HashMap<String, Object>());
            request.setSession(new MockHttpSession(servletContext));
        }
    }
View Full Code Here

      String name = entry.getKey();
      Object value = entry.getValue();
      it.remove();
      if (value instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) value).valueUnbound(
            new HttpSessionBindingEvent(new MockHttpSession(), name, value));
      }
    }
  }
View Full Code Here

      String name = entry.getKey();
      Object value = entry.getValue();
      it.remove();
      if (value instanceof HttpSessionBindingListener) {
        ((HttpSessionBindingListener) value).valueUnbound(
            new HttpSessionBindingEvent(new MockHttpSession(), name, value));
      }
    }
  }
View Full Code Here

    @Before
    @Override
    public void setUp() throws Exception {
        if (configurationManager == null) {
            servletContext = new MockServletContext(resourceLoader);
            httpSession = new MockHttpSession(servletContext);
            request = new MockHttpServletRequest(servletContext);
            request.setSession(httpSession);
            session = new SessionMap<String, Object>(request);
            setupBeforeInitDispatcher();
            processAnnotations(currentlyExecutingTest.getMethodName());
View Full Code Here

    protected void setupBeforeInitDispatcher() throws Exception {
    }

    protected void initServletMockObjects() {
        servletContext = new MockServletContext(resourceLoader);
        httpSession = new MockHttpSession(servletContext);
        response = new MockHttpServletResponse();
        request = new MockHttpServletRequest(servletContext);
        request.setSession(httpSession);
        pageContext = new MockPageContext(servletContext, request, response);
        session = new SessionMap<String, Object>(request);
View Full Code Here

  private String mockConversationName = "test_conversation";
  private String mockConversationId = "123";
 
  @Test
  public void testSetTimeout() {
    MockHttpSession session = new MockHttpSession();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setSession(session);
    request.setParameter(mockConversationName, mockConversationId);
    HttpConversationContextManagerProvider managerProvider = new DefaultHttpConversationContextManagerProvider();
    managerProvider.setConversationContextFactory(new DefaultConversationContextFactory());
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.