org.slim3.struts.test
Class MockHttpSession

java.lang.Object
  extended by org.slim3.struts.test.MockHttpSession
All Implemented Interfaces:
Serializable, HttpSession

public class MockHttpSession
extends Object
implements HttpSession, Serializable

A mock implementation for HttpSession.

Since:
3.0
Author:
higa
See Also:
Serialized Form

Field Summary
protected  Map<String,Object> attributeMap
          The map for the attributes.
protected  long creationTime
          The creation time.
protected  String id
          The identifier.
protected  long lastAccessedTime
          The last accessed time.
protected  int maxInactiveInterval
          The max inactive internal.
protected  boolean newFlag
          Whether this session is created by the current request.
protected  ServletContext servletContext
          The servlet context.
protected  boolean valid
          Whether this session is valid.
 
Constructor Summary
MockHttpSession(ServletContext servletContext)
          Constructor.
 
Method Summary
 Object getAttribute(String name)
           
 Enumeration<String> getAttributeNames()
           
 long getCreationTime()
           
 String getId()
           
 long getLastAccessedTime()
           
 int getMaxInactiveInterval()
           
 ServletContext getServletContext()
           
 HttpSessionContext getSessionContext()
           
 Object getValue(String name)
           
 String[] getValueNames()
           
 void invalidate()
           
 boolean isNew()
           
 boolean isValid()
          Determines if this session is valid.
 void putValue(String name, Object value)
           
 void removeAttribute(String name)
           
 void removeValue(String name)
           
 void setAttribute(String name, Object value)
           
 void setId(String id)
          Sets the identifier.
 void setMaxInactiveInterval(int maxInactiveInterval)
           
 void setNew(boolean newFlag)
          Sets the new flag.
 void updateLastAccessedTime()
          Reuses this session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

creationTime

protected final long creationTime
The creation time.


lastAccessedTime

protected long lastAccessedTime
The last accessed time.


servletContext

protected ServletContext servletContext
The servlet context.


id

protected String id
The identifier.


newFlag

protected boolean newFlag
Whether this session is created by the current request.


maxInactiveInterval

protected int maxInactiveInterval
The max inactive internal.


attributeMap

protected Map<String,Object> attributeMap
The map for the attributes.


valid

protected boolean valid
Whether this session is valid.

Constructor Detail

MockHttpSession

public MockHttpSession(ServletContext servletContext)
                throws NullPointerException
Constructor.

Parameters:
servletContext - the servlet context
Throws:
NullPointerException - if the servletContext parameter is null
Method Detail

getCreationTime

public long getCreationTime()
Specified by:
getCreationTime in interface HttpSession

getId

public String getId()
Specified by:
getId in interface HttpSession

setId

public void setId(String id)
Sets the identifier.

Parameters:
id - the identifier

getLastAccessedTime

public long getLastAccessedTime()
Specified by:
getLastAccessedTime in interface HttpSession
See Also:
HttpSession.getLastAccessedTime()

updateLastAccessedTime

public void updateLastAccessedTime()
Reuses this session.


getServletContext

public ServletContext getServletContext()
Specified by:
getServletContext in interface HttpSession

getMaxInactiveInterval

public int getMaxInactiveInterval()
Specified by:
getMaxInactiveInterval in interface HttpSession

setMaxInactiveInterval

public void setMaxInactiveInterval(int maxInactiveInterval)
Specified by:
setMaxInactiveInterval in interface HttpSession

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface HttpSession

setAttribute

public void setAttribute(String name,
                         Object value)
Specified by:
setAttribute in interface HttpSession

removeAttribute

public void removeAttribute(String name)
Specified by:
removeAttribute in interface HttpSession

getSessionContext

public HttpSessionContext getSessionContext()
Specified by:
getSessionContext in interface HttpSession

getValue

public Object getValue(String name)
Specified by:
getValue in interface HttpSession

getAttributeNames

public Enumeration<String> getAttributeNames()
Specified by:
getAttributeNames in interface HttpSession

getValueNames

public String[] getValueNames()
Specified by:
getValueNames in interface HttpSession

putValue

public void putValue(String name,
                     Object value)
Specified by:
putValue in interface HttpSession

removeValue

public void removeValue(String name)
Specified by:
removeValue in interface HttpSession

invalidate

public void invalidate()
Specified by:
invalidate in interface HttpSession

isNew

public boolean isNew()
Specified by:
isNew in interface HttpSession

setNew

public void setNew(boolean newFlag)
Sets the new flag.

Parameters:
newFlag - the new flag

isValid

public boolean isValid()
Determines if this session is valid.

Returns:
whether this session is valid.


Copyright © 2008-2009 The Slim3 project. All Rights Reserved.