Class MockHttpSession
java.lang.Object
org.apache.wicket.protocol.http.mock.MockHttpSession
- All Implemented Interfaces:
jakarta.servlet.http.HttpSession
,Serializable
public class MockHttpSession
extends Object
implements jakarta.servlet.http.HttpSession, Serializable
Mock implementation of the
WebSession
interface for use by the test harnesses.- Author:
- Chris Turner
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetAttribute
(String name) Get the attribute with the given name.Get the names of the attributes in the session.long
Get the creation time of the session.getId()
Return the id of this session.long
Get the time the session was last accessed.int
NOT USED.jakarta.servlet.ServletContext
Return the servlet context for the session.void
Invalidate the session.boolean
isNew()
Check if the session is new.final boolean
Indicates the state of the session.void
removeAttribute
(String name) Remove an attribute.void
setAttribute
(String name, Object o) Set an attribute.void
setMaxInactiveInterval
(int i) NOT USED.final void
setTemporary
(boolean temporary) Changes the state of this session.void
Set the last accessed time for the session.
-
Constructor Details
-
MockHttpSession
Create the session.- Parameters:
context
-
-
-
Method Details
-
getAttribute
Get the attribute with the given name.- Specified by:
getAttribute
in interfacejakarta.servlet.http.HttpSession
- Parameters:
name
- The attribute name- Returns:
- The value or null
-
getAttributeNames
Get the names of the attributes in the session.- Specified by:
getAttributeNames
in interfacejakarta.servlet.http.HttpSession
- Returns:
- The attribute names
-
getCreationTime
Get the creation time of the session.- Specified by:
getCreationTime
in interfacejakarta.servlet.http.HttpSession
- Returns:
- The creation time
-
getId
Return the id of this session.- Specified by:
getId
in interfacejakarta.servlet.http.HttpSession
- Returns:
- The id
-
getLastAccessedTime
Get the time the session was last accessed.- Specified by:
getLastAccessedTime
in interfacejakarta.servlet.http.HttpSession
- Returns:
- The last accessed time
-
getMaxInactiveInterval
NOT USED. Sessions never expire in the test harness.- Specified by:
getMaxInactiveInterval
in interfacejakarta.servlet.http.HttpSession
- Returns:
- Always returns 0
-
getServletContext
Return the servlet context for the session.- Specified by:
getServletContext
in interfacejakarta.servlet.http.HttpSession
- Returns:
- The servlet context
-
invalidate
Invalidate the session.- Specified by:
invalidate
in interfacejakarta.servlet.http.HttpSession
-
isNew
Check if the session is new.- Specified by:
isNew
in interfacejakarta.servlet.http.HttpSession
- Returns:
- Always false
-
removeAttribute
Remove an attribute.- Specified by:
removeAttribute
in interfacejakarta.servlet.http.HttpSession
- Parameters:
name
- The name of the attribute
-
setAttribute
Set an attribute.- Specified by:
setAttribute
in interfacejakarta.servlet.http.HttpSession
- Parameters:
name
- The name of the attribute to seto
- The value to set
-
setMaxInactiveInterval
NOT USED. Sessions never expire in the test harness.- Specified by:
setMaxInactiveInterval
in interfacejakarta.servlet.http.HttpSession
- Parameters:
i
- The value
-
timestamp
Set the last accessed time for the session. -
isTemporary
Indicates the state of the session. Temporary or persisted.- Returns:
- true if this is a temporary session, false otherwise
-
setTemporary
Changes the state of this session. Temporary or persisted. Upon creation all sessions are temporary.- Parameters:
temporary
- true, for a temporary session, false for a persisted session
-