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:
-
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)
-
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.
-
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.
-
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.
-
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.
-
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.
-
getCreationTime
- Specified by:
getCreationTimein interfacejakarta.servlet.http.HttpSession
-
getId
- Specified by:
getIdin interfacejakarta.servlet.http.HttpSession
-
getLastAccessedTime
- Specified by:
getLastAccessedTimein interfacejakarta.servlet.http.HttpSession
-
getServletContext
- Specified by:
getServletContextin interfacejakarta.servlet.http.HttpSession
-
setMaxInactiveInterval
- Specified by:
setMaxInactiveIntervalin interfacejakarta.servlet.http.HttpSession
-
getMaxInactiveInterval
- Specified by:
getMaxInactiveIntervalin interfacejakarta.servlet.http.HttpSession
-
getAttribute
- Specified by:
getAttributein interfacejakarta.servlet.http.HttpSession
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejakarta.servlet.http.HttpSession
-
setAttribute
- Specified by:
setAttributein interfacejakarta.servlet.http.HttpSession
-
removeAttribute
- Specified by:
removeAttributein interfacejakarta.servlet.http.HttpSession
-
invalidate
- Specified by:
invalidatein interfacejakarta.servlet.http.HttpSession
-
isNew
- Specified by:
isNewin interfacejakarta.servlet.http.HttpSession
-