25
25
import org .springframework .beans .factory .annotation .Autowired ;
26
26
import org .springframework .context .annotation .Configuration ;
27
27
import org .springframework .session .Session ;
28
+ import org .springframework .session .data .redis .ReactiveRedisSessionRepository .RedisSession ;
28
29
import org .springframework .session .data .redis .config .annotation .web .server .EnableRedisWebSession ;
29
30
import org .springframework .test .context .ContextConfiguration ;
30
31
import org .springframework .test .context .junit .jupiter .SpringExtension ;
34
35
import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
35
36
36
37
/**
37
- * Integration tests for {@link ReactiveRedisOperationsSessionRepository }.
38
+ * Integration tests for {@link ReactiveRedisSessionRepository }.
38
39
*
39
40
* @author Vedran Pavic
40
41
*/
41
42
@ ExtendWith (SpringExtension .class )
42
43
@ ContextConfiguration
43
44
@ WebAppConfiguration
44
- class ReactiveRedisOperationsSessionRepositoryITests extends AbstractRedisITests {
45
+ class ReactiveRedisSessionRepositoryITests extends AbstractRedisITests {
45
46
46
47
@ Autowired
47
- private ReactiveRedisOperationsSessionRepository repository ;
48
+ private ReactiveRedisSessionRepository repository ;
48
49
49
50
@ Test
50
51
void saves () {
51
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
52
+ RedisSession toSave = this .repository .createSession ().block ();
52
53
53
54
String expectedAttributeName = "a" ;
54
55
String expectedAttributeValue = "b" ;
@@ -70,7 +71,7 @@ void saves() {
70
71
71
72
@ Test // gh-1399
72
73
void saveMultipleTimes () {
73
- ReactiveRedisOperationsSessionRepository . RedisSession session = this .repository .createSession ().block ();
74
+ RedisSession session = this .repository .createSession ().block ();
74
75
session .setAttribute ("attribute1" , "value1" );
75
76
Mono <Void > save1 = this .repository .save (session );
76
77
session .setAttribute ("attribute2" , "value2" );
@@ -80,7 +81,7 @@ void saveMultipleTimes() {
80
81
81
82
@ Test
82
83
void putAllOnSingleAttrDoesNotRemoveOld () {
83
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
84
+ RedisSession toSave = this .repository .createSession ().block ();
84
85
toSave .setAttribute ("a" , "b" );
85
86
86
87
this .repository .save (toSave ).block ();
@@ -103,13 +104,12 @@ void putAllOnSingleAttrDoesNotRemoveOld() {
103
104
void changeSessionIdWhenOnlyChangeId () {
104
105
String attrName = "changeSessionId" ;
105
106
String attrValue = "changeSessionId-value" ;
106
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
107
+ RedisSession toSave = this .repository .createSession ().block ();
107
108
toSave .setAttribute (attrName , attrValue );
108
109
109
110
this .repository .save (toSave ).block ();
110
111
111
- ReactiveRedisOperationsSessionRepository .RedisSession findById = this .repository .findById (toSave .getId ())
112
- .block ();
112
+ RedisSession findById = this .repository .findById (toSave .getId ()).block ();
113
113
114
114
assertThat (findById .<String >getAttribute (attrName )).isEqualTo (attrValue );
115
115
@@ -120,15 +120,14 @@ void changeSessionIdWhenOnlyChangeId() {
120
120
121
121
assertThat (this .repository .findById (originalFindById ).block ()).isNull ();
122
122
123
- ReactiveRedisOperationsSessionRepository .RedisSession findByChangeSessionId = this .repository
124
- .findById (changeSessionId ).block ();
123
+ RedisSession findByChangeSessionId = this .repository .findById (changeSessionId ).block ();
125
124
126
125
assertThat (findByChangeSessionId .<String >getAttribute (attrName )).isEqualTo (attrValue );
127
126
}
128
127
129
128
@ Test
130
129
void changeSessionIdWhenChangeTwice () {
131
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
130
+ RedisSession toSave = this .repository .createSession ().block ();
132
131
133
132
this .repository .save (toSave ).block ();
134
133
@@ -148,12 +147,11 @@ void changeSessionIdWhenSetAttributeOnChangedSession() {
148
147
String attrName = "changeSessionId" ;
149
148
String attrValue = "changeSessionId-value" ;
150
149
151
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
150
+ RedisSession toSave = this .repository .createSession ().block ();
152
151
153
152
this .repository .save (toSave ).block ();
154
153
155
- ReactiveRedisOperationsSessionRepository .RedisSession findById = this .repository .findById (toSave .getId ())
156
- .block ();
154
+ RedisSession findById = this .repository .findById (toSave .getId ()).block ();
157
155
158
156
findById .setAttribute (attrName , attrValue );
159
157
@@ -164,15 +162,14 @@ void changeSessionIdWhenSetAttributeOnChangedSession() {
164
162
165
163
assertThat (this .repository .findById (originalFindById ).block ()).isNull ();
166
164
167
- ReactiveRedisOperationsSessionRepository .RedisSession findByChangeSessionId = this .repository
168
- .findById (changeSessionId ).block ();
165
+ RedisSession findByChangeSessionId = this .repository .findById (changeSessionId ).block ();
169
166
170
167
assertThat (findByChangeSessionId .<String >getAttribute (attrName )).isEqualTo (attrValue );
171
168
}
172
169
173
170
@ Test
174
171
void changeSessionIdWhenHasNotSaved () {
175
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
172
+ RedisSession toSave = this .repository .createSession ().block ();
176
173
String originalId = toSave .getId ();
177
174
toSave .changeSessionId ();
178
175
@@ -185,7 +182,7 @@ void changeSessionIdWhenHasNotSaved() {
185
182
// gh-954
186
183
@ Test
187
184
void changeSessionIdSaveTwice () {
188
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
185
+ RedisSession toSave = this .repository .createSession ().block ();
189
186
String originalId = toSave .getId ();
190
187
toSave .changeSessionId ();
191
188
@@ -199,12 +196,12 @@ void changeSessionIdSaveTwice() {
199
196
// gh-1111
200
197
@ Test
201
198
void changeSessionSaveOldSessionInstance () {
202
- ReactiveRedisOperationsSessionRepository . RedisSession toSave = this .repository .createSession ().block ();
199
+ RedisSession toSave = this .repository .createSession ().block ();
203
200
String sessionId = toSave .getId ();
204
201
205
202
this .repository .save (toSave ).block ();
206
203
207
- ReactiveRedisOperationsSessionRepository . RedisSession session = this .repository .findById (sessionId ).block ();
204
+ RedisSession session = this .repository .findById (sessionId ).block ();
208
205
session .changeSessionId ();
209
206
session .setLastAccessedTime (Instant .now ());
210
207
this .repository .save (session ).block ();
0 commit comments