Class TestHttpSession

java.lang.Object
com.oorian.test.TestHttpSession
All Implemented Interfaces:
OorianHttpSession

public class TestHttpSession extends Object implements 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 Details

    • TestHttpSession

      public TestHttpSession()
      Creates a new TestHttpSession with a random UUID as the session ID.
    • TestHttpSession

      public TestHttpSession(String id)
      Creates a new TestHttpSession with the specified session ID.
      Parameters:
      id - the session ID
  • Method Details

    • getId

      public String getId()
      Description copied from interface: OorianHttpSession
      Returns the unique session identifier.
      Specified by:
      getId in interface OorianHttpSession
      Returns:
      the session ID
    • getCreationTime

      public long getCreationTime()
      Description copied from interface: OorianHttpSession
      Returns the time the session was created.
      Specified by:
      getCreationTime in interface OorianHttpSession
      Returns:
      the creation time in milliseconds since epoch
    • getLastAccessedTime

      public long getLastAccessedTime()
      Description copied from interface: OorianHttpSession
      Returns the time of last client access.
      Specified by:
      getLastAccessedTime in interface OorianHttpSession
      Returns:
      the last access time in milliseconds since epoch
    • setMaxInactiveInterval

      public void setMaxInactiveInterval(int interval)
      Description copied from interface: OorianHttpSession
      Sets the maximum time interval between requests before the session expires.
      Specified by:
      setMaxInactiveInterval in interface OorianHttpSession
      Parameters:
      interval - the interval in seconds
    • getMaxInactiveInterval

      public int getMaxInactiveInterval()
      Description copied from interface: OorianHttpSession
      Returns the maximum inactive interval for this session.
      Specified by:
      getMaxInactiveInterval in interface OorianHttpSession
      Returns:
      the interval in seconds
    • getAttribute

      public Object getAttribute(String name)
      Description copied from interface: OorianHttpSession
      Returns the session attribute with the specified name.
      Specified by:
      getAttribute in interface OorianHttpSession
      Parameters:
      name - the attribute name
      Returns:
      the attribute value, or null if not found
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
      Description copied from interface: OorianHttpSession
      Returns an enumeration of all attribute names in this session.
      Specified by:
      getAttributeNames in interface OorianHttpSession
      Returns:
      enumeration of attribute names
    • setAttribute

      public void setAttribute(String name, Object value)
      Description copied from interface: OorianHttpSession
      Sets a session attribute.
      Specified by:
      setAttribute in interface OorianHttpSession
      Parameters:
      name - the attribute name
      value - the attribute value
    • removeAttribute

      public void removeAttribute(String name)
      Description copied from interface: OorianHttpSession
      Removes a session attribute.
      Specified by:
      removeAttribute in interface OorianHttpSession
      Parameters:
      name - the attribute name to remove
    • invalidate

      public void invalidate()
      Description copied from interface: OorianHttpSession
      Invalidates this session.
      Specified by:
      invalidate in interface OorianHttpSession
    • isNew

      public boolean isNew()
      Description copied from interface: OorianHttpSession
      Checks if the session was newly created.
      Specified by:
      isNew in interface OorianHttpSession
      Returns:
      true if the session is new
    • setNew

      public void setNew(boolean isNew)
      Sets whether this session is new.
      Parameters:
      isNew - true if the session is new
    • isInvalidated

      public boolean isInvalidated()
      Checks whether this session has been invalidated.
      Returns:
      true if the session has been invalidated