use of org.springframework.session.Session in project spring-session by spring-projects.
the class SessionEventHttpSessionListenerAdapterTests method setup.
@Before
public void setup() {
this.listener = new SessionEventHttpSessionListenerAdapter(Arrays.asList(this.listener1, this.listener2));
this.listener.setServletContext(new MockServletContext());
Session session = new MapSession();
this.destroyed = new SessionDestroyedEvent(this, session);
this.created = new SessionCreatedEvent(this, session);
}
use of org.springframework.session.Session in project spring-session by spring-projects.
the class ReactiveRedisOperationsSessionRepositoryITests method putAllOnSingleAttrDoesNotRemoveOld.
@Test
public void putAllOnSingleAttrDoesNotRemoveOld() {
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
toSave.setAttribute("a", "b");
this.repository.save(toSave).block();
toSave = this.repository.findById(toSave.getId()).block();
toSave.setAttribute("1", "2");
this.repository.save(toSave).block();
toSave = this.repository.findById(toSave.getId()).block();
Session session = this.repository.findById(toSave.getId()).block();
assertThat(session.getAttributeNames().size()).isEqualTo(2);
assertThat(session.<String>getAttribute("a")).isEqualTo("b");
assertThat(session.<String>getAttribute("1")).isEqualTo("2");
this.repository.deleteById(toSave.getId()).block();
}
use of org.springframework.session.Session in project spring-session by spring-projects.
the class ReactiveRedisOperationsSessionRepositoryITests method saves.
@Test
public void saves() throws InterruptedException {
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
String expectedAttributeName = "a";
String expectedAttributeValue = "b";
toSave.setAttribute(expectedAttributeName, expectedAttributeValue);
this.repository.save(toSave).block();
Session session = this.repository.findById(toSave.getId()).block();
assertThat(session.getId()).isEqualTo(toSave.getId());
assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
assertThat(session.<String>getAttribute(expectedAttributeName)).isEqualTo(toSave.getAttribute(expectedAttributeName));
this.repository.deleteById(toSave.getId()).block();
assertThat(this.repository.findById(toSave.getId()).block()).isNull();
}
use of org.springframework.session.Session in project spring-session by spring-projects.
the class AbstractJdbcOperationsSessionRepositoryITests method putAllOnSingleAttrDoesNotRemoveOld.
@Test
public void putAllOnSingleAttrDoesNotRemoveOld() {
JdbcOperationsSessionRepository.JdbcSession toSave = this.repository.createSession();
toSave.setAttribute("a", "b");
this.repository.save(toSave);
toSave = this.repository.findById(toSave.getId());
toSave.setAttribute("1", "2");
this.repository.save(toSave);
toSave = this.repository.findById(toSave.getId());
Session session = this.repository.findById(toSave.getId());
assertThat(session.getAttributeNames().size()).isEqualTo(2);
assertThat(session.<String>getAttribute("a")).isEqualTo("b");
assertThat(session.<String>getAttribute("1")).isEqualTo("2");
this.repository.deleteById(toSave.getId());
}
use of org.springframework.session.Session in project spring-session by spring-projects.
the class AbstractJdbcOperationsSessionRepositoryITests method updateLastAccessedTime.
@Test
public void updateLastAccessedTime() {
JdbcOperationsSessionRepository.JdbcSession toSave = this.repository.createSession();
toSave.setLastAccessedTime(Instant.now().minusSeconds(MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS + 1));
this.repository.save(toSave);
Instant lastAccessedTime = Instant.now();
toSave.setLastAccessedTime(lastAccessedTime);
this.repository.save(toSave);
Session session = this.repository.findById(toSave.getId());
assertThat(session).isNotNull();
assertThat(session.isExpired()).isFalse();
assertThat(session.getLastAccessedTime()).isEqualTo(lastAccessedTime);
}
Aggregations