Class MockHttpSession
- java.lang.Object
-
- org.apache.wicket.protocol.http.mock.MockHttpSession
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.http.HttpSession
public class MockHttpSession extends java.lang.Object implements javax.servlet.http.HttpSession, java.io.SerializableMock implementation of theWebSessioninterface 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 java.lang.ObjectgetAttribute(java.lang.String name)Get the attribute with the given name.java.util.Enumeration<java.lang.String>getAttributeNames()Get the names of the attributes in the session.longgetCreationTime()Get the creation time of the session.java.lang.StringgetId()Return the id of this session.longgetLastAccessedTime()Get the time the session was last accessed.intgetMaxInactiveInterval()NOT USED.javax.servlet.ServletContextgetServletContext()Return the servlet context for the session.javax.servlet.http.HttpSessionContextgetSessionContext()Deprecated.java.lang.ObjectgetValue(java.lang.String name)Deprecated.use getAttribute(String) insteadjava.lang.String[]getValueNames()Deprecated.use getAttributeNames() insteadvoidinvalidate()Invalidate the session.booleanisNew()Check if the session is new.booleanisTemporary()Indicates the state of the session.voidputValue(java.lang.String name, java.lang.Object o)Deprecated.Use setAttribute(String, Object) insteadvoidremoveAttribute(java.lang.String name)Remove an attribute.voidremoveValue(java.lang.String name)Deprecated.Use removeAttribute(String) insteadvoidsetAttribute(java.lang.String name, java.lang.Object o)Set an attribute.voidsetMaxInactiveInterval(int i)NOT USED.voidsetTemporary(boolean temporary)Changes the state of this session.voidtimestamp()Set the last accessed time for the session.
-
-
-
Method Detail
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Get the attribute with the given name.- Specified by:
getAttributein interfacejavax.servlet.http.HttpSession- Parameters:
name- The attribute name- Returns:
- The value or null
-
getAttributeNames
public java.util.Enumeration<java.lang.String> getAttributeNames()
Get the names of the attributes in the session.- Specified by:
getAttributeNamesin interfacejavax.servlet.http.HttpSession- Returns:
- The attribute names
-
getCreationTime
public long getCreationTime()
Get the creation time of the session.- Specified by:
getCreationTimein interfacejavax.servlet.http.HttpSession- Returns:
- The creation time
-
getId
public java.lang.String getId()
Return the id of this session.- Specified by:
getIdin interfacejavax.servlet.http.HttpSession- Returns:
- The id
-
getLastAccessedTime
public long getLastAccessedTime()
Get the time the session was last accessed.- Specified by:
getLastAccessedTimein interfacejavax.servlet.http.HttpSession- Returns:
- The last accessed time
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
NOT USED. Sessions never expire in the test harness.- Specified by:
getMaxInactiveIntervalin interfacejavax.servlet.http.HttpSession- Returns:
- Always returns 0
-
getServletContext
public javax.servlet.ServletContext getServletContext()
Return the servlet context for the session.- Specified by:
getServletContextin interfacejavax.servlet.http.HttpSession- Returns:
- The servlet context
-
getSessionContext
@Deprecated public javax.servlet.http.HttpSessionContext getSessionContext()
Deprecated.NOT USED.- Specified by:
getSessionContextin interfacejavax.servlet.http.HttpSession- Returns:
- Always null
-
getValue
@Deprecated public java.lang.Object getValue(java.lang.String name)
Deprecated.use getAttribute(String) insteadGet the value for the given name.- Specified by:
getValuein interfacejavax.servlet.http.HttpSession- Parameters:
name- The name- Returns:
- The value or null
-
getValueNames
@Deprecated public java.lang.String[] getValueNames()
Deprecated.use getAttributeNames() insteadGet the names of the values in the session.- Specified by:
getValueNamesin interfacejavax.servlet.http.HttpSession- Returns:
- The names of the attributes
-
invalidate
public void invalidate()
Invalidate the session.- Specified by:
invalidatein interfacejavax.servlet.http.HttpSession
-
isNew
public boolean isNew()
Check if the session is new.- Specified by:
isNewin interfacejavax.servlet.http.HttpSession- Returns:
- Always false
-
putValue
@Deprecated public void putValue(java.lang.String name, java.lang.Object o)Deprecated.Use setAttribute(String, Object) insteadSet a value.- Specified by:
putValuein interfacejavax.servlet.http.HttpSession- Parameters:
name- The name of the valueo- The value
-
removeAttribute
public void removeAttribute(java.lang.String name)
Remove an attribute.- Specified by:
removeAttributein interfacejavax.servlet.http.HttpSession- Parameters:
name- The name of the attribute
-
removeValue
@Deprecated public void removeValue(java.lang.String name)
Deprecated.Use removeAttribute(String) insteadRemove a value.- Specified by:
removeValuein interfacejavax.servlet.http.HttpSession- Parameters:
name- The name of the value
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object o)Set an attribute.- Specified by:
setAttributein 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:
setMaxInactiveIntervalin 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
-
-