Example usage for org.apache.wicket.protocol.http WebSession bind

List of usage examples for org.apache.wicket.protocol.http WebSession bind

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http WebSession bind.

Prototype

public final void bind() 

Source Link

Document

Force binding this session to the application's ISessionStore session store if not already done so.

Usage

From source file:org.geoserver.web.GeoServerSecuredPageTest.java

License:Open Source License

@Test
public void testSessionFixationAvoidance() throws Exception {
    tester.startPage(GeoServerHomePage.class);
    final WebSession session = WebSession.get();
    session.bind(); // fore session creation
    session.setAttribute("test", "whatever");
    // login, this will invalidate the session
    tester.startPage(GeoServerHomePage.class);
    MockHttpServletRequest request = createRequest("login");
    request.setMethod("POST");
    request.setParameter("username", "admin");
    request.setParameter("password", "geoserver");
    dispatch(request);//from ww  w.  jav a 2s .co m
    // the session in wicket tester mock does not disappear, the only
    // way to see if it has been invalidated is to check that the attributes are gone...
    assertNull(session.getAttribute("test"));

}