Class MockHttpSession

  • All Implemented Interfaces:
    jakarta.servlet.http.HttpSession

    @NotThreadSafe
    public class MockHttpSession
    extends Object
    implements jakarta.servlet.http.HttpSession
    Mock implementation of HttpSession.
    Author:
    Philip Helger
    • Constructor Detail

      • MockHttpSession

        public MockHttpSession​(@Nullable
                               jakarta.servlet.ServletContext aServletContext)
        Create a new MockHttpSession.
        Parameters:
        aServletContext - the ServletContext that the session runs in
      • MockHttpSession

        public MockHttpSession​(@Nullable
                               jakarta.servlet.ServletContext aServletContext,
                               @Nullable
                               String sID)
        Create a new MockHttpSession.
        Parameters:
        aServletContext - the ServletContext that the session runs in
        sID - a unique identifier for this session
    • Method Detail

      • getCreationTime

        public long getCreationTime()
        Specified by:
        getCreationTime in interface jakarta.servlet.http.HttpSession
      • getId

        @Nonnull
        @Nonempty
        public String getId()
        Specified by:
        getId in interface jakarta.servlet.http.HttpSession
      • doAccess

        public void doAccess()
      • getLastAccessedTime

        public long getLastAccessedTime()
        Specified by:
        getLastAccessedTime in interface jakarta.servlet.http.HttpSession
      • getServletContext

        @Nonnull
        public jakarta.servlet.ServletContext getServletContext()
        Specified by:
        getServletContext in interface jakarta.servlet.http.HttpSession
      • setMaxInactiveInterval

        public void setMaxInactiveInterval​(int nInterval)
        Specified by:
        setMaxInactiveInterval in interface jakarta.servlet.http.HttpSession
      • getMaxInactiveInterval

        public int getMaxInactiveInterval()
        Specified by:
        getMaxInactiveInterval in interface jakarta.servlet.http.HttpSession
      • getSessionContext

        @Deprecated(forRemoval=false)
        @UnsupportedOperation
        public jakarta.servlet.http.HttpSessionContext getSessionContext()
        Deprecated.
        Specified by:
        getSessionContext in interface jakarta.servlet.http.HttpSession
      • getAttribute

        @Nullable
        public Object getAttribute​(@Nonnull
                                   String sName)
        Specified by:
        getAttribute in interface jakarta.servlet.http.HttpSession
      • getAttributeNames

        @Nonnull
        public Enumeration<String> getAttributeNames()
        Specified by:
        getAttributeNames in interface jakarta.servlet.http.HttpSession
      • getValueNames

        @Deprecated(forRemoval=false)
        @Nonnull
        public String[] getValueNames()
        Deprecated.
        Specified by:
        getValueNames in interface jakarta.servlet.http.HttpSession
      • setAttribute

        public void setAttribute​(@Nonnull
                                 String sName,
                                 @Nullable
                                 Object aValue)
        Specified by:
        setAttribute in interface jakarta.servlet.http.HttpSession
      • removeAttribute

        public void removeAttribute​(@Nonnull
                                    String sName)
        Specified by:
        removeAttribute in interface jakarta.servlet.http.HttpSession
      • removeValue

        @Deprecated(forRemoval=false)
        public void removeValue​(@Nonnull
                                String sName)
        Deprecated.
        Specified by:
        removeValue in interface jakarta.servlet.http.HttpSession
      • clearAttributes

        public void clearAttributes()
        Clear all of this session's attributes.
      • invalidate

        public void invalidate()
        Specified by:
        invalidate in interface jakarta.servlet.http.HttpSession
      • isInvalid

        public boolean isInvalid()
      • setNew

        public void setNew​(boolean bIsNew)
      • isNew

        public boolean isNew()
        Specified by:
        isNew in interface jakarta.servlet.http.HttpSession