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
-
Method Summary
Modifier and TypeMethodDescriptionstatic MockHttpSession
create()
Creates a new HTTP session.creationTime
(long value) Sets the creation time on this session.getAttribute
(String name) long
getId()
long
int
jakarta.servlet.ServletContext
Sets the id on this session.void
boolean
isNew()
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.void
removeAttribute
(String name) servletContext
(jakarta.servlet.ServletContext value) Sets the servlet context on this session.void
setAttribute
(String name, Object value) void
setMaxInactiveInterval
(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:
getCreationTime
in interfacejakarta.servlet.http.HttpSession
-
getId
- Specified by:
getId
in interfacejakarta.servlet.http.HttpSession
-
getLastAccessedTime
- Specified by:
getLastAccessedTime
in interfacejakarta.servlet.http.HttpSession
-
getServletContext
- Specified by:
getServletContext
in interfacejakarta.servlet.http.HttpSession
-
setMaxInactiveInterval
- Specified by:
setMaxInactiveInterval
in interfacejakarta.servlet.http.HttpSession
-
getMaxInactiveInterval
- Specified by:
getMaxInactiveInterval
in interfacejakarta.servlet.http.HttpSession
-
getAttribute
- Specified by:
getAttribute
in interfacejakarta.servlet.http.HttpSession
-
getAttributeNames
- Specified by:
getAttributeNames
in interfacejakarta.servlet.http.HttpSession
-
setAttribute
- Specified by:
setAttribute
in interfacejakarta.servlet.http.HttpSession
-
removeAttribute
- Specified by:
removeAttribute
in interfacejakarta.servlet.http.HttpSession
-
invalidate
- Specified by:
invalidate
in interfacejakarta.servlet.http.HttpSession
-
isNew
- Specified by:
isNew
in interfacejakarta.servlet.http.HttpSession
-