Merge branch '3.1.x'

Closes gh-2530
This commit is contained in:
Marcus Da Coregio
2023-10-19 10:35:43 -03:00
104 changed files with 732 additions and 634 deletions

View File

@@ -81,7 +81,7 @@ class ReactiveRedisSessionRepositoryITests extends AbstractRedisITests {
assertThat(session.getId()).isEqualTo(toSave.getId());
assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
assertThat(session.<String>getAttribute(expectedAttributeName))
.isEqualTo(toSave.getAttribute(expectedAttributeName));
.isEqualTo(toSave.getAttribute(expectedAttributeName));
this.repository.deleteById(toSave.getId()).block();
@@ -229,7 +229,7 @@ class ReactiveRedisSessionRepositoryITests extends AbstractRedisITests {
toSave.setLastAccessedTime(Instant.now());
assertThatIllegalStateException().isThrownBy(() -> this.repository.save(toSave).block())
.withMessage("Session was invalidated");
.withMessage("Session was invalidated");
assertThat(this.repository.findById(sessionId).block()).isNull();
assertThat(this.repository.findById(session.getId()).block()).isNotNull();
@@ -240,7 +240,7 @@ class ReactiveRedisSessionRepositoryITests extends AbstractRedisITests {
@SuppressWarnings("unchecked")
void saveChangeSessionIdAfterCheckWhenOriginalKeyDoesNotExistsThenIgnoreError() {
ReactiveRedisOperations<String, Object> sessionRedisOperations = (ReactiveRedisOperations<String, Object>) ReflectionTestUtils
.getField(this.repository, "sessionRedisOperations");
.getField(this.repository, "sessionRedisOperations");
ReactiveRedisOperations<String, Object> spyOperations = spy(sessionRedisOperations);
ReflectionTestUtils.setField(this.repository, "sessionRedisOperations", spyOperations);
@@ -267,7 +267,8 @@ class ReactiveRedisSessionRepositoryITests extends AbstractRedisITests {
ReactiveHashOperations<String, Object, Object> opsForHash = spy(this.sessionRedisOperations.opsForHash());
given(spy.opsForHash()).willReturn(opsForHash);
willAnswer((invocation) -> Mono.delay(Duration.ofSeconds(1)).then((Mono<Void>) invocation.callRealMethod()))
.given(opsForHash).putAll(anyString(), any());
.given(opsForHash)
.putAll(anyString(), any());
RedisSession toSave = this.repository.createSession().block();
String expectedAttributeName = "a";

View File

@@ -69,11 +69,11 @@ class ReactiveRedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
ReactiveHashOperations<String, Object, Object> opsForHash = spy(this.spyOperations.opsForHash());
given(this.spyOperations.opsForHash()).willReturn(opsForHash);
willAnswer((invocation) -> this.sessionRepository.deleteById(session.getId())
.then((Mono<Void>) invocation.callRealMethod())).given(opsForHash).putAll(any(), any());
.then((Mono<Void>) invocation.callRealMethod())).given(opsForHash).putAll(any(), any());
this.sessionRepository.save(session).block();
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.findById(session.getId()).block())
.withMessage("creationTime key must not be null");
.withMessage("creationTime key must not be null");
}
@Test
@@ -86,7 +86,7 @@ class ReactiveRedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
ReactiveHashOperations<String, Object, Object> opsForHash = spy(this.spyOperations.opsForHash());
given(this.spyOperations.opsForHash()).willReturn(opsForHash);
willAnswer((invocation) -> this.sessionRepository.deleteById(session.getId())
.then((Mono<Void>) invocation.callRealMethod())).given(opsForHash).putAll(any(), any());
.then((Mono<Void>) invocation.callRealMethod())).given(opsForHash).putAll(any(), any());
this.sessionRepository.save(session).block();
assertThat(this.sessionRepository.findById(session.getId()).block()).isNull();
@@ -97,7 +97,7 @@ class ReactiveRedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
this.context.refresh();
this.sessionRepository = this.context.getBean(ReactiveRedisSessionRepository.class);
ReactiveRedisOperations<String, Object> redisOperations = (ReactiveRedisOperations<String, Object>) ReflectionTestUtils
.getField(this.sessionRepository, "sessionRedisOperations");
.getField(this.sessionRepository, "sessionRedisOperations");
this.spyOperations = spy(redisOperations);
ReflectionTestUtils.setField(this.sessionRepository, "sessionRedisOperations", this.spyOperations);
}
@@ -123,7 +123,7 @@ class ReactiveRedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
@Bean
ReactiveSessionRepositoryCustomizer<ReactiveRedisSessionRepository> redisSessionRepositoryCustomizer() {
return (redisSessionRepository) -> redisSessionRepository
.setRedisSessionMapper(new SafeRedisSessionMapper(redisSessionRepository));
.setRedisSessionMapper(new SafeRedisSessionMapper(redisSessionRepository));
}
}
@@ -140,9 +140,9 @@ class ReactiveRedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
@Override
public Mono<MapSession> apply(String sessionId, Map<String, Object> map) {
return Mono.fromSupplier(() -> this.delegate.apply(sessionId, map)).onErrorResume(
IllegalStateException.class,
(ex) -> this.sessionRepository.deleteById(sessionId).then(Mono.empty()));
return Mono.fromSupplier(() -> this.delegate.apply(sessionId, map))
.onErrorResume(IllegalStateException.class,
(ex) -> this.sessionRepository.deleteById(sessionId).then(Mono.empty()));
}
}

View File

@@ -78,7 +78,7 @@ class RedisIndexedSessionRepositoryDynamicITests extends AbstractRedisITests {
this.sessionRepository.save(session);
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.findById(session.getId()))
.withMessage("creationTime key must not be null");
.withMessage("creationTime key must not be null");
}
@Test
@@ -128,7 +128,7 @@ class RedisIndexedSessionRepositoryDynamicITests extends AbstractRedisITests {
this.context.refresh();
this.sessionRepository = this.context.getBean(RedisIndexedSessionRepository.class);
RedisOperations<String, Object> redisOperations = (RedisOperations<String, Object>) ReflectionTestUtils
.getField(this.sessionRepository, "sessionRedisOperations");
.getField(this.sessionRepository, "sessionRedisOperations");
this.spyOperations = spy(redisOperations);
ReflectionTestUtils.setField(this.sessionRepository, "sessionRedisOperations", this.spyOperations);
}
@@ -153,8 +153,8 @@ class RedisIndexedSessionRepositoryDynamicITests extends AbstractRedisITests {
@Bean
SessionRepositoryCustomizer<RedisIndexedSessionRepository> redisSessionRepositoryCustomizer() {
return (redisSessionRepository) -> redisSessionRepository.setRedisSessionMapper(
new SafeRedisSessionMapper(redisSessionRepository.getSessionRedisOperations()));
return (redisSessionRepository) -> redisSessionRepository
.setRedisSessionMapper(new SafeRedisSessionMapper(redisSessionRepository.getSessionRedisOperations()));
}
}

View File

@@ -119,7 +119,7 @@ class RedisIndexedSessionRepositoryITests extends AbstractRedisITests {
assertThat(session.getId()).isEqualTo(toSave.getId());
assertThat(session.getAttributeNames()).isEqualTo(toSave.getAttributeNames());
assertThat(session.<String>getAttribute(expectedAttributeName))
.isEqualTo(toSave.getAttribute(expectedAttributeName));
.isEqualTo(toSave.getAttribute(expectedAttributeName));
this.registry.clear();
@@ -127,11 +127,11 @@ class RedisIndexedSessionRepositoryITests extends AbstractRedisITests {
assertThat(this.repository.findById(toSave.getId())).isNull();
assertThat(this.registry.<SessionDestroyedEvent>getEvent(toSave.getId()))
.isInstanceOf(SessionDestroyedEvent.class);
.isInstanceOf(SessionDestroyedEvent.class);
assertThat(this.redis.boundSetOps(usernameSessionKey).members()).doesNotContain(toSave.getId());
assertThat(this.registry.getEvent(toSave.getId()).getSession().<String>getAttribute(expectedAttributeName))
.isEqualTo(expectedAttributeValue);
.isEqualTo(expectedAttributeValue);
}
@Test

View File

@@ -54,7 +54,7 @@ class RedisSessionRepositoryITests extends AbstractRedisITests {
void save_NewSession_ShouldSaveSession() {
RedisSession session = createAndSaveSession(Instant.now());
assertThat(session.getMaxInactiveInterval())
.isEqualTo(Duration.ofSeconds(MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS));
.isEqualTo(Duration.ofSeconds(MapSession.DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS));
assertThat(session.getAttributeNames()).isEqualTo(Collections.singleton("attribute1"));
assertThat(session.<String>getAttribute("attribute1")).isEqualTo("value1");
}
@@ -69,7 +69,7 @@ class RedisSessionRepositoryITests extends AbstractRedisITests {
RedisSession session = createAndSaveSession(Instant.now());
this.sessionRepository.deleteById(session.getId());
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.save(session))
.withMessage("Session was invalidated");
.withMessage("Session was invalidated");
}
@Test
@@ -160,7 +160,7 @@ class RedisSessionRepositoryITests extends AbstractRedisITests {
updateSession(session, Instant.now(), "attribute1", "value1");
String newSessionId = session.changeSessionId();
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.save(session))
.withMessage("Session was invalidated");
.withMessage("Session was invalidated");
assertThat(this.sessionRepository.findById(newSessionId)).isNull();
assertThat(this.sessionRepository.findById(originalSessionId)).isNull();
}
@@ -177,7 +177,7 @@ class RedisSessionRepositoryITests extends AbstractRedisITests {
updateSession(copy2, now.plusSeconds(2L), "attribute3", "value3");
String newSessionId2 = copy2.changeSessionId();
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.save(copy2))
.withMessage("Session was invalidated");
.withMessage("Session was invalidated");
assertThat(this.sessionRepository.findById(newSessionId1)).isNotNull();
assertThat(this.sessionRepository.findById(newSessionId2)).isNull();
assertThat(this.sessionRepository.findById(originalSessionId)).isNull();

View File

@@ -74,7 +74,7 @@ class RedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
this.sessionRepository.save(session);
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.findById(session.getId()))
.withMessage("creationTime key must not be null");
.withMessage("creationTime key must not be null");
}
@Test
@@ -100,7 +100,7 @@ class RedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
this.context.refresh();
this.sessionRepository = this.context.getBean(RedisSessionRepository.class);
RedisOperations<String, Object> redisOperations = (RedisOperations<String, Object>) ReflectionTestUtils
.getField(this.sessionRepository, "sessionRedisOperations");
.getField(this.sessionRepository, "sessionRedisOperations");
this.spyOperations = spy(redisOperations);
ReflectionTestUtils.setField(this.sessionRepository, "sessionRedisOperations", this.spyOperations);
}
@@ -126,7 +126,7 @@ class RedisSessionRepositoryKeyMissITests extends AbstractRedisITests {
@Bean
SessionRepositoryCustomizer<RedisSessionRepository> redisSessionRepositoryCustomizer() {
return (redisSessionRepository) -> redisSessionRepository
.setRedisSessionMapper(new SafeRedisSessionMapper(redisSessionRepository));
.setRedisSessionMapper(new SafeRedisSessionMapper(redisSessionRepository));
}
}

View File

@@ -56,7 +56,7 @@ class RedisListenerContainerTaskExecutorITests extends AbstractRedisITests {
@Test
void testRedisDelEventsAreDispatchedInSessionTaskExecutor() throws InterruptedException {
BoundSetOperations<Object, Object> ops = this.redis
.boundSetOps("spring:session:RedisListenerContainerTaskExecutorITests:expirations:dummy");
.boundSetOps("spring:session:RedisListenerContainerTaskExecutorITests:expirations:dummy");
ops.add("value");
ops.remove("value");
assertThat(this.executor.taskDispatched()).isTrue();