net.sourceforge.stripes.mock
Class MockHttpSession

java.lang.Object
  extended by net.sourceforge.stripes.mock.MockHttpSession
All Implemented Interfaces:
HttpSession

public class MockHttpSession
extends Object
implements HttpSession

Simple mock implementation of HttpSession that implements most basic operations.

Since:
Stripes 1.1.1
Author:
Tim Fennell

Constructor Summary
MockHttpSession(ServletContext context)
          Default constructor which provides the session with access to the context.
 
Method Summary
 Object getAttribute(String key)
          Returns the value of the named attribute from an internal Map.
 Enumeration<String> getAttributeNames()
          Returns an enumeration of all the attribute names in the session.
 long getCreationTime()
          Returns the time in milliseconds when the session was created.
 String getId()
          Returns an ID that was randomly generated when the session was created.
 long getLastAccessedTime()
          Always returns the current time.
 int getMaxInactiveInterval()
          Always returns Integer.MAX_VALUE.
 ServletContext getServletContext()
          Provides access to the servlet context within which the session exists.
 HttpSessionContext getSessionContext()
          Deprecated method always returns null.
 Object getValue(String key)
          Deprecated method.
 String[] getValueNames()
          Returns a String[] of all the attribute names in session.
 void invalidate()
          Clears the set of attributes, but has no other effect.
 boolean isNew()
          Always returns false.
 void putValue(String key, Object value)
          Stores the value in session, replacing any existing value with the same key.
 void removeAttribute(String key)
          Removes any value stored in session with the key supplied.
 void removeValue(String key)
          Removes any value stored in session with the key supplied.
 void setAttribute(String key, Object value)
          Stores the value in session, replacing any existing value with the same key.
 void setMaxInactiveInterval(int i)
          Has no effect.
 void setServletContext(ServletContext context)
          Sets the servlet context within which the session exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockHttpSession

public MockHttpSession(ServletContext context)
Default constructor which provides the session with access to the context.

Method Detail

getCreationTime

public long getCreationTime()
Returns the time in milliseconds when the session was created.

Specified by:
getCreationTime in interface HttpSession

getId

public String getId()
Returns an ID that was randomly generated when the session was created.

Specified by:
getId in interface HttpSession

getLastAccessedTime

public long getLastAccessedTime()
Always returns the current time.

Specified by:
getLastAccessedTime in interface HttpSession

getServletContext

public ServletContext getServletContext()
Provides access to the servlet context within which the session exists.

Specified by:
getServletContext in interface HttpSession

setServletContext

public void setServletContext(ServletContext context)
Sets the servlet context within which the session exists.


setMaxInactiveInterval

public void setMaxInactiveInterval(int i)
Has no effect.

Specified by:
setMaxInactiveInterval in interface HttpSession

getMaxInactiveInterval

public int getMaxInactiveInterval()
Always returns Integer.MAX_VALUE.

Specified by:
getMaxInactiveInterval in interface HttpSession

getSessionContext

public HttpSessionContext getSessionContext()
Deprecated method always returns null.

Specified by:
getSessionContext in interface HttpSession

getAttribute

public Object getAttribute(String key)
Returns the value of the named attribute from an internal Map.

Specified by:
getAttribute in interface HttpSession

getValue

public Object getValue(String key)
Deprecated method. Use getAttribute() instead.

Specified by:
getValue in interface HttpSession

getAttributeNames

public Enumeration<String> getAttributeNames()
Returns an enumeration of all the attribute names in the session.

Specified by:
getAttributeNames in interface HttpSession

getValueNames

public String[] getValueNames()
Returns a String[] of all the attribute names in session. Deprecated.

Specified by:
getValueNames in interface HttpSession

setAttribute

public void setAttribute(String key,
                         Object value)
Stores the value in session, replacing any existing value with the same key.

Specified by:
setAttribute in interface HttpSession

putValue

public void putValue(String key,
                     Object value)
Stores the value in session, replacing any existing value with the same key.

Specified by:
putValue in interface HttpSession

removeAttribute

public void removeAttribute(String key)
Removes any value stored in session with the key supplied.

Specified by:
removeAttribute in interface HttpSession

removeValue

public void removeValue(String key)
Removes any value stored in session with the key supplied.

Specified by:
removeValue in interface HttpSession

invalidate

public void invalidate()
Clears the set of attributes, but has no other effect.

Specified by:
invalidate in interface HttpSession

isNew

public boolean isNew()
Always returns false.

Specified by:
isNew in interface HttpSession


? Copyright 2005-2006, Stripes Development Team.