Package com.oorian.test
Class TestHttpSession
java.lang.Object
com.oorian.test.TestHttpSession
- All Implemented Interfaces:
OorianHttpSession
In-memory implementation of
OorianHttpSession for headless testing.
Stores session attributes in a HashMap and generates a random session ID.
All session operations work without a servlet container.
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TestHttpSession with a random UUID as the session ID.Creates a new TestHttpSession with the specified session ID. -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Returns the session attribute with the specified name.Returns an enumeration of all attribute names in this session.longReturns the time the session was created.getId()Returns the unique session identifier.longReturns the time of last client access.intReturns the maximum inactive interval for this session.voidInvalidates this session.booleanChecks whether this session has been invalidated.booleanisNew()Checks if the session was newly created.voidremoveAttribute(String name) Removes a session attribute.voidsetAttribute(String name, Object value) Sets a session attribute.voidsetMaxInactiveInterval(int interval) Sets the maximum time interval between requests before the session expires.voidsetNew(boolean isNew) Sets whether this session is new.
-
Constructor Details
-
TestHttpSession
public TestHttpSession()Creates a new TestHttpSession with a random UUID as the session ID. -
TestHttpSession
Creates a new TestHttpSession with the specified session ID.- Parameters:
id- the session ID
-
-
Method Details
-
getId
Description copied from interface:OorianHttpSessionReturns the unique session identifier.- Specified by:
getIdin interfaceOorianHttpSession- Returns:
- the session ID
-
getCreationTime
public long getCreationTime()Description copied from interface:OorianHttpSessionReturns the time the session was created.- Specified by:
getCreationTimein interfaceOorianHttpSession- Returns:
- the creation time in milliseconds since epoch
-
getLastAccessedTime
public long getLastAccessedTime()Description copied from interface:OorianHttpSessionReturns the time of last client access.- Specified by:
getLastAccessedTimein interfaceOorianHttpSession- Returns:
- the last access time in milliseconds since epoch
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int interval) Description copied from interface:OorianHttpSessionSets the maximum time interval between requests before the session expires.- Specified by:
setMaxInactiveIntervalin interfaceOorianHttpSession- Parameters:
interval- the interval in seconds
-
getMaxInactiveInterval
public int getMaxInactiveInterval()Description copied from interface:OorianHttpSessionReturns the maximum inactive interval for this session.- Specified by:
getMaxInactiveIntervalin interfaceOorianHttpSession- Returns:
- the interval in seconds
-
getAttribute
Description copied from interface:OorianHttpSessionReturns the session attribute with the specified name.- Specified by:
getAttributein interfaceOorianHttpSession- Parameters:
name- the attribute name- Returns:
- the attribute value, or null if not found
-
getAttributeNames
Description copied from interface:OorianHttpSessionReturns an enumeration of all attribute names in this session.- Specified by:
getAttributeNamesin interfaceOorianHttpSession- Returns:
- enumeration of attribute names
-
setAttribute
Description copied from interface:OorianHttpSessionSets a session attribute.- Specified by:
setAttributein interfaceOorianHttpSession- Parameters:
name- the attribute namevalue- the attribute value
-
removeAttribute
Description copied from interface:OorianHttpSessionRemoves a session attribute.- Specified by:
removeAttributein interfaceOorianHttpSession- Parameters:
name- the attribute name to remove
-
invalidate
public void invalidate()Description copied from interface:OorianHttpSessionInvalidates this session.- Specified by:
invalidatein interfaceOorianHttpSession
-
isNew
public boolean isNew()Description copied from interface:OorianHttpSessionChecks if the session was newly created.- Specified by:
isNewin interfaceOorianHttpSession- Returns:
- true if the session is new
-
setNew
public void setNew(boolean isNew) Sets whether this session is new.- Parameters:
isNew-trueif the session is new
-
isInvalidated
public boolean isInvalidated()Checks whether this session has been invalidated.- Returns:
trueif the session has been invalidated
-