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

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

Introduction

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

Prototype

public final Session setAttribute(String name, Serializable value) 

Source Link

Document

Adds or replaces the attribute with the given name and value.

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);//  ww w  .java2 s  .  com
    // 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"));

}