Class MockWebSession

java.lang.Object
org.springframework.mock.web.server.MockWebSession
All Implemented Interfaces:
org.springframework.web.server.WebSession

public class MockWebSession extends Object implements org.springframework.web.server.WebSession
Implementation of WebSession that delegates to a session instance obtained via InMemoryWebSessionStore.

This is intended for use with the session(WebSession) method of the MockServerWebExchange builder, eliminating the need to use WebSessionManager or WebSessionStore altogether.

Since:
5.1
Author:
Rossen Stoyanchev
  • Constructor Details

    • MockWebSession

      public MockWebSession()
    • MockWebSession

      public MockWebSession(@Nullable Clock clock)
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface org.springframework.web.server.WebSession
    • getAttributes

      public Map<String,Object> getAttributes()
      Specified by:
      getAttributes in interface org.springframework.web.server.WebSession
    • start

      public void start()
      Specified by:
      start in interface org.springframework.web.server.WebSession
    • isStarted

      public boolean isStarted()
      Specified by:
      isStarted in interface org.springframework.web.server.WebSession
    • changeSessionId

      public reactor.core.publisher.Mono<Void> changeSessionId()
      Specified by:
      changeSessionId in interface org.springframework.web.server.WebSession
    • invalidate

      public reactor.core.publisher.Mono<Void> invalidate()
      Specified by:
      invalidate in interface org.springframework.web.server.WebSession
    • save

      public reactor.core.publisher.Mono<Void> save()
      Specified by:
      save in interface org.springframework.web.server.WebSession
    • isExpired

      public boolean isExpired()
      Specified by:
      isExpired in interface org.springframework.web.server.WebSession
    • getCreationTime

      public Instant getCreationTime()
      Specified by:
      getCreationTime in interface org.springframework.web.server.WebSession
    • getLastAccessTime

      public Instant getLastAccessTime()
      Specified by:
      getLastAccessTime in interface org.springframework.web.server.WebSession
    • setMaxIdleTime

      public void setMaxIdleTime(Duration maxIdleTime)
      Specified by:
      setMaxIdleTime in interface org.springframework.web.server.WebSession
    • getMaxIdleTime

      public Duration getMaxIdleTime()
      Specified by:
      getMaxIdleTime in interface org.springframework.web.server.WebSession