use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class InMemoryWebSessionStoreTests method retrieveExpiredSession.
@Test
public void retrieveExpiredSession() {
WebSession session = this.store.createWebSession().block();
assertThat(session).isNotNull();
session.getAttributes().put("foo", "bar");
session.save().block();
String id = session.getId();
WebSession retrieved = this.store.retrieveSession(id).block();
assertThat(retrieved).isNotNull();
assertThat(retrieved).isSameAs(session);
// Fast-forward 31 minutes
this.store.setClock(Clock.offset(this.store.getClock(), Duration.ofMinutes(31)));
WebSession retrievedAgain = this.store.retrieveSession(id).block();
assertThat(retrievedAgain).isNull();
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class InMemoryWebSessionStoreTests method insertSession.
private WebSession insertSession() {
WebSession session = this.store.createWebSession().block();
assertThat(session).isNotNull();
session.start();
session.save().block();
return session;
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultWebSessionManager method createSession.
protected Mono<WebSession> createSession(ServerWebExchange exchange) {
String sessionId = UUID.randomUUID().toString();
WebSession session = new DefaultWebSession(sessionId, getClock());
return Mono.just(session);
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultWebSessionManagerTests method startSessionImplicitly.
@Test
public void startSessionImplicitly() throws Exception {
this.idResolver.setIdsToResolve(Collections.emptyList());
WebSession session = this.manager.getSession(this.exchange).block();
session.getAttributes().put("foo", "bar");
session.save();
assertNotNull(this.idResolver.getSavedId());
}
use of org.springframework.web.server.WebSession in project spring-framework by spring-projects.
the class DefaultWebSessionManagerTests method multipleSessions.
@Test
public void multipleSessions() throws Exception {
DefaultWebSession existing = new DefaultWebSession("3", Clock.systemDefaultZone());
this.manager.getSessionStore().storeSession(existing);
this.idResolver.setIdsToResolve(Arrays.asList("1", "2", "3"));
WebSession actual = this.manager.getSession(this.exchange).block();
assertSame(existing, actual);
}
Aggregations