Example usage for org.springframework.mock.web MockHttpSession setNew

List of usage examples for org.springframework.mock.web MockHttpSession setNew

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpSession setNew.

Prototype

public void setNew(boolean value) 

Source Link

Usage

From source file:org.hdiv.filter.ValidatorErrorHandlerTest.java

public void testValidatorErrorHandler() {

    HttpServletRequest request = HDIVUtil.getHttpServletRequest();
    MockHttpSession session = (MockHttpSession) request.getSession();
    session.setNew(false); // mark as not new sesssion
    MockHttpServletResponse response = new MockHttpServletResponse();

    this.validatorErrorHandler.handleValidatorError(request, response, HDIVErrorCodes.REQUIRED_PARAMETERS);

    String redirectUrl = response.getRedirectedUrl();

    assertEquals(getConfig().getErrorPage(), redirectUrl);
}

From source file:org.cateproject.test.functional.mockmvc.HtmlUnitRequestBuilder.java

private MockHttpSession httpSession(MockHttpServletRequest request, final String sessionid) {
    MockHttpSession session;
    synchronized (sessions) {
        session = sessions.get(sessionid);
        if (session == null) {
            session = new HtmlUnitMockHttpSession(request, sessionid);
            session.setNew(true);
            synchronized (sessions) {
                sessions.put(sessionid, session);
            }//from   w  w  w . j a  va2 s  .com
            addSessionCookie(request, sessionid);
        } else {
            session.setNew(false);
        }
    }
    return session;
}