Package org.apache.juneau.rest.mock
Class MockHttpSession
java.lang.Object
org.apache.juneau.rest.mock.MockHttpSession
- All Implemented Interfaces:
jakarta.servlet.http.HttpSession
An implementation of
HttpSession for mocking purposes.
Session-based tests can use this API to create customized instances of HttpSession objects
that can be passed to the MockRestRequest.httpSession(HttpSession) method.
See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.servlet.http.HttpSession
jakarta.servlet.http.HttpSession.Accessor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MockHttpSessioncreate()Creates a new HTTP session.creationTime(long value) Sets the creation time on this session.getAttribute(String name) longgetId()longintjakarta.servlet.ServletContextSets the id on this session.voidbooleanisNew()isNew(boolean value) Sets the is-new value on this session.lastAccessedTime(long value) Sets the last-accessed time on this session.maxInactiveInterval(int value) Sets the max-inactive interval time on this session.voidremoveAttribute(String name) servletContext(jakarta.servlet.ServletContext value) Sets the servlet context on this session.voidsetAttribute(String name, Object value) voidsetMaxInactiveInterval(int value) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpSession
getAccessor
-
Constructor Details
-
MockHttpSession
public MockHttpSession()
-
-
Method Details
-
create
Creates a new HTTP session.- Returns:
- A new HTTP session.
-
creationTime
Sets the creation time on this session.Affects the results of calling
HttpSession.getCreationTime().- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
getAttribute
- Specified by:
getAttributein interfacejakarta.servlet.http.HttpSession
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejakarta.servlet.http.HttpSession
-
getCreationTime
- Specified by:
getCreationTimein interfacejakarta.servlet.http.HttpSession
-
getId
- Specified by:
getIdin interfacejakarta.servlet.http.HttpSession
-
getLastAccessedTime
- Specified by:
getLastAccessedTimein interfacejakarta.servlet.http.HttpSession
-
getMaxInactiveInterval
- Specified by:
getMaxInactiveIntervalin interfacejakarta.servlet.http.HttpSession
-
getServletContext
- Specified by:
getServletContextin interfacejakarta.servlet.http.HttpSession
-
id
Sets the id on this session.Affects the results of calling
HttpSession.getId().- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
invalidate
- Specified by:
invalidatein interfacejakarta.servlet.http.HttpSession
-
isNew
- Specified by:
isNewin interfacejakarta.servlet.http.HttpSession
-
isNew
Sets the is-new value on this session.Affects the results of calling
HttpSession.isNew().- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
lastAccessedTime
Sets the last-accessed time on this session.Affects the results of calling
HttpSession.getLastAccessedTime().- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
maxInactiveInterval
Sets the max-inactive interval time on this session.Affects the results of calling
HttpSession.getMaxInactiveInterval().- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
removeAttribute
- Specified by:
removeAttributein interfacejakarta.servlet.http.HttpSession
-
servletContext
Sets the servlet context on this session.Affects the results of calling
HttpSession.getServletContext().- Parameters:
value- The new value for this setting.- Returns:
- This object.
-
setAttribute
- Specified by:
setAttributein interfacejakarta.servlet.http.HttpSession
-
setMaxInactiveInterval
- Specified by:
setMaxInactiveIntervalin interfacejakarta.servlet.http.HttpSession
-