public class MockHttpSession extends Object implements javax.servlet.http.HttpSession
Mock implementation of HttpSession
.
Constructor and Description |
---|
MockHttpSession()
Configure a default instance.
|
MockHttpSession(javax.servlet.ServletContext servletContext)
Configure a session instance associated with the specified
servlet context.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributeListener(javax.servlet.http.HttpSessionAttributeListener listener)
Add a new listener instance that should be notified about
attribute changes.
|
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 |
setId(String id)
Set the session identifier of this session.
|
void |
setMaxInactiveInterval(int interval) |
void |
setServletContext(javax.servlet.ServletContext servletContext)
Set the ServletContext associated with this session.
|
public MockHttpSession()
Configure a default instance.
public MockHttpSession(javax.servlet.ServletContext servletContext)
Configure a session instance associated with the specified servlet context.
servletContext
- The associated servlet contextpublic void addAttributeListener(javax.servlet.http.HttpSessionAttributeListener listener)
Add a new listener instance that should be notified about attribute changes.
listener
- The new listener to be addedpublic void setServletContext(javax.servlet.ServletContext servletContext)
Set the ServletContext associated with this session.
servletContext
- The associated servlet contextpublic void setId(String id)
Set the session identifier of this session.
id
- The new session identifierpublic 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 © 2004-2013 Apache Software Foundation. All Rights Reserved.