Skip to content

Commit 8cc8fbb

Browse files
committed
Harmonize naming of session repositories
Resolves: #1455
1 parent 96715e0 commit 8cc8fbb

File tree

64 files changed

+3029
-2888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3029
-2888
lines changed

spring-session-data-redis/src/integration-test/java/org/springframework/session/data/redis/AbstractRedisITests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
2424

2525
/**
26-
* Base class for {@link RedisOperationsSessionRepository} integration tests.
26+
* Base class for Redis integration tests.
2727
*
2828
* @author Vedran Pavic
2929
*/
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.session.Session;
28+
import org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession;
2829
import org.springframework.session.data.redis.config.annotation.web.server.EnableRedisWebSession;
2930
import org.springframework.test.context.ContextConfiguration;
3031
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -34,21 +35,21 @@
3435
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
3536

3637
/**
37-
* Integration tests for {@link ReactiveRedisOperationsSessionRepository}.
38+
* Integration tests for {@link ReactiveRedisSessionRepository}.
3839
*
3940
* @author Vedran Pavic
4041
*/
4142
@ExtendWith(SpringExtension.class)
4243
@ContextConfiguration
4344
@WebAppConfiguration
44-
class ReactiveRedisOperationsSessionRepositoryITests extends AbstractRedisITests {
45+
class ReactiveRedisSessionRepositoryITests extends AbstractRedisITests {
4546

4647
@Autowired
47-
private ReactiveRedisOperationsSessionRepository repository;
48+
private ReactiveRedisSessionRepository repository;
4849

4950
@Test
5051
void saves() {
51-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
52+
RedisSession toSave = this.repository.createSession().block();
5253

5354
String expectedAttributeName = "a";
5455
String expectedAttributeValue = "b";
@@ -70,7 +71,7 @@ void saves() {
7071

7172
@Test // gh-1399
7273
void saveMultipleTimes() {
73-
ReactiveRedisOperationsSessionRepository.RedisSession session = this.repository.createSession().block();
74+
RedisSession session = this.repository.createSession().block();
7475
session.setAttribute("attribute1", "value1");
7576
Mono<Void> save1 = this.repository.save(session);
7677
session.setAttribute("attribute2", "value2");
@@ -80,7 +81,7 @@ void saveMultipleTimes() {
8081

8182
@Test
8283
void putAllOnSingleAttrDoesNotRemoveOld() {
83-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
84+
RedisSession toSave = this.repository.createSession().block();
8485
toSave.setAttribute("a", "b");
8586

8687
this.repository.save(toSave).block();
@@ -103,13 +104,12 @@ void putAllOnSingleAttrDoesNotRemoveOld() {
103104
void changeSessionIdWhenOnlyChangeId() {
104105
String attrName = "changeSessionId";
105106
String attrValue = "changeSessionId-value";
106-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
107+
RedisSession toSave = this.repository.createSession().block();
107108
toSave.setAttribute(attrName, attrValue);
108109

109110
this.repository.save(toSave).block();
110111

111-
ReactiveRedisOperationsSessionRepository.RedisSession findById = this.repository.findById(toSave.getId())
112-
.block();
112+
RedisSession findById = this.repository.findById(toSave.getId()).block();
113113

114114
assertThat(findById.<String>getAttribute(attrName)).isEqualTo(attrValue);
115115

@@ -120,15 +120,14 @@ void changeSessionIdWhenOnlyChangeId() {
120120

121121
assertThat(this.repository.findById(originalFindById).block()).isNull();
122122

123-
ReactiveRedisOperationsSessionRepository.RedisSession findByChangeSessionId = this.repository
124-
.findById(changeSessionId).block();
123+
RedisSession findByChangeSessionId = this.repository.findById(changeSessionId).block();
125124

126125
assertThat(findByChangeSessionId.<String>getAttribute(attrName)).isEqualTo(attrValue);
127126
}
128127

129128
@Test
130129
void changeSessionIdWhenChangeTwice() {
131-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
130+
RedisSession toSave = this.repository.createSession().block();
132131

133132
this.repository.save(toSave).block();
134133

@@ -148,12 +147,11 @@ void changeSessionIdWhenSetAttributeOnChangedSession() {
148147
String attrName = "changeSessionId";
149148
String attrValue = "changeSessionId-value";
150149

151-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
150+
RedisSession toSave = this.repository.createSession().block();
152151

153152
this.repository.save(toSave).block();
154153

155-
ReactiveRedisOperationsSessionRepository.RedisSession findById = this.repository.findById(toSave.getId())
156-
.block();
154+
RedisSession findById = this.repository.findById(toSave.getId()).block();
157155

158156
findById.setAttribute(attrName, attrValue);
159157

@@ -164,15 +162,14 @@ void changeSessionIdWhenSetAttributeOnChangedSession() {
164162

165163
assertThat(this.repository.findById(originalFindById).block()).isNull();
166164

167-
ReactiveRedisOperationsSessionRepository.RedisSession findByChangeSessionId = this.repository
168-
.findById(changeSessionId).block();
165+
RedisSession findByChangeSessionId = this.repository.findById(changeSessionId).block();
169166

170167
assertThat(findByChangeSessionId.<String>getAttribute(attrName)).isEqualTo(attrValue);
171168
}
172169

173170
@Test
174171
void changeSessionIdWhenHasNotSaved() {
175-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
172+
RedisSession toSave = this.repository.createSession().block();
176173
String originalId = toSave.getId();
177174
toSave.changeSessionId();
178175

@@ -185,7 +182,7 @@ void changeSessionIdWhenHasNotSaved() {
185182
// gh-954
186183
@Test
187184
void changeSessionIdSaveTwice() {
188-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
185+
RedisSession toSave = this.repository.createSession().block();
189186
String originalId = toSave.getId();
190187
toSave.changeSessionId();
191188

@@ -199,12 +196,12 @@ void changeSessionIdSaveTwice() {
199196
// gh-1111
200197
@Test
201198
void changeSessionSaveOldSessionInstance() {
202-
ReactiveRedisOperationsSessionRepository.RedisSession toSave = this.repository.createSession().block();
199+
RedisSession toSave = this.repository.createSession().block();
203200
String sessionId = toSave.getId();
204201

205202
this.repository.save(toSave).block();
206203

207-
ReactiveRedisOperationsSessionRepository.RedisSession session = this.repository.findById(sessionId).block();
204+
RedisSession session = this.repository.findById(sessionId).block();
208205
session.changeSessionId();
209206
session.setLastAccessedTime(Instant.now());
210207
this.repository.save(session).block();
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.springframework.session.FindByIndexNameSessionRepository;
3838
import org.springframework.session.Session;
3939
import org.springframework.session.data.SessionEventRegistry;
40-
import org.springframework.session.data.redis.RedisOperationsSessionRepository.RedisSession;
40+
import org.springframework.session.data.redis.RedisIndexedSessionRepository.RedisSession;
4141
import org.springframework.session.data.redis.config.annotation.SpringSessionRedisOperations;
4242
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
4343
import org.springframework.session.events.SessionCreatedEvent;
@@ -48,17 +48,23 @@
4848

4949
import static org.assertj.core.api.Assertions.assertThat;
5050

51+
/**
52+
* Integration tests for {@link RedisIndexedSessionRepository}.
53+
*
54+
* @author Rob Winch
55+
* @author Vedran Pavic
56+
*/
5157
@ExtendWith(SpringExtension.class)
5258
@ContextConfiguration
5359
@WebAppConfiguration
54-
class RedisOperationsSessionRepositoryITests extends AbstractRedisITests {
60+
class RedisIndexedSessionRepositoryITests extends AbstractRedisITests {
5561

5662
private static final String SPRING_SECURITY_CONTEXT = "SPRING_SECURITY_CONTEXT";
5763

5864
private static final String INDEX_NAME = FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME;
5965

6066
@Autowired
61-
private RedisOperationsSessionRepository repository;
67+
private RedisIndexedSessionRepository repository;
6268

6369
@Autowired
6470
private SessionEventRegistry registry;
@@ -88,7 +94,7 @@ void setup() {
8894
void saves() throws InterruptedException {
8995
String username = "saves-" + System.currentTimeMillis();
9096

91-
String usernameSessionKey = "RedisOperationsSessionRepositoryITests:index:" + INDEX_NAME + ":" + username;
97+
String usernameSessionKey = "RedisIndexedSessionRepositoryITests:index:" + INDEX_NAME + ":" + username;
9298

9399
RedisSession toSave = this.repository.createSession();
94100
String expectedAttributeName = "a";
@@ -180,7 +186,7 @@ void findByPrincipalNameExpireRemovesIndex() {
180186

181187
this.repository.save(toSave);
182188

183-
String body = "RedisOperationsSessionRepositoryITests:sessions:expires:" + toSave.getId();
189+
String body = "RedisIndexedSessionRepositoryITests:sessions:expires:" + toSave.getId();
184190
String channel = "__keyevent@0__:expired";
185191
DefaultMessage message = new DefaultMessage(channel.getBytes(StandardCharsets.UTF_8),
186192
body.getBytes(StandardCharsets.UTF_8));
@@ -342,7 +348,7 @@ void findBySecurityPrincipalNameExpireRemovesIndex() {
342348

343349
this.repository.save(toSave);
344350

345-
String body = "RedisOperationsSessionRepositoryITests:sessions:expires:" + toSave.getId();
351+
String body = "RedisIndexedSessionRepositoryITests:sessions:expires:" + toSave.getId();
346352
String channel = "__keyevent@0__:expired";
347353
DefaultMessage message = new DefaultMessage(channel.getBytes(StandardCharsets.UTF_8),
348354
body.getBytes(StandardCharsets.UTF_8));
@@ -607,7 +613,7 @@ private String getChangedSecurityName() {
607613
}
608614

609615
@Configuration
610-
@EnableRedisHttpSession(redisNamespace = "RedisOperationsSessionRepositoryITests")
616+
@EnableRedisHttpSession(redisNamespace = "RedisIndexedSessionRepositoryITests")
611617
static class Config extends BaseConfig {
612618

613619
@Bean
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.springframework.data.redis.core.RedisTemplate;
3333
import org.springframework.session.MapSession;
3434
import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
35-
import org.springframework.session.data.redis.SimpleRedisOperationsSessionRepository.RedisSession;
35+
import org.springframework.session.data.redis.RedisSessionRepository.RedisSession;
3636
import org.springframework.test.context.ContextConfiguration;
3737
import org.springframework.test.context.junit.jupiter.SpringExtension;
3838
import org.springframework.test.context.web.WebAppConfiguration;
@@ -41,17 +41,17 @@
4141
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
4242

4343
/**
44-
* Integration tests for {@link SimpleRedisOperationsSessionRepository}.
44+
* Integration tests for {@link RedisSessionRepository}.
4545
*
4646
* @author Vedran Pavic
4747
*/
4848
@ExtendWith(SpringExtension.class)
4949
@ContextConfiguration
5050
@WebAppConfiguration
51-
class SimpleRedisOperationsSessionRepositoryITests extends AbstractRedisITests {
51+
class RedisSessionRepositoryITests extends AbstractRedisITests {
5252

5353
@Autowired
54-
private SimpleRedisOperationsSessionRepository sessionRepository;
54+
private RedisSessionRepository sessionRepository;
5555

5656
@Test
5757
void save_NewSession_ShouldSaveSession() {
@@ -227,11 +227,11 @@ private static void updateSession(RedisSession session, Instant lastAccessedTime
227227
static class Config extends BaseConfig {
228228

229229
@Bean
230-
public SimpleRedisOperationsSessionRepository sessionRepository(RedisConnectionFactory redisConnectionFactory) {
230+
public RedisSessionRepository sessionRepository(RedisConnectionFactory redisConnectionFactory) {
231231
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
232232
redisTemplate.setConnectionFactory(redisConnectionFactory);
233233
redisTemplate.afterPropertiesSet();
234-
return new SimpleRedisOperationsSessionRepository(redisTemplate);
234+
return new RedisSessionRepository(redisTemplate);
235235
}
236236

237237
}
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@ExtendWith(SpringExtension.class)
3636
@ContextConfiguration
3737
@WebAppConfiguration
38-
class RedisOperationsSessionRepositoryFlushImmediatelyITests<S extends Session> extends AbstractRedisITests {
38+
class RedisIndexedSessionRepositoryFlushImmediatelyITests<S extends Session> extends AbstractRedisITests {
3939

4040
@Autowired
4141
private SessionRepository<S> sessionRepository;

0 commit comments

Comments
 (0)