use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultWebSessionManagerTests method existingSessionIsExpired.
@Test
public void existingSessionIsExpired() throws Exception {
Clock clock = Clock.systemDefaultZone();
DefaultWebSession existing = new DefaultWebSession("1", clock);
existing.start();
existing.setLastAccessTime(Instant.now(clock).minus(Duration.ofMinutes(31)));
this.manager.getSessionStore().storeSession(existing);
this.idResolver.setIdsToResolve(Collections.singletonList("1"));
WebSession actual = this.manager.getSession(this.exchange).block();
assertNotSame(existing, actual);
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultWebSessionManagerTests method getSessionWithoutStarting.
@Test
public void getSessionWithoutStarting() throws Exception {
this.idResolver.setIdsToResolve(Collections.emptyList());
WebSession session = this.manager.getSession(this.exchange).block();
session.save();
assertFalse(session.isStarted());
assertFalse(session.isExpired());
assertNull(this.idResolver.getSavedId());
assertNull(this.manager.getSessionStore().retrieveSession(session.getId()).block());
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultWebSessionManagerTests method startSessionExplicitly.
@Test
public void startSessionExplicitly() throws Exception {
this.idResolver.setIdsToResolve(Collections.emptyList());
WebSession session = this.manager.getSession(this.exchange).block();
session.start();
session.save();
String id = session.getId();
assertNotNull(this.idResolver.getSavedId());
assertEquals(id, this.idResolver.getSavedId());
assertSame(session, this.manager.getSessionStore().retrieveSession(id).block());
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultServerRequestTests method session.
@Test
public void session() throws Exception {
WebSession session = mock(WebSession.class);
when(mockExchange.getSession()).thenReturn(Mono.just(session));
assertEquals(session, defaultRequest.session().block());
}
use of org.springframework.web.server.WebSession in project spring-session by spring-projects.
the class SpringSessionWebSessionStoreTests method createSessionWhenNoAttributesThenNotStarted.
@Test
public void createSessionWhenNoAttributesThenNotStarted() {
WebSession createdWebSession = this.webSessionStore.createWebSession().block();
assertThat(createdWebSession.isStarted()).isFalse();
}
Aggregations