public class MockHttpSession extends Object implements javax.servlet.http.HttpSession
Mock HttpSession object for low-level unit tests of Struts controller components. Coarser grained tests should be implemented in terms of the Cactus framework, instead of the mock object classes.
WARNING - Only the minimal set of methods needed to
create unit tests is provided, plus additional methods to configure this
object as necessary. Methods for unsupported operations will throw
UnsupportedOperationException
.
WARNING - Because unit tests operate in a single threaded environment, no synchronization is performed.
Modifier and Type | Field and Description |
---|---|
protected HashMap |
attributes
The set of session attributes.
|
protected javax.servlet.ServletContext |
servletContext
The ServletContext with which we are associated.
|
Constructor and Description |
---|
MockHttpSession() |
MockHttpSession(javax.servlet.ServletContext servletContext) |
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(String name) |
Enumeration |
getAttributeNames() |
long |
getCreationTime() |
String |
getId() |
long |
getLastAccessedTime() |
int |
getMaxInactiveInterval() |
javax.servlet.ServletContext |
getServletContext() |
javax.servlet.http.HttpSessionContext |
getSessionContext() |
Object |
getValue(String name) |
String[] |
getValueNames() |
void |
invalidate() |
boolean |
isNew() |
void |
putValue(String name,
Object value) |
void |
removeAttribute(String name) |
void |
removeValue(String name) |
void |
setAttribute(String name,
Object value) |
void |
setMaxInactiveInterval(int interval) |
void |
setServletContext(javax.servlet.ServletContext servletContext) |
protected HashMap attributes
The set of session attributes.
protected javax.servlet.ServletContext servletContext
The ServletContext with which we are associated.
public MockHttpSession()
public MockHttpSession(javax.servlet.ServletContext servletContext)
public void setServletContext(javax.servlet.ServletContext servletContext)
public Object getAttribute(String name)
getAttribute
in interface javax.servlet.http.HttpSession
public Enumeration getAttributeNames()
getAttributeNames
in interface javax.servlet.http.HttpSession
public long getCreationTime()
getCreationTime
in interface javax.servlet.http.HttpSession
public String getId()
getId
in interface javax.servlet.http.HttpSession
public long getLastAccessedTime()
getLastAccessedTime
in interface javax.servlet.http.HttpSession
public int getMaxInactiveInterval()
getMaxInactiveInterval
in interface javax.servlet.http.HttpSession
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface javax.servlet.http.HttpSession
public javax.servlet.http.HttpSessionContext getSessionContext()
getSessionContext
in interface javax.servlet.http.HttpSession
public Object getValue(String name)
getValue
in interface javax.servlet.http.HttpSession
public String[] getValueNames()
getValueNames
in interface javax.servlet.http.HttpSession
public void invalidate()
invalidate
in interface javax.servlet.http.HttpSession
public boolean isNew()
isNew
in interface javax.servlet.http.HttpSession
public void putValue(String name, Object value)
putValue
in interface javax.servlet.http.HttpSession
public void removeAttribute(String name)
removeAttribute
in interface javax.servlet.http.HttpSession
public void removeValue(String name)
removeValue
in interface javax.servlet.http.HttpSession
public void setAttribute(String name, Object value)
setAttribute
in interface javax.servlet.http.HttpSession
public void setMaxInactiveInterval(int interval)
setMaxInactiveInterval
in interface javax.servlet.http.HttpSession
Copyright © 2000–2016 Apache Software Foundation. All rights reserved.