public class

MockHttpSession

extends Object
implements HttpSession
java.lang.Object
   ↳ org.springframework.mock.web.MockHttpSession

Class Overview

Mock implementation of the javax.servlet.http.HttpSession interface. Supports the Servlet 2.4 API level.

Used for testing the web framework; also useful for testing application controllers.

Summary

Constants
String SESSION_COOKIE_NAME
Public Constructors
MockHttpSession()
Create a new MockHttpSession with a default MockServletContext.
MockHttpSession(ServletContext servletContext)
Create a new MockHttpSession.
MockHttpSession(ServletContext servletContext, String id)
Create a new MockHttpSession.
Public Methods
void access()
void clearAttributes()
Clear all of this session's attributes.
void deserializeState(Serializable state)
Deserialize the attributes of this session from a state object created by serializeState().
Object getAttribute(String name)
Enumeration<String> getAttributeNames()
long getCreationTime()
String getId()
long getLastAccessedTime()
int getMaxInactiveInterval()
ServletContext getServletContext()
HttpSessionContext getSessionContext()
Object getValue(String name)
String[] getValueNames()
void invalidate()
boolean isInvalid()
boolean isNew()
void putValue(String name, Object value)
void removeAttribute(String name)
void removeValue(String name)
Serializable serializeState()
Serialize the attributes of this session into an object that can be turned into a byte array with standard Java serialization.
void setAttribute(String name, Object value)
void setMaxInactiveInterval(int interval)
void setNew(boolean value)
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.servlet.http.HttpSession

Constants

public static final String SESSION_COOKIE_NAME

Constant Value: "JSESSION"

Public Constructors

public MockHttpSession ()

Create a new MockHttpSession with a default MockServletContext.

public MockHttpSession (ServletContext servletContext)

Create a new MockHttpSession.

Parameters
servletContext the ServletContext that the session runs in

public MockHttpSession (ServletContext servletContext, String id)

Create a new MockHttpSession.

Parameters
servletContext the ServletContext that the session runs in
id a unique identifier for this session

Public Methods

public void access ()

public void clearAttributes ()

Clear all of this session's attributes.

public void deserializeState (Serializable state)

Deserialize the attributes of this session from a state object created by serializeState().

Parameters
state a representation of this session's serialized state

public Object getAttribute (String name)

public Enumeration<String> getAttributeNames ()

public long getCreationTime ()

public String getId ()

public long getLastAccessedTime ()

public int getMaxInactiveInterval ()

public ServletContext getServletContext ()

public HttpSessionContext getSessionContext ()

public Object getValue (String name)

public String[] getValueNames ()

public void invalidate ()

public boolean isInvalid ()

public boolean isNew ()

public void putValue (String name, Object value)

public void removeAttribute (String name)

public void removeValue (String name)

public Serializable serializeState ()

Serialize the attributes of this session into an object that can be turned into a byte array with standard Java serialization.

Returns
  • a representation of this session's serialized state

public void setAttribute (String name, Object value)

public void setMaxInactiveInterval (int interval)

public void setNew (boolean value)