@NotThreadSafe public class MockHttpSession extends Object implements javax.servlet.http.HttpSession
HttpSession.| Modifier and Type | Field and Description |
|---|---|
static String |
SESSION_COOKIE_NAME |
| Constructor and Description |
|---|
MockHttpSession()
Create a new MockHttpSession with a default
MockServletContext. |
MockHttpSession(javax.servlet.ServletContext aServletContext)
Create a new MockHttpSession.
|
MockHttpSession(javax.servlet.ServletContext aServletContext,
String sID)
Create a new MockHttpSession.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearAttributes()
Clear all of this session's attributes.
|
void |
deserializeState(Serializable aState)
Deserialize the attributes of this session from a state object created by
serializeState(). |
void |
doAccess() |
Object |
getAttribute(String sName) |
Enumeration<String> |
getAttributeNames() |
long |
getCreationTime() |
String |
getId() |
long |
getLastAccessedTime() |
int |
getMaxInactiveInterval() |
javax.servlet.ServletContext |
getServletContext() |
javax.servlet.http.HttpSessionContext |
getSessionContext()
Deprecated.
|
Object |
getValue(String sName)
Deprecated.
|
String[] |
getValueNames()
Deprecated.
|
void |
invalidate() |
boolean |
isInvalid() |
boolean |
isNew() |
void |
putValue(String sName,
Object aValue)
Deprecated.
|
void |
removeAttribute(String sName) |
void |
removeValue(String sName)
Deprecated.
|
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 sName,
Object aValue) |
void |
setMaxInactiveInterval(int nInterval) |
void |
setNew(boolean bIsNew) |
String |
toString() |
public static final String SESSION_COOKIE_NAME
public MockHttpSession()
MockServletContext.MockServletContextpublic MockHttpSession(@Nullable javax.servlet.ServletContext aServletContext)
aServletContext - the ServletContext that the session runs inpublic long getCreationTime()
getCreationTime in interface javax.servlet.http.HttpSession@Nonnull @Nonempty public String getId()
getId in interface javax.servlet.http.HttpSessionpublic void doAccess()
public long getLastAccessedTime()
getLastAccessedTime in interface javax.servlet.http.HttpSession@Nonnull public javax.servlet.ServletContext getServletContext()
getServletContext in interface javax.servlet.http.HttpSessionpublic void setMaxInactiveInterval(int nInterval)
setMaxInactiveInterval in interface javax.servlet.http.HttpSessionpublic int getMaxInactiveInterval()
getMaxInactiveInterval in interface javax.servlet.http.HttpSession@Deprecated @UnsupportedOperation public javax.servlet.http.HttpSessionContext getSessionContext()
getSessionContext in interface javax.servlet.http.HttpSession@Nullable public Object getAttribute(@Nonnull String sName)
getAttribute in interface javax.servlet.http.HttpSession@Deprecated public Object getValue(@Nonnull String sName)
getValue in interface javax.servlet.http.HttpSession@Nonnull public Enumeration<String> getAttributeNames()
getAttributeNames in interface javax.servlet.http.HttpSession@Deprecated @Nonnull public String[] getValueNames()
getValueNames in interface javax.servlet.http.HttpSessionpublic void setAttribute(@Nonnull String sName, @Nullable Object aValue)
setAttribute in interface javax.servlet.http.HttpSession@Deprecated public void putValue(@Nonnull String sName, @Nullable Object aValue)
putValue in interface javax.servlet.http.HttpSessionpublic void removeAttribute(@Nonnull String sName)
removeAttribute in interface javax.servlet.http.HttpSession@Deprecated public void removeValue(@Nonnull String sName)
removeValue in interface javax.servlet.http.HttpSessionpublic void clearAttributes()
public void invalidate()
invalidate in interface javax.servlet.http.HttpSessionpublic boolean isInvalid()
public void setNew(boolean bIsNew)
public boolean isNew()
isNew in interface javax.servlet.http.HttpSession@Nonnull public Serializable serializeState()
public void deserializeState(@Nonnull Serializable aState)
serializeState().aState - a representation of this session's serialized stateCopyright © 2016–2019 Philip Helger. All rights reserved.