Package com.jalios.servlet.http
Class MockHttpSession
java.lang.Object
com.jalios.servlet.http.MockHttpSession
- All Implemented Interfaces:
javax.servlet.http.HttpSession
Mock implementation of the
HttpSession interface.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new MockHttpSession with a defaultMockServletContext.MockHttpSession(javax.servlet.ServletContext servletContext) Create a new MockHttpSession.MockHttpSession(javax.servlet.ServletContext servletContext, String id) Create a new MockHttpSession. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccess()As of Servlet 3.1 the id of a session can be changed.voidClear all of this session's attributes.voiddeserializeState(Serializable state) Deserialize the attributes of this session from a state object created byserializeState().getAttribute(String name) longgetId()longintjavax.servlet.ServletContextjavax.servlet.http.HttpSessionContextString[]voidInvalidates this session then unbinds any objects bound to it.booleanbooleanisNew()voidvoidremoveAttribute(String name) voidremoveValue(String name) Serialize the attributes of this session into an object that can be turned into a byte array with standard Java serialization.voidsetAttribute(String name, Object value) voidsetMaxInactiveInterval(int interval) voidsetNew(boolean value)
-
Field Details
-
SESSION_COOKIE_NAME
- See Also:
-
-
Constructor Details
-
MockHttpSession
public MockHttpSession()Create a new MockHttpSession with a defaultMockServletContext.- See Also:
-
MockHttpSession
public MockHttpSession(javax.servlet.ServletContext servletContext) Create a new MockHttpSession.- Parameters:
servletContext- the ServletContext that the session runs in
-
MockHttpSession
Create a new MockHttpSession.- Parameters:
servletContext- the ServletContext that the session runs inid- a unique identifier for this session
-
-
Method Details
-
getCreationTime
public long getCreationTime()- Specified by:
getCreationTimein interfacejavax.servlet.http.HttpSession
-
getId
- Specified by:
getIdin interfacejavax.servlet.http.HttpSession
-
changeSessionId
As of Servlet 3.1 the id of a session can be changed.- Returns:
- the new session id.
- Since:
- 4.0.3
-
access
public void access() -
getLastAccessedTime
public long getLastAccessedTime()- Specified by:
getLastAccessedTimein interfacejavax.servlet.http.HttpSession
-
getServletContext
public javax.servlet.ServletContext getServletContext()- Specified by:
getServletContextin interfacejavax.servlet.http.HttpSession
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int interval) - Specified by:
setMaxInactiveIntervalin interfacejavax.servlet.http.HttpSession
-
getMaxInactiveInterval
public int getMaxInactiveInterval()- Specified by:
getMaxInactiveIntervalin interfacejavax.servlet.http.HttpSession
-
getSessionContext
public javax.servlet.http.HttpSessionContext getSessionContext()- Specified by:
getSessionContextin interfacejavax.servlet.http.HttpSession
-
getAttribute
- Specified by:
getAttributein interfacejavax.servlet.http.HttpSession
-
getValue
- Specified by:
getValuein interfacejavax.servlet.http.HttpSession
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejavax.servlet.http.HttpSession
-
getValueNames
- Specified by:
getValueNamesin interfacejavax.servlet.http.HttpSession
-
setAttribute
- Specified by:
setAttributein interfacejavax.servlet.http.HttpSession
-
putValue
- Specified by:
putValuein interfacejavax.servlet.http.HttpSession
-
removeAttribute
- Specified by:
removeAttributein interfacejavax.servlet.http.HttpSession
-
removeValue
- Specified by:
removeValuein interfacejavax.servlet.http.HttpSession
-
clearAttributes
public void clearAttributes()Clear all of this session's attributes. -
invalidate
public void invalidate()Invalidates this session then unbinds any objects bound to it.- Specified by:
invalidatein interfacejavax.servlet.http.HttpSession- Throws:
IllegalStateException- if this method is called on an already invalidated session
-
isInvalid
public boolean isInvalid() -
setNew
public void setNew(boolean value) -
isNew
public boolean isNew()- Specified by:
isNewin interfacejavax.servlet.http.HttpSession
-
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
-
deserializeState
Deserialize the attributes of this session from a state object created byserializeState().- Parameters:
state- a representation of this session's serialized state
-