3535import org .jspecify .annotations .Nullable ;
3636import org .junit .jupiter .api .BeforeEach ;
3737import 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 ;
3841
3942import org .springframework .data .redis .connection .RedisConnection ;
4043import org .springframework .data .redis .connection .RedisConnectionFactory ;
4346import org .springframework .data .redis .test .condition .EnabledOnRedisDriver ;
4447import org .springframework .data .redis .test .condition .EnabledOnRedisDriver .DriverQualifier ;
4548import 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 ;
4849
4950/**
5051 * Integration tests for {@link DefaultRedisCacheWriter}.
5354 * @author Mark Paluch
5455 * @author ChanYoung Joung
5556 */
57+ @ ParameterizedClass
5658@ MethodSource ("testParams" )
5759public class DefaultRedisCacheWriterTests {
5860
@@ -79,7 +81,8 @@ void setUp() {
7981 doWithConnection (RedisConnection ::flushAll );
8082 }
8183
82- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
84+ @ Test
85+ // DATAREDIS-481, DATAREDIS-1082
8386 void putShouldAddEternalEntry () {
8487
8588 RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -96,7 +99,7 @@ void putShouldAddEternalEntry() {
9699 assertThat (writer .getCacheStatistics (CACHE_NAME ).getLockWaitDuration (TimeUnit .NANOSECONDS )).isZero ();
97100 }
98101
99- @ ParameterizedRedisTest // DATAREDIS-481
102+ @ Test // DATAREDIS-481
100103 void putShouldAddExpiringEntry () {
101104
102105 nonLockingRedisCacheWriter (connectionFactory ).put (CACHE_NAME , binaryCacheKey , binaryCacheValue ,
@@ -108,7 +111,7 @@ void putShouldAddExpiringEntry() {
108111 });
109112 }
110113
111- @ ParameterizedRedisTest // DATAREDIS-481
114+ @ Test // DATAREDIS-481
112115 void putShouldOverwriteExistingEternalEntry () {
113116
114117 doWithConnection (connection -> connection .set (binaryCacheKey , "foo" .getBytes ()));
@@ -121,7 +124,7 @@ void putShouldOverwriteExistingEternalEntry() {
121124 });
122125 }
123126
124- @ ParameterizedRedisTest // DATAREDIS-481
127+ @ Test // DATAREDIS-481
125128 void putShouldOverwriteExistingExpiringEntryAndResetTtl () {
126129
127130 doWithConnection (connection -> connection .set (binaryCacheKey , "foo" .getBytes (),
@@ -136,7 +139,7 @@ void putShouldOverwriteExistingExpiringEntryAndResetTtl() {
136139 });
137140 }
138141
139- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
142+ @ Test // DATAREDIS-481, DATAREDIS-1082
140143 void getShouldReturnValue () {
141144
142145 doWithConnection (connection -> connection .set (binaryCacheKey , binaryCacheValue ));
@@ -150,12 +153,12 @@ void getShouldReturnValue() {
150153 assertThat (writer .getCacheStatistics (CACHE_NAME ).getMisses ()).isZero ();
151154 }
152155
153- @ ParameterizedRedisTest // DATAREDIS-481
156+ @ Test // DATAREDIS-481
154157 void getShouldReturnNullWhenKeyDoesNotExist () {
155158 assertThat (nonLockingRedisCacheWriter (connectionFactory ).get (CACHE_NAME , binaryCacheKey )).isNull ();
156159 }
157160
158- @ ParameterizedRedisTest // GH-2650
161+ @ Test // GH-2650
159162 @ EnabledOnRedisDriver (RedisDriver .LETTUCE )
160163 void cacheHitRetrieveShouldIncrementStatistics () throws ExecutionException , InterruptedException {
161164
@@ -170,7 +173,7 @@ void cacheHitRetrieveShouldIncrementStatistics() throws ExecutionException, Inte
170173 assertThat (writer .getCacheStatistics (CACHE_NAME ).getHits ()).isOne ();
171174 }
172175
173- @ ParameterizedRedisTest // GH-2650
176+ @ Test // GH-2650
174177 @ EnabledOnRedisDriver (RedisDriver .LETTUCE )
175178 void storeShouldIncrementStatistics () throws ExecutionException , InterruptedException {
176179
@@ -182,7 +185,7 @@ void storeShouldIncrementStatistics() throws ExecutionException, InterruptedExce
182185 assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
183186 }
184187
185- @ ParameterizedRedisTest // GH-2650
188+ @ Test // GH-2650
186189 @ EnabledOnRedisDriver (RedisDriver .LETTUCE )
187190 void cacheMissRetrieveWithLoaderAsyncShouldIncrementStatistics () throws ExecutionException , InterruptedException {
188191
@@ -195,7 +198,7 @@ void cacheMissRetrieveWithLoaderAsyncShouldIncrementStatistics() throws Executio
195198 assertThat (writer .getCacheStatistics (CACHE_NAME ).getMisses ()).isOne ();
196199 }
197200
198- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
201+ @ Test // DATAREDIS-481, DATAREDIS-1082
199202 void putIfAbsentShouldAddEternalEntryWhenKeyDoesNotExist () {
200203
201204 RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -210,7 +213,7 @@ void putIfAbsentShouldAddEternalEntryWhenKeyDoesNotExist() {
210213 assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
211214 }
212215
213- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
216+ @ Test // DATAREDIS-481, DATAREDIS-1082
214217 void putIfAbsentShouldNotAddEternalEntryWhenKeyAlreadyExist () {
215218
216219 doWithConnection (connection -> connection .set (binaryCacheKey , binaryCacheValue ));
@@ -228,7 +231,7 @@ void putIfAbsentShouldNotAddEternalEntryWhenKeyAlreadyExist() {
228231 assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isZero ();
229232 }
230233
231- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
234+ @ Test // DATAREDIS-481, DATAREDIS-1082
232235 void putIfAbsentShouldAddExpiringEntryWhenKeyDoesNotExist () {
233236
234237 RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -243,7 +246,7 @@ void putIfAbsentShouldAddExpiringEntryWhenKeyDoesNotExist() {
243246 assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
244247 }
245248
246- @ ParameterizedRedisTest // GH-2890
249+ @ Test // GH-2890
247250 void getWithValueLoaderShouldStoreCacheValue () {
248251
249252 RedisCacheWriter writer = nonLockingRedisCacheWriter (connectionFactory )
@@ -259,7 +262,7 @@ void getWithValueLoaderShouldStoreCacheValue() {
259262 assertThat (writer .getCacheStatistics (CACHE_NAME ).getPuts ()).isOne ();
260263 }
261264
262- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
265+ @ Test // DATAREDIS-481, DATAREDIS-1082
263266 void removeShouldDeleteEntry () {
264267
265268 doWithConnection (connection -> connection .set (binaryCacheKey , binaryCacheValue ));
@@ -274,7 +277,7 @@ void removeShouldDeleteEntry() {
274277 assertThat (writer .getCacheStatistics (CACHE_NAME ).getDeletes ()).isOne ();
275278 }
276279
277- @ ParameterizedRedisTest // DATAREDIS-418, DATAREDIS-1082
280+ @ Test // DATAREDIS-418, DATAREDIS-1082
278281 void cleanShouldRemoveAllKeysByPattern () {
279282
280283 doWithConnection (connection -> {
@@ -295,7 +298,7 @@ void cleanShouldRemoveAllKeysByPattern() {
295298 assertThat (writer .getCacheStatistics (CACHE_NAME ).getDeletes ()).isOne ();
296299 }
297300
298- @ ParameterizedRedisTest // DATAREDIS-481
301+ @ Test // DATAREDIS-481
299302 void nonLockingCacheWriterShouldIgnoreExistingLock () {
300303
301304 ((DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory )).lock (CACHE_NAME );
@@ -307,7 +310,7 @@ void nonLockingCacheWriterShouldIgnoreExistingLock() {
307310 });
308311 }
309312
310- @ ParameterizedRedisTest // DATAREDIS-481
313+ @ Test // DATAREDIS-481
311314 void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache () {
312315
313316 ((DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory )).lock (CACHE_NAME );
@@ -320,7 +323,7 @@ void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache() {
320323 });
321324 }
322325
323- @ ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
326+ @ Test // DATAREDIS-481, DATAREDIS-1082
324327 void lockingCacheWriterShouldWaitForLockRelease () throws InterruptedException {
325328
326329 DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory )
@@ -362,7 +365,7 @@ void lockingCacheWriterShouldWaitForLockRelease() throws InterruptedException {
362365 }
363366 }
364367
365- @ ParameterizedRedisTest // DATAREDIS-481
368+ @ Test // DATAREDIS-481
366369 void lockingCacheWriterShouldExitWhenInterruptedWaitForLockRelease () throws InterruptedException {
367370
368371 DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory );
@@ -403,7 +406,7 @@ boolean doCheckLock(String name, RedisConnection connection) {
403406 assertThat (exceptionRef .get ()).hasRootCauseInstanceOf (InterruptedException .class );
404407 }
405408
406- @ ParameterizedRedisTest // GH-2300
409+ @ Test // GH-2300
407410 void lockingCacheWriterShouldUsePersistentLocks () {
408411
409412 DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory ,
@@ -417,7 +420,7 @@ void lockingCacheWriterShouldUsePersistentLocks() {
417420 });
418421 }
419422
420- @ ParameterizedRedisTest // GH-2300
423+ @ Test // GH-2300
421424 void lockingCacheWriterShouldApplyLockTtl () {
422425
423426 DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory ,
@@ -431,7 +434,7 @@ void lockingCacheWriterShouldApplyLockTtl() {
431434 });
432435 }
433436
434- @ ParameterizedRedisTest // DATAREDIS-1082
437+ @ Test // DATAREDIS-1082
435438 void noOpStatisticsCollectorReturnsEmptyStatsInstance () {
436439
437440 DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter ) lockingRedisCacheWriter (connectionFactory );
@@ -443,7 +446,7 @@ void noOpStatisticsCollectorReturnsEmptyStatsInstance() {
443446 assertThat (stats .getPuts ()).isZero ();
444447 }
445448
446- @ ParameterizedRedisTest // GH-1686
449+ @ Test // GH-1686
447450 @ Disabled ("Occasional failures on CI but not locally" )
448451 void doLockShouldGetLock () throws InterruptedException {
449452
0 commit comments