Package com.helger.servlet.mock
Class MockHttpSession
- java.lang.Object
-
- com.helger.servlet.mock.MockHttpSession
-
- All Implemented Interfaces:
jakarta.servlet.http.HttpSession
@NotThreadSafe public class MockHttpSession extends Object implements jakarta.servlet.http.HttpSession
Mock implementation ofHttpSession.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static StringSESSION_COOKIE_NAME
-
Constructor Summary
Constructors Constructor Description MockHttpSession()Create a new MockHttpSession with a defaultMockServletContext.MockHttpSession(jakarta.servlet.ServletContext aServletContext)Create a new MockHttpSession.MockHttpSession(jakarta.servlet.ServletContext aServletContext, String sID)Create a new MockHttpSession.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearAttributes()Clear all of this session's attributes.voiddoAccess()ObjectgetAttribute(String sName)Enumeration<String>getAttributeNames()longgetCreationTime()StringgetId()longgetLastAccessedTime()intgetMaxInactiveInterval()jakarta.servlet.ServletContextgetServletContext()jakarta.servlet.http.HttpSessionContextgetSessionContext()Deprecated.ObjectgetValue(String sName)Deprecated.String[]getValueNames()Deprecated.voidinvalidate()booleanisInvalid()booleanisNew()voidputValue(String sName, Object aValue)Deprecated.voidremoveAttribute(String sName)voidremoveValue(String sName)Deprecated.voidsetAttribute(String sName, Object aValue)voidsetMaxInactiveInterval(int nInterval)voidsetNew(boolean bIsNew)StringtoString()
-
-
-
Field Detail
-
SESSION_COOKIE_NAME
public static final String SESSION_COOKIE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MockHttpSession
public MockHttpSession()
Create a new MockHttpSession with a defaultMockServletContext.- See Also:
MockServletContext
-
MockHttpSession
public MockHttpSession(@Nullable jakarta.servlet.ServletContext aServletContext)
Create a new MockHttpSession.- Parameters:
aServletContext- the ServletContext that the session runs in
-
-
Method Detail
-
getCreationTime
public long getCreationTime()
- Specified by:
getCreationTimein interfacejakarta.servlet.http.HttpSession
-
getId
@Nonnull @Nonempty public String getId()
- Specified by:
getIdin interfacejakarta.servlet.http.HttpSession
-
doAccess
public void doAccess()
-
getLastAccessedTime
public long getLastAccessedTime()
- Specified by:
getLastAccessedTimein interfacejakarta.servlet.http.HttpSession
-
getServletContext
@Nonnull public jakarta.servlet.ServletContext getServletContext()
- Specified by:
getServletContextin interfacejakarta.servlet.http.HttpSession
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int nInterval)
- Specified by:
setMaxInactiveIntervalin interfacejakarta.servlet.http.HttpSession
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
- Specified by:
getMaxInactiveIntervalin interfacejakarta.servlet.http.HttpSession
-
getSessionContext
@Deprecated(forRemoval=false) @UnsupportedOperation public jakarta.servlet.http.HttpSessionContext getSessionContext()
Deprecated.- Specified by:
getSessionContextin interfacejakarta.servlet.http.HttpSession
-
getAttribute
@Nullable public Object getAttribute(@Nonnull String sName)
- Specified by:
getAttributein interfacejakarta.servlet.http.HttpSession
-
getValue
@Deprecated(forRemoval=false) public Object getValue(@Nonnull String sName)
Deprecated.- Specified by:
getValuein interfacejakarta.servlet.http.HttpSession
-
getAttributeNames
@Nonnull public Enumeration<String> getAttributeNames()
- Specified by:
getAttributeNamesin interfacejakarta.servlet.http.HttpSession
-
getValueNames
@Deprecated(forRemoval=false) @Nonnull public String[] getValueNames()
Deprecated.- Specified by:
getValueNamesin interfacejakarta.servlet.http.HttpSession
-
setAttribute
public void setAttribute(@Nonnull String sName, @Nullable Object aValue)
- Specified by:
setAttributein interfacejakarta.servlet.http.HttpSession
-
putValue
@Deprecated(forRemoval=false) public void putValue(@Nonnull String sName, @Nullable Object aValue)
Deprecated.- Specified by:
putValuein interfacejakarta.servlet.http.HttpSession
-
removeAttribute
public void removeAttribute(@Nonnull String sName)
- Specified by:
removeAttributein interfacejakarta.servlet.http.HttpSession
-
removeValue
@Deprecated(forRemoval=false) public void removeValue(@Nonnull String sName)
Deprecated.- Specified by:
removeValuein interfacejakarta.servlet.http.HttpSession
-
clearAttributes
public void clearAttributes()
Clear all of this session's attributes.
-
invalidate
public void invalidate()
- Specified by:
invalidatein interfacejakarta.servlet.http.HttpSession
-
isInvalid
public boolean isInvalid()
-
setNew
public void setNew(boolean bIsNew)
-
isNew
public boolean isNew()
- Specified by:
isNewin interfacejakarta.servlet.http.HttpSession
-
-