Search in sources :

Example 11 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndPutNullThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndPutNullThenDelegatesToCreateSession() {
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    attributes.put("a", null);
    verify(this.createSession).setAttribute("a", null);
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 12 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndClearThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndClearThenDelegatesToCreateSession() {
    given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    attributes.clear();
    verify(this.createSession).removeAttribute("a");
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 13 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndKeySetThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndKeySetThenDelegatesToCreateSession() {
    given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    assertThat(attributes.keySet()).containsExactly("a");
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 14 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method storeSessionWhenInvokedThenSessionSaved.

@Test
public void storeSessionWhenInvokedThenSessionSaved() {
    given(this.sessionRepository.save(this.createSession)).willReturn(Mono.empty());
    WebSession createdSession = this.webSessionStore.createWebSession().block();
    this.webSessionStore.storeSession(createdSession).block();
    verify(this.sessionRepository).save(this.createSession);
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 15 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method retrieveSessionThenStarted.

@Test
public void retrieveSessionThenStarted() {
    String id = "id";
    WebSession retrievedWebSession = this.webSessionStore.retrieveSession(id).block();
    assertThat(retrievedWebSession.isStarted()).isTrue();
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Aggregations

WebSession (org.springframework.web.server.WebSession)53 Test (org.junit.Test)24 Test (org.junit.jupiter.api.Test)24 Method (java.lang.reflect.Method)3 TestBean (org.springframework.beans.testfixture.beans.TestBean)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 HandlerMethod (org.springframework.web.method.HandlerMethod)3 SyncInvocableHandlerMethod (org.springframework.web.reactive.result.method.SyncInvocableHandlerMethod)3 ServerWebExchange (org.springframework.web.server.ServerWebExchange)3 Mono (reactor.core.publisher.Mono)3 Instant (java.time.Instant)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 BDDMockito.given (org.mockito.BDDMockito.given)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.spy (org.mockito.Mockito.spy)2 Mockito.times (org.mockito.Mockito.times)2 Mockito.verify (org.mockito.Mockito.verify)2