Package org.springframework.mock.web.server

# 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 Summary

Constructors
Constructor
Description
`MockWebSession()`
`MockWebSession(Clock clock)`

## Method Summary

Modifier and Type
Method
Description
`reactor.core.publisher.Mono<Void>`
`changeSessionId()`
`Map<String,Object>`
`getAttributes()`
`Instant`
`getCreationTime()`
`String`
`getId()`
`Instant`
`getLastAccessTime()`
`Duration`
`getMaxIdleTime()`
`reactor.core.publisher.Mono<Void>`
`invalidate()`
`boolean`
`isExpired()`
`boolean`
`isStarted()`
`reactor.core.publisher.Mono<Void>`
`save()`
`void`
`setMaxIdleTime(Duration maxIdleTime)`
`void`
`start()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.web.server.WebSession

`getAttribute, getAttributeOrDefault, getRequiredAttribute`

## 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`