use of org.springframework.session.MapSession in project spring-session by spring-projects.
the class JdbcOperationsSessionRepositoryTests method saveUpdatedLastAccessedTime.
@Test
public void saveUpdatedLastAccessedTime() {
JdbcOperationsSessionRepository.JdbcSession session = this.repository.new JdbcSession("primaryKey", new MapSession());
session.setLastAccessedTime(Instant.now());
this.repository.save(session);
assertThat(session.isNew()).isFalse();
assertPropagationRequiresNew();
verify(this.jdbcOperations, times(1)).update(and(startsWith("UPDATE"), contains("LAST_ACCESS_TIME")), isA(PreparedStatementSetter.class));
}
use of org.springframework.session.MapSession in project spring-session by spring-projects.
the class JdbcOperationsSessionRepositoryTests method saveUnchanged.
@Test
public void saveUnchanged() {
JdbcOperationsSessionRepository.JdbcSession session = this.repository.new JdbcSession("primaryKey", new MapSession());
this.repository.save(session);
assertThat(session.isNew()).isFalse();
verifyZeroInteractions(this.jdbcOperations);
}
use of org.springframework.session.MapSession in project spring-session by spring-projects.
the class JdbcOperationsSessionRepositoryTests method saveUpdatedAttributes.
@Test
public void saveUpdatedAttributes() {
JdbcOperationsSessionRepository.JdbcSession session = this.repository.new JdbcSession("primaryKey", new MapSession());
session.setAttribute("testName", "testValue");
this.repository.save(session);
assertThat(session.isNew()).isFalse();
assertPropagationRequiresNew();
verify(this.jdbcOperations, times(1)).update(and(startsWith("UPDATE"), contains("ATTRIBUTE_BYTES")), isA(PreparedStatementSetter.class));
}
use of org.springframework.session.MapSession in project spring-session by spring-projects.
the class ReactiveRedisOperationsSessionRepositoryTests method saveSetAttribute.
@Test
public void saveSetAttribute() {
given(this.redisOperations.opsForHash()).willReturn(this.hashOperations);
given(this.hashOperations.putAll(anyString(), this.delta.capture())).willReturn(Mono.just(true));
given(this.redisOperations.expire(anyString(), any())).willReturn(Mono.just(true));
String attrName = "attrName";
ReactiveRedisOperationsSessionRepository.RedisSession session = this.repository.new RedisSession(new MapSession());
session.setAttribute(attrName, "attrValue");
Mono<Void> result = this.repository.save(session);
StepVerifier.create(result).expectNextMatches(predicate -> {
assertThat(this.delta.getAllValues().get(0)).isEqualTo(map(RedisOperationsSessionRepository.getSessionAttrNameKey(attrName), session.getAttribute(attrName)));
return true;
});
}
use of org.springframework.session.MapSession in project spring-session by spring-projects.
the class ReactiveRedisOperationsSessionRepositoryTests method delete.
@Test
public void delete() {
given(this.redisOperations.delete(anyString())).willReturn(Mono.just(1L));
ReactiveRedisOperationsSessionRepository.RedisSession session = this.repository.new RedisSession(new MapSession());
Mono<Void> result = this.repository.deleteById(session.getId());
StepVerifier.create(result).expectNextMatches(predicate -> {
assertThat(result).isEqualTo(1);
return true;
});
}
Aggregations