Class MockHttpSession
- java.lang.Object
-
- org.apache.wicket.protocol.http.mock.MockHttpSession
-
- All Implemented Interfaces:
Serializable
,javax.servlet.http.HttpSession
public class MockHttpSession extends Object implements javax.servlet.http.HttpSession, Serializable
Mock implementation of theWebSession
interface for use by the test harnesses.- Author:
- Chris Turner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MockHttpSession(javax.servlet.ServletContext context)
Create the session.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
getAttribute(String name)
Get the attribute with the given name.Enumeration<String>
getAttributeNames()
Get the names of the attributes in the session.long
getCreationTime()
Get the creation time of the session.String
getId()
Return the id of this session.long
getLastAccessedTime()
Get the time the session was last accessed.int
getMaxInactiveInterval()
NOT USED.javax.servlet.ServletContext
getServletContext()
Return the servlet context for the session.javax.servlet.http.HttpSessionContext
getSessionContext()
Deprecated.Object
getValue(String name)
Deprecated.use getAttribute(String) insteadString[]
getValueNames()
Deprecated.use getAttributeNames() insteadvoid
invalidate()
Invalidate the session.boolean
isNew()
Check if the session is new.boolean
isTemporary()
Indicates the state of the session.void
putValue(String name, Object o)
Deprecated.Use setAttribute(String, Object) insteadvoid
removeAttribute(String name)
Remove an attribute.void
removeValue(String name)
Deprecated.Use removeAttribute(String) insteadvoid
setAttribute(String name, Object o)
Set an attribute.void
setMaxInactiveInterval(int i)
NOT USED.void
setTemporary(boolean temporary)
Changes the state of this session.void
timestamp()
Set the last accessed time for the session.
-
-
-
Constructor Detail
-
MockHttpSession
public MockHttpSession(javax.servlet.ServletContext context)
Create the session.- Parameters:
context
-
-
-
Method Detail
-
getAttribute
public Object getAttribute(String name)
Get the attribute with the given name.- Specified by:
getAttribute
in interfacejavax.servlet.http.HttpSession
- Parameters:
name
- The attribute name- Returns:
- The value or null
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Get the names of the attributes in the session.- Specified by:
getAttributeNames
in interfacejavax.servlet.http.HttpSession
- Returns:
- The attribute names
-
getCreationTime
public long getCreationTime()
Get the creation time of the session.- Specified by:
getCreationTime
in interfacejavax.servlet.http.HttpSession
- Returns:
- The creation time
-
getId
public String getId()
Return the id of this session.- Specified by:
getId
in interfacejavax.servlet.http.HttpSession
- Returns:
- The id
-
getLastAccessedTime
public long getLastAccessedTime()
Get the time the session was last accessed.- Specified by:
getLastAccessedTime
in interfacejavax.servlet.http.HttpSession
- Returns:
- The last accessed time
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
NOT USED. Sessions never expire in the test harness.- Specified by:
getMaxInactiveInterval
in interfacejavax.servlet.http.HttpSession
- Returns:
- Always returns 0
-
getServletContext
public javax.servlet.ServletContext getServletContext()
Return the servlet context for the session.- Specified by:
getServletContext
in interfacejavax.servlet.http.HttpSession
- Returns:
- The servlet context
-
getSessionContext
@Deprecated public javax.servlet.http.HttpSessionContext getSessionContext()
Deprecated.NOT USED.- Specified by:
getSessionContext
in interfacejavax.servlet.http.HttpSession
- Returns:
- Always null
-
getValue
@Deprecated public Object getValue(String name)
Deprecated.use getAttribute(String) insteadGet the value for the given name.- Specified by:
getValue
in interfacejavax.servlet.http.HttpSession
- Parameters:
name
- The name- Returns:
- The value or null
-
getValueNames
@Deprecated public String[] getValueNames()
Deprecated.use getAttributeNames() insteadGet the names of the values in the session.- Specified by:
getValueNames
in interfacejavax.servlet.http.HttpSession
- Returns:
- The names of the attributes
-
invalidate
public void invalidate()
Invalidate the session.- Specified by:
invalidate
in interfacejavax.servlet.http.HttpSession
-
isNew
public boolean isNew()
Check if the session is new.- Specified by:
isNew
in interfacejavax.servlet.http.HttpSession
- Returns:
- Always false
-
putValue
@Deprecated public void putValue(String name, Object o)
Deprecated.Use setAttribute(String, Object) insteadSet a value.- Specified by:
putValue
in interfacejavax.servlet.http.HttpSession
- Parameters:
name
- The name of the valueo
- The value
-
removeAttribute
public void removeAttribute(String name)
Remove an attribute.- Specified by:
removeAttribute
in interfacejavax.servlet.http.HttpSession
- Parameters:
name
- The name of the attribute
-
removeValue
@Deprecated public void removeValue(String name)
Deprecated.Use removeAttribute(String) insteadRemove a value.- Specified by:
removeValue
in interfacejavax.servlet.http.HttpSession
- Parameters:
name
- The name of the value
-
setAttribute
public void setAttribute(String name, Object o)
Set an attribute.- Specified by:
setAttribute
in interfacejavax.servlet.http.HttpSession
- Parameters:
name
- The name of the attribute to seto
- The value to set
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int i)
NOT USED. Sessions never expire in the test harness.- Specified by:
setMaxInactiveInterval
in interfacejavax.servlet.http.HttpSession
- Parameters:
i
- The value
-
timestamp
public void timestamp()
Set the last accessed time for the session.
-
isTemporary
public final boolean isTemporary()
Indicates the state of the session. Temporary or persisted.- Returns:
- true if this is a temporary session, false otherwise
-
setTemporary
public final void setTemporary(boolean temporary)
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
-
-