类 MockHttpSession

java.lang.Object
cn.taketoday.mock.web.MockHttpSession
所有已实现的接口:
jakarta.servlet.http.HttpSession
直接已知子类:
HtmlUnitRequestBuilder.HtmlUnitMockHttpSession

public class MockHttpSession extends Object implements 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
  • 字段详细资料

    • nextId

      private static int nextId
    • id

      private String id
    • creationTime

      private final long creationTime
    • maxInactiveInterval

      private int maxInactiveInterval
    • lastAccessedTime

      private long lastAccessedTime
    • servletContext

      private final jakarta.servlet.ServletContext servletContext
    • attributes

      private final Map<String,Object> attributes
    • invalid

      private boolean invalid
    • isNew

      private boolean isNew
  • 构造器详细资料

    • MockHttpSession

      public MockHttpSession()
      Create a new MockHttpSession with a default MockServletContext.
      另请参阅:
    • 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 in
      id - a unique identifier for this session
  • 方法详细资料

    • getCreationTime

      public long getCreationTime()
      指定者:
      getCreationTime 在接口中 jakarta.servlet.http.HttpSession
    • getId

      public String getId()
      指定者:
      getId 在接口中 jakarta.servlet.http.HttpSession
    • changeSessionId

      public String 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

      public Object getAttribute(String name)
      指定者:
      getAttribute 在接口中 jakarta.servlet.http.HttpSession
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
      指定者:
      getAttributeNames 在接口中 jakarta.servlet.http.HttpSession
    • setAttribute

      public void setAttribute(String name, @Nullable Object value)
      指定者:
      setAttribute 在接口中 jakarta.servlet.http.HttpSession
    • removeAttribute

      public void removeAttribute(String name)
      指定者:
      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

      public Serializable 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

      public void deserializeState(Serializable state)
      Deserialize the attributes of this session from a state object created by serializeState().
      参数:
      state - a representation of this session's serialized state