类 MockHttpSession
java.lang.Object
cn.taketoday.mock.web.MockHttpSession
- 所有已实现的接口:
jakarta.servlet.http.HttpSession
Mock implementation of the
HttpSession interface.
@since 4.0this set of mocks is designed on a Servlet 4.0 baseline.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Rod Johnson, Mark Fisher, Sam Brannen, Vedran Pavic
-
字段概要
字段 -
构造器概要
构造器构造器说明Create a new MockHttpSession with a defaultMockServletContext.MockHttpSession(jakarta.servlet.ServletContext servletContext) Create a new MockHttpSession.MockHttpSession(jakarta.servlet.ServletContext servletContext, String id) Create a new MockHttpSession. -
方法概要
修饰符和类型方法说明voidaccess()private voidConvenience method for asserting that this session has not been invalidated.As of Servlet 3.1, the id of a session can be changed.voidClear all of this session's attributes.voiddeserializeState(Serializable state) Deserialize the attributes of this session from a state object created byserializeState().getAttribute(String name) longgetId()longintjakarta.servlet.ServletContextvoidInvalidates this session then unbinds any objects bound to it.booleanbooleanisNew()voidremoveAttribute(String name) Serialize the attributes of this session into an object that can be turned into a byte array with standard Java serialization.voidsetAttribute(String name, Object value) voidsetMaxInactiveInterval(int interval) voidsetNew(boolean value)
-
字段详细资料
-
SESSION_COOKIE_NAME
The session cookie name.- 另请参阅:
-
nextId
private static int nextId -
id
-
creationTime
private final long creationTime -
maxInactiveInterval
private int maxInactiveInterval -
lastAccessedTime
private long lastAccessedTime -
servletContext
private final jakarta.servlet.ServletContext servletContext -
attributes
-
invalid
private boolean invalid -
isNew
private boolean isNew
-
-
构造器详细资料
-
MockHttpSession
public MockHttpSession()Create a new MockHttpSession with a defaultMockServletContext.- 另请参阅:
-
MockHttpSession
public MockHttpSession(@Nullable jakarta.servlet.ServletContext servletContext) Create a new MockHttpSession.- 参数:
servletContext- the ServletContext that the session runs in
-
MockHttpSession
public MockHttpSession(@Nullable jakarta.servlet.ServletContext servletContext, @Nullable String id) Create a new MockHttpSession.- 参数:
servletContext- the ServletContext that the session runs inid- a unique identifier for this session
-
-
方法详细资料
-
getCreationTime
public long getCreationTime()- 指定者:
getCreationTime在接口中jakarta.servlet.http.HttpSession
-
getId
- 指定者:
getId在接口中jakarta.servlet.http.HttpSession
-
changeSessionId
As of Servlet 3.1, the id of a session can be changed.- 返回:
- the new session id
-
access
public void access() -
getLastAccessedTime
public long getLastAccessedTime()- 指定者:
getLastAccessedTime在接口中jakarta.servlet.http.HttpSession
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()- 指定者:
getServletContext在接口中jakarta.servlet.http.HttpSession
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int interval) - 指定者:
setMaxInactiveInterval在接口中jakarta.servlet.http.HttpSession
-
getMaxInactiveInterval
public int getMaxInactiveInterval()- 指定者:
getMaxInactiveInterval在接口中jakarta.servlet.http.HttpSession
-
getAttribute
- 指定者:
getAttribute在接口中jakarta.servlet.http.HttpSession
-
getAttributeNames
- 指定者:
getAttributeNames在接口中jakarta.servlet.http.HttpSession
-
setAttribute
- 指定者:
setAttribute在接口中jakarta.servlet.http.HttpSession
-
removeAttribute
- 指定者:
removeAttribute在接口中jakarta.servlet.http.HttpSession
-
clearAttributes
public void clearAttributes()Clear all of this session's attributes. -
invalidate
public void invalidate()Invalidates this session then unbinds any objects bound to it.- 指定者:
invalidate在接口中jakarta.servlet.http.HttpSession- 抛出:
IllegalStateException- if this method is called on an already invalidated session
-
isInvalid
public boolean isInvalid() -
assertIsValid
private void assertIsValid()Convenience method for asserting that this session has not been invalidated.- 抛出:
IllegalStateException- if this session has been invalidated
-
setNew
public void setNew(boolean value) -
isNew
public boolean isNew()- 指定者:
isNew在接口中jakarta.servlet.http.HttpSession
-
serializeState
Serialize the attributes of this session into an object that can be turned into a byte array with standard Java serialization.- 返回:
- a representation of this session's serialized state
-
deserializeState
Deserialize the attributes of this session from a state object created byserializeState().- 参数:
state- a representation of this session's serialized state
-