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

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

Introduction

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

Prototype

public final Serializable getAttribute(final String name) 

Source Link

Document

Gets the attribute value with the given name

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. j  ava 2s .c om*/
    // 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"));

}