35
35
import org .jspecify .annotations .Nullable ;
36
36
import org .junit .jupiter .api .BeforeEach ;
37
37
import org .junit .jupiter .api .Disabled ;
38
+ import org .junit .jupiter .api .Test ;
39
+ import org .junit .jupiter .params .ParameterizedClass ;
40
+ import org .junit .jupiter .params .provider .MethodSource ;
38
41
39
42
import org .springframework .data .redis .connection .RedisConnection ;
40
43
import org .springframework .data .redis .connection .RedisConnectionFactory ;
43
46
import org .springframework .data .redis .test .condition .EnabledOnRedisDriver ;
44
47
import org .springframework .data .redis .test .condition .EnabledOnRedisDriver .DriverQualifier ;
45
48
import org .springframework .data .redis .test .condition .RedisDriver ;
46
- import org .springframework .data .redis .test .extension .parametrized .MethodSource ;
47
- import org .springframework .data .redis .test .extension .parametrized .ParameterizedRedisTest ;
48
49
49
50
/**
50
51
* Integration tests for {@link DefaultRedisCacheWriter}.
53
54
* @author Mark Paluch
54
55
* @author ChanYoung Joung
55
56
*/
57
+ @ ParameterizedClass
56
58
@ MethodSource ("testParams" )
57
59
public class DefaultRedisCacheWriterTests {
58
60
@@ -79,7 +81,8 @@ void setUp() {
79
81
doWithConnection (RedisConnection ::flushAll );
80
82
}
81
83
82
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
84
+ @ Test
85
+ // DATAREDIS-481, DATAREDIS-1082
83
86
void putShouldAddEternalEntry () {
84
87
85
88
RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -96,7 +99,7 @@ void putShouldAddEternalEntry() {
96
99
assertThat (writer .getCacheStatistics (CACHE_NAME ).getLockWaitDuration (TimeUnit .NANOSECONDS )).isZero ();
97
100
}
98
101
99
- @ ParameterizedRedisTest // DATAREDIS-481
102
+ @ Test // DATAREDIS-481
100
103
void putShouldAddExpiringEntry () {
101
104
102
105
nonLockingRedisCacheWriter (connectionFactory ).put (CACHE_NAME , binaryCacheKey , binaryCacheValue ,
@@ -108,7 +111,7 @@ void putShouldAddExpiringEntry() {
108
111
});
109
112
}
110
113
111
- @ ParameterizedRedisTest // DATAREDIS-481
114
+ @ Test // DATAREDIS-481
112
115
void putShouldOverwriteExistingEternalEntry () {
113
116
114
117
doWithConnection (connection -> connection .set (binaryCacheKey , "foo" .getBytes ()));
@@ -121,7 +124,7 @@ void putShouldOverwriteExistingEternalEntry() {
121
124
});
122
125
}
123
126
124
- @ ParameterizedRedisTest // DATAREDIS-481
127
+ @ Test // DATAREDIS-481
125
128
void putShouldOverwriteExistingExpiringEntryAndResetTtl () {
126
129
127
130
doWithConnection (connection -> connection .set (binaryCacheKey , "foo" .getBytes (),
@@ -136,7 +139,7 @@ void putShouldOverwriteExistingExpiringEntryAndResetTtl() {
136
139
});
137
140
}
138
141
139
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
142
+ @ Test // DATAREDIS-481, DATAREDIS-1082
140
143
void getShouldReturnValue () {
141
144
142
145
doWithConnection (connection -> connection .set (binaryCacheKey , binaryCacheValue ));
@@ -150,12 +153,12 @@ void getShouldReturnValue() {
150
153
assertThat (writer .getCacheStatistics (CACHE_NAME ).getMisses ()).isZero ();
151
154
}
152
155
153
- @ ParameterizedRedisTest // DATAREDIS-481
156
+ @ Test // DATAREDIS-481
154
157
void getShouldReturnNullWhenKeyDoesNotExist () {
155
158
assertThat (nonLockingRedisCacheWriter (connectionFactory ).get (CACHE_NAME , binaryCacheKey )).isNull ();
156
159
}
157
160
158
- @ ParameterizedRedisTest // GH-2650
161
+ @ Test // GH-2650
159
162
@ EnabledOnRedisDriver (RedisDriver .LETTUCE )
160
163
void cacheHitRetrieveShouldIncrementStatistics () throws ExecutionException , InterruptedException {
161
164
@@ -170,7 +173,7 @@ void cacheHitRetrieveShouldIncrementStatistics() throws ExecutionException, Inte
170
173
assertThat (writer .getCacheStatistics (CACHE_NAME ).getHits ()).isOne ();
171
174
}
172
175
173
- @ ParameterizedRedisTest // GH-2650
176
+ @ Test // GH-2650
174
177
@ EnabledOnRedisDriver (RedisDriver .LETTUCE )
175
178
void storeShouldIncrementStatistics () throws ExecutionException , InterruptedException {
176
179
@@ -182,7 +185,7 @@ void storeShouldIncrementStatistics() throws ExecutionException, InterruptedExce
182
185
assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
183
186
}
184
187
185
- @ ParameterizedRedisTest // GH-2650
188
+ @ Test // GH-2650
186
189
@ EnabledOnRedisDriver (RedisDriver .LETTUCE )
187
190
void cacheMissRetrieveWithLoaderAsyncShouldIncrementStatistics () throws ExecutionException , InterruptedException {
188
191
@@ -195,7 +198,7 @@ void cacheMissRetrieveWithLoaderAsyncShouldIncrementStatistics() throws Executio
195
198
assertThat (writer .getCacheStatistics (CACHE_NAME ).getMisses ()).isOne ();
196
199
}
197
200
198
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
201
+ @ Test // DATAREDIS-481, DATAREDIS-1082
199
202
void putIfAbsentShouldAddEternalEntryWhenKeyDoesNotExist () {
200
203
201
204
RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -210,7 +213,7 @@ void putIfAbsentShouldAddEternalEntryWhenKeyDoesNotExist() {
210
213
assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
211
214
}
212
215
213
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
216
+ @ Test // DATAREDIS-481, DATAREDIS-1082
214
217
void putIfAbsentShouldNotAddEternalEntryWhenKeyAlreadyExist () {
215
218
216
219
doWithConnection (connection -> connection .set (binaryCacheKey , binaryCacheValue ));
@@ -228,7 +231,7 @@ void putIfAbsentShouldNotAddEternalEntryWhenKeyAlreadyExist() {
228
231
assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isZero ();
229
232
}
230
233
231
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
234
+ @ Test // DATAREDIS-481, DATAREDIS-1082
232
235
void putIfAbsentShouldAddExpiringEntryWhenKeyDoesNotExist () {
233
236
234
237
RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -243,7 +246,7 @@ void putIfAbsentShouldAddExpiringEntryWhenKeyDoesNotExist() {
243
246
assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
244
247
}
245
248
246
- @ ParameterizedRedisTest // GH-2890
249
+ @ Test // GH-2890
247
250
void getWithValueLoaderShouldStoreCacheValue () {
248
251
249
252
RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -259,7 +262,7 @@ void getWithValueLoaderShouldStoreCacheValue() {
259
262
assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
260
263
}
261
264
262
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
265
+ @ Test // DATAREDIS-481, DATAREDIS-1082
263
266
void removeShouldDeleteEntry () {
264
267
265
268
doWithConnection (connection -> connection .set (binaryCacheKey , binaryCacheValue ));
@@ -274,7 +277,7 @@ void removeShouldDeleteEntry() {
274
277
assertThat (writer .getCacheStatistics (CACHE_NAME ).getDeletes ()).isOne ();
275
278
}
276
279
277
- @ ParameterizedRedisTest // DATAREDIS-418, DATAREDIS-1082
280
+ @ Test // DATAREDIS-418, DATAREDIS-1082
278
281
void cleanShouldRemoveAllKeysByPattern () {
279
282
280
283
doWithConnection (connection -> {
@@ -295,7 +298,7 @@ void cleanShouldRemoveAllKeysByPattern() {
295
298
assertThat (writer .getCacheStatistics (CACHE_NAME ).getDeletes ()).isOne ();
296
299
}
297
300
298
- @ ParameterizedRedisTest // DATAREDIS-481
301
+ @ Test // DATAREDIS-481
299
302
void nonLockingCacheWriterShouldIgnoreExistingLock () {
300
303
301
304
((DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory )).lock (CACHE_NAME );
@@ -307,7 +310,7 @@ void nonLockingCacheWriterShouldIgnoreExistingLock() {
307
310
});
308
311
}
309
312
310
- @ ParameterizedRedisTest // DATAREDIS-481
313
+ @ Test // DATAREDIS-481
311
314
void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache () {
312
315
313
316
((DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory )).lock (CACHE_NAME );
@@ -320,7 +323,7 @@ void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache() {
320
323
});
321
324
}
322
325
323
- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
326
+ @ Test // DATAREDIS-481, DATAREDIS-1082
324
327
void lockingCacheWriterShouldWaitForLockRelease () throws InterruptedException {
325
328
326
329
DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory )
@@ -362,7 +365,7 @@ void lockingCacheWriterShouldWaitForLockRelease() throws InterruptedException {
362
365
}
363
366
}
364
367
365
- @ ParameterizedRedisTest // DATAREDIS-481
368
+ @ Test // DATAREDIS-481
366
369
void lockingCacheWriterShouldExitWhenInterruptedWaitForLockRelease () throws InterruptedException {
367
370
368
371
DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory );
@@ -403,7 +406,7 @@ boolean doCheckLock(String name, RedisConnection connection) {
403
406
assertThat (exceptionRef .get ()).hasRootCauseInstanceOf (InterruptedException .class );
404
407
}
405
408
406
- @ ParameterizedRedisTest // GH-2300
409
+ @ Test // GH-2300
407
410
void lockingCacheWriterShouldUsePersistentLocks () {
408
411
409
412
DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory ,
@@ -417,7 +420,7 @@ void lockingCacheWriterShouldUsePersistentLocks() {
417
420
});
418
421
}
419
422
420
- @ ParameterizedRedisTest // GH-2300
423
+ @ Test // GH-2300
421
424
void lockingCacheWriterShouldApplyLockTtl () {
422
425
423
426
DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory ,
@@ -431,7 +434,7 @@ void lockingCacheWriterShouldApplyLockTtl() {
431
434
});
432
435
}
433
436
434
- @ ParameterizedRedisTest // DATAREDIS-1082
437
+ @ Test // DATAREDIS-1082
435
438
void noOpStatisticsCollectorReturnsEmptyStatsInstance () {
436
439
437
440
DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory );
@@ -443,7 +446,7 @@ void noOpStatisticsCollectorReturnsEmptyStatsInstance() {
443
446
assertThat (stats .getPuts ()).isZero ();
444
447
}
445
448
446
- @ ParameterizedRedisTest // GH-1686
449
+ @ Test // GH-1686
447
450
@ Disabled ("Occasional failures on CI but not locally" )
448
451
void doLockShouldGetLock () throws InterruptedException {
449
452
0 commit comments