diff --git a/pom.xml b/pom.xml index 985d38d7b8..f9da4f33b6 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-redis - 4.0.0-SNAPSHOT + 4.0.0-GH-3167-SNAPSHOT Spring Data Redis Spring Data module for Redis @@ -28,7 +28,6 @@ 1.01 4.1.121.Final spring.data.redis - 5.12.2 @@ -154,6 +153,12 @@ commons-beanutils ${beanutils} true + + + commons-logging + commons-logging + + diff --git a/src/test/java/org/springframework/data/redis/cache/CacheTestParams.java b/src/test/java/org/springframework/data/redis/cache/CacheTestParams.java index b037099902..8add67d9cb 100644 --- a/src/test/java/org/springframework/data/redis/cache/CacheTestParams.java +++ b/src/test/java/org/springframework/data/redis/cache/CacheTestParams.java @@ -36,7 +36,7 @@ import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; import org.springframework.data.redis.test.condition.RedisDetector; import org.springframework.data.redis.test.extension.RedisCluster; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.lang.Nullable; /** @@ -55,12 +55,12 @@ private static Collection connectionFactories() { // Jedis Standalone JedisConnectionFactory jedisConnectionFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); factoryList.add(jedisConnectionFactory); // Lettuce Standalone LettuceConnectionFactory lettuceConnectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); factoryList.add(lettuceConnectionFactory); if (clusterAvailable()) { diff --git a/src/test/java/org/springframework/data/redis/cache/DefaultRedisCacheWriterTests.java b/src/test/java/org/springframework/data/redis/cache/DefaultRedisCacheWriterTests.java index 6b74b80931..b6b801dfc8 100644 --- a/src/test/java/org/springframework/data/redis/cache/DefaultRedisCacheWriterTests.java +++ b/src/test/java/org/springframework/data/redis/cache/DefaultRedisCacheWriterTests.java @@ -34,6 +34,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -42,8 +45,6 @@ import org.springframework.data.redis.test.condition.EnabledOnRedisDriver; import org.springframework.data.redis.test.condition.EnabledOnRedisDriver.DriverQualifier; import org.springframework.data.redis.test.condition.RedisDriver; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.lang.Nullable; /** @@ -53,6 +54,7 @@ * @author Mark Paluch * @author ChanYoung Joung */ +@ParameterizedClass @MethodSource("testParams") public class DefaultRedisCacheWriterTests { @@ -79,7 +81,8 @@ void setUp() { doWithConnection(RedisConnection::flushAll); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test + // DATAREDIS-481, DATAREDIS-1082 void putShouldAddEternalEntry() { RedisCacheWriter writer = nonLockingRedisCacheWriter(connectionFactory) @@ -96,7 +99,7 @@ void putShouldAddEternalEntry() { assertThat(writer.getCacheStatistics(CACHE_NAME).getLockWaitDuration(TimeUnit.NANOSECONDS)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putShouldAddExpiringEntry() { nonLockingRedisCacheWriter(connectionFactory).put(CACHE_NAME, binaryCacheKey, binaryCacheValue, @@ -108,7 +111,7 @@ void putShouldAddExpiringEntry() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putShouldOverwriteExistingEternalEntry() { doWithConnection(connection -> connection.set(binaryCacheKey, "foo".getBytes())); @@ -121,7 +124,7 @@ void putShouldOverwriteExistingEternalEntry() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putShouldOverwriteExistingExpiringEntryAndResetTtl() { doWithConnection(connection -> connection.set(binaryCacheKey, "foo".getBytes(), @@ -136,7 +139,7 @@ void putShouldOverwriteExistingExpiringEntryAndResetTtl() { }); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test // DATAREDIS-481, DATAREDIS-1082 void getShouldReturnValue() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryCacheValue)); @@ -150,12 +153,12 @@ void getShouldReturnValue() { assertThat(writer.getCacheStatistics(CACHE_NAME).getMisses()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void getShouldReturnNullWhenKeyDoesNotExist() { assertThat(nonLockingRedisCacheWriter(connectionFactory).get(CACHE_NAME, binaryCacheKey)).isNull(); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void cacheHitRetrieveShouldIncrementStatistics() throws ExecutionException, InterruptedException { @@ -170,7 +173,7 @@ void cacheHitRetrieveShouldIncrementStatistics() throws ExecutionException, Inte assertThat(writer.getCacheStatistics(CACHE_NAME).getHits()).isOne(); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void storeShouldIncrementStatistics() throws ExecutionException, InterruptedException { @@ -182,7 +185,7 @@ void storeShouldIncrementStatistics() throws ExecutionException, InterruptedExce assertThat(writer.getCacheStatistics(CACHE_NAME).getPuts()).isOne(); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void cacheMissRetrieveWithLoaderAsyncShouldIncrementStatistics() throws ExecutionException, InterruptedException { @@ -195,7 +198,7 @@ void cacheMissRetrieveWithLoaderAsyncShouldIncrementStatistics() throws Executio assertThat(writer.getCacheStatistics(CACHE_NAME).getMisses()).isOne(); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test // DATAREDIS-481, DATAREDIS-1082 void putIfAbsentShouldAddEternalEntryWhenKeyDoesNotExist() { RedisCacheWriter writer = nonLockingRedisCacheWriter(connectionFactory) @@ -210,7 +213,7 @@ void putIfAbsentShouldAddEternalEntryWhenKeyDoesNotExist() { assertThat(writer.getCacheStatistics(CACHE_NAME).getPuts()).isOne(); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test // DATAREDIS-481, DATAREDIS-1082 void putIfAbsentShouldNotAddEternalEntryWhenKeyAlreadyExist() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryCacheValue)); @@ -228,7 +231,7 @@ void putIfAbsentShouldNotAddEternalEntryWhenKeyAlreadyExist() { assertThat(writer.getCacheStatistics(CACHE_NAME).getPuts()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test // DATAREDIS-481, DATAREDIS-1082 void putIfAbsentShouldAddExpiringEntryWhenKeyDoesNotExist() { RedisCacheWriter writer = nonLockingRedisCacheWriter(connectionFactory) @@ -243,7 +246,7 @@ void putIfAbsentShouldAddExpiringEntryWhenKeyDoesNotExist() { assertThat(writer.getCacheStatistics(CACHE_NAME).getPuts()).isOne(); } - @ParameterizedRedisTest // GH-2890 + @Test // GH-2890 void getWithValueLoaderShouldStoreCacheValue() { RedisCacheWriter writer = nonLockingRedisCacheWriter(connectionFactory) @@ -259,7 +262,7 @@ void getWithValueLoaderShouldStoreCacheValue() { assertThat(writer.getCacheStatistics(CACHE_NAME).getPuts()).isOne(); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test // DATAREDIS-481, DATAREDIS-1082 void removeShouldDeleteEntry() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryCacheValue)); @@ -274,7 +277,7 @@ void removeShouldDeleteEntry() { assertThat(writer.getCacheStatistics(CACHE_NAME).getDeletes()).isOne(); } - @ParameterizedRedisTest // DATAREDIS-418, DATAREDIS-1082 + @Test // DATAREDIS-418, DATAREDIS-1082 void cleanShouldRemoveAllKeysByPattern() { doWithConnection(connection -> { @@ -295,7 +298,7 @@ void cleanShouldRemoveAllKeysByPattern() { assertThat(writer.getCacheStatistics(CACHE_NAME).getDeletes()).isOne(); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void nonLockingCacheWriterShouldIgnoreExistingLock() { ((DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory)).lock(CACHE_NAME); @@ -307,7 +310,7 @@ void nonLockingCacheWriterShouldIgnoreExistingLock() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache() { ((DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory)).lock(CACHE_NAME); @@ -320,7 +323,7 @@ void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache() { }); } - @ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082 + @Test // DATAREDIS-481, DATAREDIS-1082 void lockingCacheWriterShouldWaitForLockRelease() throws InterruptedException { DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory) @@ -362,7 +365,7 @@ void lockingCacheWriterShouldWaitForLockRelease() throws InterruptedException { } } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void lockingCacheWriterShouldExitWhenInterruptedWaitForLockRelease() throws InterruptedException { DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory); @@ -403,7 +406,7 @@ boolean doCheckLock(String name, RedisConnection connection) { assertThat(exceptionRef.get()).hasRootCauseInstanceOf(InterruptedException.class); } - @ParameterizedRedisTest // GH-2300 + @Test // GH-2300 void lockingCacheWriterShouldUsePersistentLocks() { DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory, @@ -417,7 +420,7 @@ void lockingCacheWriterShouldUsePersistentLocks() { }); } - @ParameterizedRedisTest // GH-2300 + @Test // GH-2300 void lockingCacheWriterShouldApplyLockTtl() { DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory, @@ -431,7 +434,7 @@ void lockingCacheWriterShouldApplyLockTtl() { }); } - @ParameterizedRedisTest // DATAREDIS-1082 + @Test // DATAREDIS-1082 void noOpStatisticsCollectorReturnsEmptyStatsInstance() { DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory); @@ -443,7 +446,7 @@ void noOpStatisticsCollectorReturnsEmptyStatsInstance() { assertThat(stats.getPuts()).isZero(); } - @ParameterizedRedisTest // GH-1686 + @Test // GH-1686 @Disabled("Occasional failures on CI but not locally") void doLockShouldGetLock() throws InterruptedException { diff --git a/src/test/java/org/springframework/data/redis/cache/LegacyRedisCacheTests.java b/src/test/java/org/springframework/data/redis/cache/LegacyRedisCacheTests.java index d718055ffa..013dfad4e6 100644 --- a/src/test/java/org/springframework/data/redis/cache/LegacyRedisCacheTests.java +++ b/src/test/java/org/springframework/data/redis/cache/LegacyRedisCacheTests.java @@ -30,6 +30,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.cache.Cache; import org.springframework.cache.Cache.ValueRetrievalException; @@ -38,8 +41,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.AbstractOperationsTestParams; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Tests moved over from 1.x line RedisCache implementation. Just removed somme of the limitations/assumptions @@ -51,6 +52,7 @@ * @author Mark Paluch */ @SuppressWarnings("rawtypes") +@ParameterizedClass @MethodSource("testParams") public class LegacyRedisCacheTests { @@ -116,7 +118,7 @@ protected Object getKey() { return keyFactory.instance(); } - @ParameterizedRedisTest + @Test void testCachePut() { Object key = getKey(); @@ -131,7 +133,7 @@ void testCachePut() { } } - @ParameterizedRedisTest + @Test void testCacheClear() { Object key1 = getKey(); @@ -149,7 +151,7 @@ void testCacheClear() { assertThat(cache.get(key1)).isNull(); } - @ParameterizedRedisTest + @Test void testConcurrentRead() throws Exception { final Object key1 = getKey(); @@ -195,7 +197,7 @@ void testConcurrentRead() throws Exception { assertThat(valueWrapper.get()).isEqualTo(v1); } - @ParameterizedRedisTest + @Test void testGetWhileClear() throws InterruptedException { final Object key1 = getKey(); @@ -221,7 +223,7 @@ void testGetWhileClear() throws InterruptedException { assertThat(monitorStateException.get()).isFalse(); } - @ParameterizedRedisTest // DATAREDIS-243 + @Test // DATAREDIS-243 void testCacheGetShouldReturnCachedInstance() { Object key = getKey(); @@ -231,7 +233,7 @@ void testCacheGetShouldReturnCachedInstance() { assertThat(value).isEqualTo(cache.get(key, Object.class)); } - @ParameterizedRedisTest // DATAREDIS-243 + @Test // DATAREDIS-243 void testCacheGetShouldRetunInstanceOfCorrectType() { Object key = getKey(); @@ -241,7 +243,7 @@ void testCacheGetShouldRetunInstanceOfCorrectType() { assertThat(cache.get(key, value.getClass())).isInstanceOf(value.getClass()); } - @ParameterizedRedisTest // DATAREDIS-243 + @Test // DATAREDIS-243 void testCacheGetShouldThrowExceptionOnInvalidType() { Object key = getKey(); @@ -251,7 +253,7 @@ void testCacheGetShouldThrowExceptionOnInvalidType() { assertThatIllegalStateException().isThrownBy(() -> cache.get(key, Cache.class)); } - @ParameterizedRedisTest // DATAREDIS-243 + @Test // DATAREDIS-243 void testCacheGetShouldReturnNullIfNoCachedValueFound() { Object key = getKey(); @@ -262,7 +264,7 @@ void testCacheGetShouldReturnNullIfNoCachedValueFound() { assertThat(cache.get(invalidKey, value.getClass())).isNull(); } - @ParameterizedRedisTest // DATAREDIS-344, DATAREDIS-416 + @Test // DATAREDIS-344, DATAREDIS-416 void putIfAbsentShouldSetValueOnlyIfNotPresent() { Object key = getKey(); @@ -280,7 +282,7 @@ void putIfAbsentShouldSetValueOnlyIfNotPresent() { assertThat(wrapper.get()).isEqualTo(value); } - @ParameterizedRedisTest // DATAREDIS-510, DATAREDIS-606 + @Test // DATAREDIS-510, DATAREDIS-606 void cachePutWithNullShouldNotAddStuffToRedis() { assumeThat(allowCacheNullValues).as("Only suitable when cache does NOT allow null values.").isFalse(); @@ -290,7 +292,7 @@ void cachePutWithNullShouldNotAddStuffToRedis() { assertThatIllegalArgumentException().isThrownBy(() -> cache.put(key, null)); } - @ParameterizedRedisTest // DATAREDIS-510, DATAREDIS-606 + @Test // DATAREDIS-510, DATAREDIS-606 void cachePutWithNullShouldErrorAndLeaveExistingKeyUntouched() { assumeThat(allowCacheNullValues).as("Only suitable when cache does NOT allow null values.").isFalse(); @@ -310,13 +312,13 @@ void cachePutWithNullShouldErrorAndLeaveExistingKeyUntouched() { assertThat(cache.get(key).get()).isEqualTo(value); } - @ParameterizedRedisTest // DATAREDIS-443, DATAREDIS-452 + @Test // DATAREDIS-443, DATAREDIS-452 @Disabled("junit.framework.AssertionFailedError: expected:<2> but was:<1>") void testCacheGetSynchronized() throws Throwable { runOnce(new CacheGetWithValueLoaderIsThreadSafe(cache)); } - @ParameterizedRedisTest // DATAREDIS-553 + @Test // DATAREDIS-553 void cachePutWithNullShouldAddStuffToRedisWhenCachingNullIsEnabled() { assumeThat(allowCacheNullValues).as("Only suitable when cache does allow null values.").isTrue(); @@ -329,7 +331,7 @@ void cachePutWithNullShouldAddStuffToRedisWhenCachingNullIsEnabled() { assertThat(cache.get(key, String.class)).isNull(); } - @ParameterizedRedisTest // DATAREDIS-553 + @Test // DATAREDIS-553 void testCacheGetSynchronizedNullAllowingNull() { assumeThat(allowCacheNullValues).as("Only suitable when cache does allow null values.").isTrue(); @@ -341,7 +343,7 @@ void testCacheGetSynchronizedNullAllowingNull() { assertThat(cache.get(key).get()).isNull(); } - @ParameterizedRedisTest // DATAREDIS-553, DATAREDIS-606 + @Test // DATAREDIS-553, DATAREDIS-606 void testCacheGetSynchronizedNullNotAllowingNull() { assumeThat(allowCacheNullValues).as("Only suitable when cache does NOT allow null values.").isFalse(); @@ -350,7 +352,7 @@ void testCacheGetSynchronizedNullNotAllowingNull() { assertThatIllegalArgumentException().isThrownBy(() -> cache.get(key, () -> null)); } - @ParameterizedRedisTest + @Test void testCacheGetSynchronizedThrowsExceptionInValueLoader() { Object key = getKey(); @@ -362,7 +364,7 @@ void testCacheGetSynchronizedThrowsExceptionInValueLoader() { }); } - @ParameterizedRedisTest // DATAREDIS-553 + @Test // DATAREDIS-553 void testCacheGetSynchronizedNullWithStoredNull() { assumeThat(allowCacheNullValues).as("Only suitable when cache does allow null values").isTrue(); diff --git a/src/test/java/org/springframework/data/redis/cache/RedisCacheTests.java b/src/test/java/org/springframework/data/redis/cache/RedisCacheTests.java index 520b73d09f..42a456d6b1 100644 --- a/src/test/java/org/springframework/data/redis/cache/RedisCacheTests.java +++ b/src/test/java/org/springframework/data/redis/cache/RedisCacheTests.java @@ -35,6 +35,9 @@ import java.util.function.Supplier; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.cache.Cache.ValueWrapper; import org.springframework.cache.interceptor.SimpleKey; @@ -48,8 +51,6 @@ import org.springframework.data.redis.test.condition.EnabledOnRedisDriver; import org.springframework.data.redis.test.condition.EnabledOnRedisDriver.DriverQualifier; import org.springframework.data.redis.test.condition.RedisDriver; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.lang.Nullable; /** @@ -62,6 +63,7 @@ * @author Jos Roseboom * @author John Blum */ +@ParameterizedClass @MethodSource("testParams") public class RedisCacheTests { @@ -97,7 +99,7 @@ void setUp() { this.cache = new RedisCache("cache", usingRedisCacheWriter(), usingRedisCacheConfiguration()); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putShouldAddEntry() { cache.put("key-1", sample); @@ -105,7 +107,7 @@ void putShouldAddEntry() { doWithConnection(connection -> assertThat(connection.exists(binaryCacheKey)).isTrue()); } - @ParameterizedRedisTest // GH-2379 + @Test // GH-2379 void cacheShouldBeClearedByPattern() { cache.put(key, sample); @@ -116,7 +118,7 @@ void cacheShouldBeClearedByPattern() { doWithConnection(connection -> assertThat(connection.exists(binaryCacheKey)).isFalse()); } - @ParameterizedRedisTest // GH-2379 + @Test // GH-2379 void cacheShouldNotBeClearedIfNoPatternMatch() { cache.put(key, sample); @@ -127,7 +129,8 @@ void cacheShouldNotBeClearedIfNoPatternMatch() { doWithConnection(connection -> assertThat(connection.exists(binaryCacheKey)).isTrue()); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test + // DATAREDIS-481 void putNullShouldAddEntryForNullValue() { cache.put("key-1", null); @@ -138,7 +141,7 @@ void putNullShouldAddEntryForNullValue() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putIfAbsentShouldAddEntryIfNotExists() { cache.putIfAbsent("key-1", sample); @@ -149,7 +152,7 @@ void putIfAbsentShouldAddEntryIfNotExists() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putIfAbsentWithNullShouldAddNullValueEntryIfNotExists() { assertThat(cache.putIfAbsent("key-1", null)).isNull(); @@ -160,7 +163,7 @@ void putIfAbsentWithNullShouldAddNullValueEntryIfNotExists() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putIfAbsentShouldReturnExistingIfExists() { doWithConnection(connection -> connection.set(binaryCacheKey, binarySample)); @@ -173,7 +176,7 @@ void putIfAbsentShouldReturnExistingIfExists() { doWithConnection(connection -> assertThat(connection.get(binaryCacheKey)).isEqualTo(binarySample)); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void putIfAbsentShouldReturnExistingNullValueIfExists() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryNullValue)); @@ -186,7 +189,7 @@ void putIfAbsentShouldReturnExistingNullValueIfExists() { doWithConnection(connection -> assertThat(connection.get(binaryCacheKey)).isEqualTo(binaryNullValue)); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void getShouldRetrieveEntry() { doWithConnection(connection -> connection.set(binaryCacheKey, binarySample)); @@ -196,7 +199,7 @@ void getShouldRetrieveEntry() { assertThat(result.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void shouldReadAndWriteSimpleCacheKey() { SimpleKey key = new SimpleKey("param-1", "param-2"); @@ -208,7 +211,7 @@ void shouldReadAndWriteSimpleCacheKey() { assertThat(result.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void shouldRejectNonInvalidKey() { InvalidKey key = new InvalidKey(sample.getFirstname(), sample.getBirthdate()); @@ -216,7 +219,7 @@ void shouldRejectNonInvalidKey() { assertThatIllegalStateException().isThrownBy(() -> cache.put(key, sample)); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void shouldAllowComplexKeyWithToStringMethod() { ComplexKey key = new ComplexKey(sample.getFirstname(), sample.getBirthdate()); @@ -229,12 +232,12 @@ void shouldAllowComplexKeyWithToStringMethod() { assertThat(result.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void getShouldReturnNullWhenKeyDoesNotExist() { assertThat(cache.get(key)).isNull(); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void getShouldReturnValueWrapperHoldingNullIfNullValueStored() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryNullValue)); @@ -245,7 +248,7 @@ void getShouldReturnValueWrapperHoldingNullIfNullValueStored() { assertThat(result.get()).isEqualTo(null); } - @ParameterizedRedisTest // GH-2890 + @Test // GH-2890 void getWithValueLoaderShouldStoreNull() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryNullValue)); @@ -257,7 +260,7 @@ void getWithValueLoaderShouldStoreNull() { assertThat(result).isNull(); } - @ParameterizedRedisTest // GH-2890 + @Test // GH-2890 void getWithValueLoaderShouldRetrieveValue() { AtomicLong counter = new AtomicLong(); @@ -276,7 +279,7 @@ void getWithValueLoaderShouldRetrieveValue() { assertThat(counter).hasValue(1); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void evictShouldRemoveKey() { doWithConnection(connection -> { @@ -292,7 +295,7 @@ void evictShouldRemoveKey() { }); } - @ParameterizedRedisTest // GH-2028 + @Test // GH-2028 void clearShouldClearCache() { doWithConnection(connection -> { @@ -308,7 +311,7 @@ void clearShouldClearCache() { }); } - @ParameterizedRedisTest // GH-1721 + @Test // GH-1721 @EnabledOnRedisDriver(RedisDriver.LETTUCE) // SCAN not supported via Jedis Cluster. void clearWithScanShouldClearCache() { @@ -331,7 +334,7 @@ void clearWithScanShouldClearCache() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void getWithCallableShouldResolveValueIfNotPresent() { assertThat(cache.get(key, () -> sample)).isEqualTo(sample); @@ -342,7 +345,7 @@ void getWithCallableShouldResolveValueIfNotPresent() { }); } - @ParameterizedRedisTest // DATAREDIS-481 + @Test // DATAREDIS-481 void getWithCallableShouldNotResolveValueIfPresent() { doWithConnection(connection -> connection.set(binaryCacheKey, binaryNullValue)); @@ -357,7 +360,7 @@ void getWithCallableShouldNotResolveValueIfPresent() { }); } - @ParameterizedRedisTest // DATAREDIS-715 + @Test // DATAREDIS-715 void computePrefixCreatesCacheKeyCorrectly() { RedisCache cacheWithCustomPrefix = new RedisCache("cache", @@ -372,7 +375,7 @@ void computePrefixCreatesCacheKeyCorrectly() { .isEqualTo(binarySample)); } - @ParameterizedRedisTest // DATAREDIS-1041 + @Test // DATAREDIS-1041 void prefixCacheNameCreatesCacheKeyCorrectly() { RedisCache cacheWithCustomPrefix = new RedisCache("cache", @@ -386,7 +389,7 @@ void prefixCacheNameCreatesCacheKeyCorrectly() { .isEqualTo(binarySample)); } - @ParameterizedRedisTest // DATAREDIS-715 + @Test // DATAREDIS-715 void fetchKeyWithComputedPrefixReturnsExpectedResult() { doWithConnection(connection -> connection.set("_cache_key-1".getBytes(StandardCharsets.UTF_8), binarySample)); @@ -402,7 +405,7 @@ void fetchKeyWithComputedPrefixReturnsExpectedResult() { assertThat(result.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-1032 + @Test // DATAREDIS-1032 void cacheShouldAllowListKeyCacheKeysOfSimpleTypes() { Object key = SimpleKeyGenerator.generateKey(Collections.singletonList("my-cache-key-in-a-list")); @@ -414,7 +417,7 @@ void cacheShouldAllowListKeyCacheKeysOfSimpleTypes() { assertThat(target.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-1032 + @Test // DATAREDIS-1032 void cacheShouldAllowArrayKeyCacheKeysOfSimpleTypes() { Object key = SimpleKeyGenerator.generateKey("my-cache-key-in-an-array"); @@ -425,7 +428,7 @@ void cacheShouldAllowArrayKeyCacheKeysOfSimpleTypes() { assertThat(target.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-1032 + @Test // DATAREDIS-1032 void cacheShouldAllowListCacheKeysOfComplexTypes() { Object key = SimpleKeyGenerator @@ -438,7 +441,7 @@ void cacheShouldAllowListCacheKeysOfComplexTypes() { assertThat(target.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-1032 + @Test // DATAREDIS-1032 void cacheShouldAllowMapCacheKeys() { Object key = SimpleKeyGenerator @@ -451,7 +454,7 @@ void cacheShouldAllowMapCacheKeys() { assertThat(target.get()).isEqualTo(sample); } - @ParameterizedRedisTest // DATAREDIS-1032 + @Test // DATAREDIS-1032 void cacheShouldFailOnNonConvertibleCacheKey() { Object key = SimpleKeyGenerator @@ -461,7 +464,7 @@ void cacheShouldFailOnNonConvertibleCacheKey() { } @EnabledOnCommand("GETEX") - @ParameterizedRedisTest // GH-2351 + @Test // GH-2351 void cacheGetWithTimeToIdleExpirationWhenEntryNotExpiredShouldReturnValue() { doWithConnection(connection -> connection.stringCommands().set(this.binaryCacheKey, this.binarySample)); @@ -478,7 +481,7 @@ void cacheGetWithTimeToIdleExpirationWhenEntryNotExpiredShouldReturnValue() { } @EnabledOnCommand("GETEX") - @ParameterizedRedisTest // GH-2351 + @Test // GH-2351 void cacheGetWithTimeToIdleExpirationAfterEntryExpiresShouldReturnNull() { doWithConnection(connection -> connection.stringCommands().set(this.binaryCacheKey, this.binarySample)); @@ -493,7 +496,7 @@ void cacheGetWithTimeToIdleExpirationAfterEntryExpiresShouldReturnNull() { }); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.JEDIS) void retrieveCacheValueUsingJedis() { @@ -501,7 +504,7 @@ void retrieveCacheValueUsingJedis() { .isThrownBy(() -> this.cache.retrieve(this.binaryCacheKey)).withMessageContaining("RedisCache"); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.JEDIS) void retrieveLoadedValueUsingJedis() { @@ -510,7 +513,7 @@ void retrieveLoadedValueUsingJedis() { .withMessageContaining("RedisCache"); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveReturnsCachedValue() throws Exception { @@ -531,7 +534,7 @@ void retrieveReturnsCachedValue() throws Exception { }); } - @ParameterizedRedisTest // GH-2890 + @Test // GH-2890 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveAppliesTimeToIdle() throws ExecutionException, InterruptedException { @@ -551,7 +554,7 @@ void retrieveAppliesTimeToIdle() throws ExecutionException, InterruptedException }); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveReturnsCachedNullableValue() throws Exception { @@ -566,7 +569,7 @@ void retrieveReturnsCachedNullableValue() throws Exception { assertThat(value).isDone(); } - @ParameterizedRedisTest // GH-2783 + @Test // GH-2783 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveReturnsCachedNullValue() throws Exception { @@ -579,7 +582,7 @@ void retrieveReturnsCachedNullValue() throws Exception { assertThat(wrapper.get()).isNull(); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveReturnsCachedValueWhenLockIsReleased() throws Exception { @@ -605,7 +608,7 @@ void retrieveReturnsCachedValueWhenLockIsReleased() throws Exception { assertThat(value).isDone(); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveReturnsLoadedValue() throws Exception { @@ -627,7 +630,7 @@ void retrieveReturnsLoadedValue() throws Exception { assertThat(value).isDone(); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveStoresLoadedValue() throws Exception { @@ -643,7 +646,7 @@ void retrieveStoresLoadedValue() throws Exception { .isTrue()); } - @ParameterizedRedisTest // GH-2650 + @Test // GH-2650 @EnabledOnRedisDriver(RedisDriver.LETTUCE) void retrieveReturnsNull() throws Exception { diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/ScanTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/ScanTests.java index c89882bd49..937aa534c3 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/ScanTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/ScanTests.java @@ -26,6 +26,9 @@ import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; @@ -36,14 +39,13 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("params") public class ScanTests { @@ -60,10 +62,10 @@ public ScanTests(RedisConnectionFactory factory) { public static List params() { JedisConnectionFactory jedisConnectionFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); LettuceConnectionFactory lettuceConnectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); return Arrays.asList(jedisConnectionFactory, lettuceConnectionFactory); } @@ -75,7 +77,7 @@ void setUp() { redisOperations.afterPropertiesSet(); } - @ParameterizedRedisTest + @Test void contextLoads() throws InterruptedException { BoundHashOperations hash = redisOperations.boundHashOps("hash"); diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/extension/JedisConnectionFactoryExtension.java b/src/test/java/org/springframework/data/redis/connection/jedis/extension/JedisConnectionFactoryExtension.java index 267e5cb37b..554f34b4bf 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/extension/JedisConnectionFactoryExtension.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/extension/JedisConnectionFactoryExtension.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis.extension; -import java.io.Closeable; -import java.io.IOException; import java.lang.annotation.Annotation; import java.util.HashMap; import java.util.Map; @@ -26,6 +24,7 @@ import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterResolutionException; import org.junit.jupiter.api.extension.ParameterResolver; + import org.springframework.data.redis.ConnectionFactoryTracker; import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.connection.RedisClusterConfiguration; @@ -34,9 +33,10 @@ import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.jedis.JedisClientConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.data.redis.test.RedisTestExtensionSupport; import org.springframework.data.redis.test.extension.RedisCluster; import org.springframework.data.redis.test.extension.RedisSentinel; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.data.redis.test.extension.ShutdownQueue; import org.springframework.data.util.Lazy; @@ -46,11 +46,11 @@ * specific factory instance. Instances are managed by this extension and will be shut down on JVM shutdown. * * @author Mark Paluch - * @see RedisStanalone + * @see RedisStandalone * @see RedisSentinel * @see RedisCluster */ -public class JedisConnectionFactoryExtension implements ParameterResolver { +public class JedisConnectionFactoryExtension extends RedisTestExtensionSupport implements ParameterResolver { private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace .create(JedisConnectionFactoryExtension.class); @@ -99,7 +99,7 @@ public class JedisConnectionFactoryExtension implements ParameterResolver { static { factories = new HashMap<>(); - factories.put(RedisStanalone.class, STANDALONE); + factories.put(RedisStandalone.class, STANDALONE); factories.put(RedisSentinel.class, SENTINEL); factories.put(RedisCluster.class, CLUSTER); } @@ -108,7 +108,7 @@ public class JedisConnectionFactoryExtension implements ParameterResolver { * Obtain a cached {@link JedisConnectionFactory} described by {@code qualifier}. Instances are managed by this * extension and will be shut down on JVM shutdown. * - * @param qualifier an be any of {@link RedisStanalone}, {@link RedisSentinel}, {@link RedisCluster}. + * @param qualifier can be any of {@link RedisStandalone}, {@link RedisSentinel}, {@link RedisCluster}. * @return the managed {@link JedisConnectionFactory}. */ public static JedisConnectionFactory getConnectionFactory(Class extends Annotation> qualifier) { @@ -119,7 +119,7 @@ public static JedisConnectionFactory getConnectionFactory(Class extends Annota * Obtain a new {@link JedisConnectionFactory} described by {@code qualifier}. Instances are managed by this extension * and will be shut down on JVM shutdown. * - * @param qualifier an be any of {@link RedisStanalone}, {@link RedisSentinel}, {@link RedisCluster}. + * @param qualifier can be any of {@link RedisStandalone}, {@link RedisSentinel}, {@link RedisCluster}. * @return the managed {@link JedisConnectionFactory}. */ public static JedisConnectionFactory getNewConnectionFactory(Class extends Annotation> qualifier) { @@ -136,7 +136,7 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { - ExtensionContext.Store store = extensionContext.getStore(NAMESPACE); + ExtensionContext.Store store = getSessionStore(extensionContext, NAMESPACE); Class extends Annotation> qualifier = getQualifier(parameterContext); @@ -153,7 +153,7 @@ private static Class extends Annotation> getQualifier(ParameterContext paramet return RedisCluster.class; } - return RedisStanalone.class; + return RedisStandalone.class; } static class NewableLazy { @@ -174,7 +174,7 @@ public T getNew() { } static class ManagedJedisConnectionFactory extends JedisConnectionFactory - implements ConnectionFactoryTracker.Managed, Closeable { + implements ConnectionFactoryTracker.Managed, ShutdownQueue.ShutdownCloseable { private volatile boolean mayClose; @@ -223,7 +223,7 @@ public String toString() { } @Override - public void close() throws IOException { + public void close() { try { mayClose = true; destroy(); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveCommandsTestSupport.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveCommandsTestSupport.java index 3407fea953..4bf4a794b1 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveCommandsTestSupport.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveCommandsTestSupport.java @@ -36,11 +36,12 @@ import org.assertj.core.api.Assumptions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.provider.MethodSource; + import org.springframework.beans.factory.DisposableBean; import org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection.ByteBufferCodec; import org.springframework.data.redis.test.condition.RedisDetector; import org.springframework.data.redis.test.extension.LettuceExtension; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; /** * @author Christoph Strobl diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveGeoCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveGeoCommandsIntegrationTests.java index 5f3d43e2b8..631e4c2c9d 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveGeoCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveGeoCommandsIntegrationTests.java @@ -16,6 +16,7 @@ package org.springframework.data.redis.connection.lettuce; import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.data.Offset.*; import static org.assertj.core.data.Offset.offset; import static org.springframework.data.redis.connection.RedisGeoCommands.*; import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*; @@ -28,6 +29,9 @@ import java.util.Arrays; import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.geo.Circle; import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; @@ -35,11 +39,11 @@ import org.springframework.data.redis.domain.geo.GeoReference; import org.springframework.data.redis.domain.geo.GeoShape; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Christoph Strobl */ +@ParameterizedClass public class LettuceReactiveGeoCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { private static final String ARIGENTO_MEMBER_NAME = "arigento"; @@ -61,18 +65,19 @@ public LettuceReactiveGeoCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoAddShouldAddSingleGeoLocationCorrectly() { assertThat(connection.geoCommands().geoAdd(KEY_1_BBUFFER, ARIGENTO).block()).isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test + // DATAREDIS-525 void geoAddShouldAddMultipleGeoLocationsCorrectly() { assertThat(connection.geoCommands().geoAdd(KEY_1_BBUFFER, Arrays.asList(ARIGENTO, CATANIA, PALERMO)).block()) .isEqualTo(3L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoDistShouldReturnDistanceInMetersByDefault() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -82,7 +87,7 @@ void geoDistShouldReturnDistanceInMetersByDefault() { .isCloseTo(166274.15156960033D, offset(0.005)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoDistShouldReturnDistanceInDesiredMetric() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -92,7 +97,7 @@ void geoDistShouldReturnDistanceInDesiredMetric() { .block().getValue()).isCloseTo(166.27415156960033D, offset(0.005)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoHash() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -103,7 +108,7 @@ void geoHash() { .containsExactly("sqc8b49rny0", "sqdtr74hyu0"); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoHashNotExisting() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -114,7 +119,7 @@ void geoHashNotExisting() { .containsExactly("sqc8b49rny0", null, "sqdtr74hyu0"); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoPos() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -129,7 +134,7 @@ void geoPos() { assertThat(result.get(1).getY()).isCloseTo(POINT_CATANIA.getY(), offset(0.005)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoPosNonExisting() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -146,7 +151,7 @@ void geoPosNonExisting() { assertThat(result.get(2).getY()).isCloseTo(POINT_CATANIA.getY(), offset(0.005)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoRadiusShouldReturnMembersCorrectly() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -164,7 +169,7 @@ void geoRadiusShouldReturnMembersCorrectly() { .expectComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoRadiusShouldReturnDistanceCorrectly() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -183,7 +188,7 @@ void geoRadiusShouldReturnDistanceCorrectly() { .expectComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoRadiusShouldApplyLimit() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -198,7 +203,7 @@ void geoRadiusShouldApplyLimit() { .expectComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoRadiusByMemberShouldReturnMembersCorrectly() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -216,7 +221,7 @@ void geoRadiusByMemberShouldReturnMembersCorrectly() { .expectComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoRadiusByMemberShouldReturnDistanceCorrectly() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -236,7 +241,7 @@ void geoRadiusByMemberShouldReturnDistanceCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void geoRadiusByMemberShouldApplyLimit() { nativeCommands.geoadd(KEY_1, PALERMO.getPoint().getX(), PALERMO.getPoint().getY(), PALERMO_MEMBER_NAME); @@ -250,7 +255,7 @@ void geoRadiusByMemberShouldApplyLimit() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchShouldReturnMembersCorrectly() { @@ -266,7 +271,7 @@ void geoSearchShouldReturnMembersCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCHSTORE") void geoSearchStoreShouldStoreMembersCorrectly() { diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommandsIntegrationTests.java index bc1f8cc204..0c8d8f1506 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommandsIntegrationTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.redis.connection.lettuce; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import reactor.test.StepVerifier; @@ -29,9 +29,11 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link LettuceReactiveHashCommands}. @@ -40,6 +42,7 @@ * @author Mark Paluch * @author Tihomir Mateev */ +@ParameterizedClass public class LettuceReactiveHashCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { private static final String FIELD_1 = "field-1"; @@ -58,20 +61,20 @@ public LettuceReactiveHashCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hSetShouldOperateCorrectly() { connection.hashCommands().hSet(KEY_1_BBUFFER, FIELD_1_BBUFFER, VALUE_1_BBUFFER).as(StepVerifier::create) .expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hSetNxShouldOperateCorrectly() { connection.hashCommands().hSetNX(KEY_1_BBUFFER, FIELD_1_BBUFFER, VALUE_1_BBUFFER).as(StepVerifier::create) .expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hSetNxShouldReturnFalseIfFieldAlreadyExists() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -80,7 +83,7 @@ void hSetNxShouldReturnFalseIfFieldAlreadyExists() { .expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hGetShouldReturnValueForExistingField() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -91,7 +94,7 @@ void hGetShouldReturnValueForExistingField() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hGetShouldReturnNullForNotExistingField() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -99,7 +102,7 @@ void hGetShouldReturnNullForNotExistingField() { connection.hashCommands().hGet(KEY_1_BBUFFER, FIELD_2_BBUFFER).as(StepVerifier::create).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hMGetShouldReturnValueForFields() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -114,7 +117,7 @@ void hMGetShouldReturnValueForFields() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525, GH-2210 + @Test // DATAREDIS-525, GH-2210 void hMGetShouldReturnNullValueForFieldsThatHaveNoValue() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -130,7 +133,7 @@ void hMGetShouldReturnNullValueForFieldsThatHaveNoValue() { .as(StepVerifier::create).expectNext(Arrays.asList(VALUE_1_BBUFFER, null, VALUE_3_BBUFFER)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hMSetSouldSetValuesCorrectly() { Map fieldValues = new LinkedHashMap<>(); @@ -143,7 +146,7 @@ void hMSetSouldSetValuesCorrectly() { assertThat(nativeCommands.hget(KEY_1, FIELD_2)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-791 + @Test // DATAREDIS-791 void hMSetShouldOverwriteValuesCorrectly() { Map fieldValues = new LinkedHashMap<>(); @@ -160,7 +163,7 @@ void hMSetShouldOverwriteValuesCorrectly() { assertThat(nativeCommands.hget(KEY_1, FIELD_1)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hExistsShouldReturnTrueForExistingField() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -169,13 +172,13 @@ void hExistsShouldReturnTrueForExistingField() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hExistsShouldReturnFalseForNonExistingField() { connection.hashCommands().hExists(KEY_1_BBUFFER, FIELD_1_BBUFFER).as(StepVerifier::create).expectNext(false) .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hDelShouldRemoveSingleFieldsCorrectly() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -186,7 +189,7 @@ void hDelShouldRemoveSingleFieldsCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hDelShouldRemoveMultipleFieldsCorrectly() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -197,7 +200,7 @@ void hDelShouldRemoveMultipleFieldsCorrectly() { .as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hLenShouldReturnSizeCorrectly() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -207,7 +210,7 @@ void hLenShouldReturnSizeCorrectly() { connection.hashCommands().hLen(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(3L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hKeysShouldReturnFieldsCorrectly() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -219,7 +222,7 @@ void hKeysShouldReturnFieldsCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hValsShouldReturnValuesCorrectly() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -231,7 +234,7 @@ void hValsShouldReturnValuesCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hGetAllShouldReturnEntriesCorrectly() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -250,7 +253,7 @@ void hGetAllShouldReturnEntriesCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void hScanShouldIterateOverHash() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -262,7 +265,7 @@ void hScanShouldIterateOverHash() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-698 + @Test // DATAREDIS-698 void hStrLenReturnsFieldLength() { nativeCommands.hset(KEY_1, FIELD_1, VALUE_1); @@ -273,7 +276,7 @@ void hStrLenReturnsFieldLength() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-698 + @Test // DATAREDIS-698 void hStrLenReturnsZeroWhenFieldDoesNotExist() { nativeCommands.hset(KEY_1, FIELD_2, VALUE_3); @@ -282,14 +285,14 @@ void hStrLenReturnsZeroWhenFieldDoesNotExist() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-698 + @Test // DATAREDIS-698 void hStrLenReturnsZeroWhenKeyDoesNotExist() { connection.hashCommands().hStrLen(KEY_1_BBUFFER, FIELD_1_BBUFFER).as(StepVerifier::create).expectNext(0L) // .verifyComplete(); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void hExpireShouldHandleMultipleParametersCorrectly() { @@ -305,7 +308,7 @@ void hExpireShouldHandleMultipleParametersCorrectly() { assertThat(nativeCommands.httl(KEY_1, FIELD_3)).allSatisfy(it -> assertThat(it).isEqualTo(-2L)); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void hExpireAtShouldHandleMultipleParametersCorrectly() { @@ -320,7 +323,7 @@ void hExpireAtShouldHandleMultipleParametersCorrectly() { assertThat(nativeCommands.httl(KEY_1, FIELD_3)).allSatisfy(it -> assertThat(it).isEqualTo(-2L)); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void hPersistShouldPersistFields() { diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHyperLogLogCommandsTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHyperLogLogCommandsTests.java index 2b33e87a38..278f4ac910 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHyperLogLogCommandsTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHyperLogLogCommandsTests.java @@ -21,26 +21,28 @@ import java.util.Arrays; import java.util.Collections; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; /** * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass public class LettuceReactiveHyperLogLogCommandsTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveHyperLogLogCommandsTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pfAddShouldAddToNonExistingKeyCorrectly() { assertThat(connection.hyperLogLogCommands() .pfAdd(KEY_1_BBUFFER, Arrays.asList(VALUE_1_BBUFFER, VALUE_2_BBUFFER, VALUE_3_BBUFFER)).block()).isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pfAddShouldReturnZeroWhenValueAlreadyExists() { nativeCommands.pfadd(KEY_1, VALUE_1, VALUE_2); @@ -51,7 +53,7 @@ void pfAddShouldReturnZeroWhenValueAlreadyExists() { .isEqualTo(0L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pfCountShouldReturnCorrectly() { nativeCommands.pfadd(KEY_1, VALUE_1, VALUE_2); @@ -59,7 +61,7 @@ void pfCountShouldReturnCorrectly() { assertThat(connection.hyperLogLogCommands().pfCount(KEY_1_BBUFFER).block()).isEqualTo(2L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pfCountWithMultipleKeysShouldReturnCorrectly() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -71,7 +73,7 @@ void pfCountWithMultipleKeysShouldReturnCorrectly() { .isEqualTo(3L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pfMergeShouldWorkCorrectly() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsIntegrationTests.java index 5dd4f5684b..829840dff4 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveKeyCommandsIntegrationTests.java @@ -30,6 +30,9 @@ import java.util.Collections; import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.connection.DataType; import org.springframework.data.redis.connection.ExpirationOptions; @@ -43,7 +46,6 @@ import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.test.condition.EnabledOnCommand; import org.springframework.data.redis.test.condition.EnabledOnRedisVersion; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link LettuceReactiveKeyCommands}. @@ -52,13 +54,14 @@ * @author Mark Paluch * @author Dahye Anne Lee */ +@ParameterizedClass public class LettuceReactiveKeyCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveKeyCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void existsShouldReturnTrueForExistingKeys() { nativeCommands.set(KEY_1, VALUE_1); @@ -66,12 +69,12 @@ void existsShouldReturnTrueForExistingKeys() { connection.keyCommands().exists(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void existsShouldReturnFalseForNonExistingKeys() { connection.keyCommands().exists(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // GH-2883 + @Test // GH-2883 void existsKeyReturnsKeyCount() { nativeCommands.set(KEY_1, "1000"); @@ -82,13 +85,13 @@ void existsKeyReturnsKeyCount() { .expectNext(3L).verifyComplete(); } - @ParameterizedRedisTest // GH-2883 + @Test // GH-2883 void existsKeyReturnsZeroWhenKeysDoNotExist() { connection.keyCommands().exists(List.of(KEY_1_BBUFFER, KEY_2_BBUFFER, KEY_3_BBUFFER)).as(StepVerifier::create) .expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void typeShouldReturnTypeCorrectly() { nativeCommands.set(KEY_1, VALUE_2); @@ -100,7 +103,7 @@ void typeShouldReturnTypeCorrectly() { connection.keyCommands().type(KEY_3_BBUFFER).as(StepVerifier::create).expectNext(DataType.HASH).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void keysShouldReturnCorrectly() { nativeCommands.set(KEY_1, VALUE_2); @@ -119,7 +122,7 @@ void keysShouldReturnCorrectly() { .expectNextCount(3).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void scanShouldShouldIterateOverKeyspace() { nativeCommands.set(KEY_1, VALUE_2); @@ -139,7 +142,7 @@ void scanShouldShouldIterateOverKeyspace() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2089 + @Test // GH-2089 @EnabledOnRedisVersion("6.0") void scanWithType() { @@ -163,7 +166,7 @@ void scanWithType() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void randomKeyShouldReturnAnyKey() { nativeCommands.set(KEY_1, VALUE_2); @@ -173,12 +176,12 @@ void randomKeyShouldReturnAnyKey() { connection.keyCommands().randomKey().as(StepVerifier::create).expectNextCount(1).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void randomKeyShouldReturnNullWhenNoKeyExists() { connection.keyCommands().randomKey().as(StepVerifier::create).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void renameShouldAlterKeyNameCorrectly() { nativeCommands.set(KEY_1, VALUE_2); @@ -189,14 +192,14 @@ void renameShouldAlterKeyNameCorrectly() { assertThat(nativeCommands.exists(KEY_1)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void renameShouldThrowErrorWhenKeyDoesNotExist() { connection.keyCommands().rename(KEY_1_BBUFFER, KEY_2_BBUFFER).as(StepVerifier::create) .expectError(RedisSystemException.class).verify(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void renameNXShouldAlterKeyNameCorrectly() { nativeCommands.set(KEY_1, VALUE_2); @@ -208,7 +211,7 @@ void renameNXShouldAlterKeyNameCorrectly() { assertThat(nativeCommands.exists(KEY_1)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void renameNXShouldNotAlterExistingKeyName() { nativeCommands.set(KEY_1, VALUE_2); @@ -218,7 +221,7 @@ void renameNXShouldNotAlterExistingKeyName() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void shouldDeleteKeyCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -226,7 +229,7 @@ void shouldDeleteKeyCorrectly() { connection.keyCommands().del(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void shouldDeleteKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -238,7 +241,7 @@ void shouldDeleteKeysCorrectly() { result.as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void shouldDeleteKeysInBatchCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -249,7 +252,7 @@ void shouldDeleteKeysInBatchCorrectly() { result.as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void shouldDeleteKeysInMultipleBatchesCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -263,7 +266,7 @@ void shouldDeleteKeysInMultipleBatchesCorrectly() { result.as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-693 + @Test // DATAREDIS-693 @EnabledOnCommand("UNLINK") void shouldUnlinkKeyCorrectly() { @@ -272,7 +275,7 @@ void shouldUnlinkKeyCorrectly() { connection.keyCommands().unlink(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-693 + @Test // DATAREDIS-693 @EnabledOnCommand("UNLINK") void shouldUnlinkKeysCorrectly() { @@ -285,7 +288,7 @@ void shouldUnlinkKeysCorrectly() { result.as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-693 + @Test // DATAREDIS-693 @EnabledOnCommand("UNLINK") void shouldUnlinkKeysInBatchCorrectly() { @@ -297,7 +300,7 @@ void shouldUnlinkKeysInBatchCorrectly() { result.as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-693 + @Test // DATAREDIS-693 @EnabledOnCommand("UNLINK") void shouldUnlinkKeysInMultipleBatchesCorrectly() { @@ -312,7 +315,7 @@ void shouldUnlinkKeysInMultipleBatchesCorrectly() { result.as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldExpireKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -325,7 +328,7 @@ void shouldExpireKeysCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); } - @ParameterizedRedisTest // GH-3114 + @Test // GH-3114 @EnabledOnCommand("SPUBLISH") // Redis 7.0 void shouldExpireWithOptionsKeysCorrectly() { @@ -354,7 +357,7 @@ void shouldExpireWithOptionsKeysCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-1031 + @Test // DATAREDIS-602, DATAREDIS-1031 void shouldPreciseExpireKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -367,7 +370,7 @@ void shouldPreciseExpireKeysCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-1031 + @Test // DATAREDIS-602, DATAREDIS-1031 void shouldExpireAtKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -381,7 +384,7 @@ void shouldExpireAtKeysCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-1031 + @Test // DATAREDIS-602, DATAREDIS-1031 void shouldPreciseExpireAtKeysCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -395,7 +398,7 @@ void shouldPreciseExpireAtKeysCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8).isLessThan(11); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldReportTimeToLiveCorrectly() { nativeCommands.set(KEY_1, VALUE_1, SetArgs.Builder.ex(10)); @@ -408,7 +411,7 @@ void shouldReportTimeToLiveCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(8L); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldReportPreciseTimeToLiveCorrectly() { nativeCommands.set(KEY_1, VALUE_1, SetArgs.Builder.ex(10)); @@ -422,7 +425,7 @@ void shouldReportPreciseTimeToLiveCorrectly() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldPersist() { nativeCommands.set(KEY_1, VALUE_1, SetArgs.Builder.ex(10)); @@ -435,7 +438,7 @@ void shouldPersist() { assertThat(nativeCommands.ttl(KEY_1)).isEqualTo(-1L); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldMoveToDatabase() { assumeThat(connection).isNotInstanceOf(LettuceReactiveRedisClusterConnection.class); @@ -449,7 +452,7 @@ void shouldMoveToDatabase() { assertThat(nativeCommands.exists(KEY_1)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-694 + @Test // DATAREDIS-694 void touchReturnsNrOfKeysTouched() { nativeCommands.set(KEY_1, VALUE_1); @@ -460,7 +463,7 @@ void touchReturnsNrOfKeysTouched() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-694 + @Test // DATAREDIS-694 void touchReturnsZeroIfNoKeysTouched() { connection.keyCommands().touch(Collections.singletonList(KEY_1_BBUFFER)).as(StepVerifier::create) // @@ -468,7 +471,7 @@ void touchReturnsZeroIfNoKeysTouched() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-716 + @Test // DATAREDIS-716 void encodingReturnsCorrectly() { nativeCommands.set(KEY_1, "1000"); @@ -477,14 +480,14 @@ void encodingReturnsCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-716 + @Test // DATAREDIS-716 void encodingReturnsVacantWhenKeyDoesNotExist() { connection.keyCommands().encodingOf(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(RedisValueEncoding.VACANT) .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-716 + @Test // DATAREDIS-716 void idletimeReturnsCorrectly() { nativeCommands.set(KEY_1, "1000"); @@ -495,12 +498,12 @@ void idletimeReturnsCorrectly() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-716 + @Test // DATAREDIS-716 void idldetimeReturnsNullWhenKeyDoesNotExist() { connection.keyCommands().idletime(KEY_1_BBUFFER).as(StepVerifier::create).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-716 + @Test // DATAREDIS-716 void refcountReturnsCorrectly() { nativeCommands.lpush(KEY_1, "1000"); @@ -508,7 +511,7 @@ void refcountReturnsCorrectly() { connection.keyCommands().refcount(KEY_1_BBUFFER).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-716 + @Test // DATAREDIS-716 void refcountReturnsNullWhenKeyDoesNotExist() { connection.keyCommands().refcount(KEY_1_BBUFFER).as(StepVerifier::create).verifyComplete(); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveListCommandIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveListCommandIntegrationTests.java index b09aa7fe5c..b666ca8cdb 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveListCommandIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveListCommandIntegrationTests.java @@ -27,6 +27,9 @@ import java.time.Duration; import java.util.Arrays; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.domain.Range; import org.springframework.data.redis.connection.ReactiveListCommands; @@ -38,7 +41,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.RangeCommand; import org.springframework.data.redis.connection.RedisListCommands.Position; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Christoph Strobl @@ -46,13 +48,14 @@ * @author Michele Mancioppi * @author dengliming */ +@ParameterizedClass public class LettuceReactiveListCommandIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveListCommandIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void rPushShouldAppendValuesCorrectly() { nativeCommands.lpush(KEY_1, VALUE_1); @@ -62,7 +65,7 @@ void rPushShouldAppendValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_1, VALUE_2, VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lPushShouldPrependValuesCorrectly() { nativeCommands.lpush(KEY_1, VALUE_1); @@ -72,7 +75,8 @@ void lPushShouldPrependValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_3, VALUE_2, VALUE_1); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test + // DATAREDIS-525 void rPushXShouldAppendValuesCorrectly() { nativeCommands.lpush(KEY_1, VALUE_1); @@ -81,7 +85,7 @@ void rPushXShouldAppendValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_1, VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lPushXShouldPrependValuesCorrectly() { nativeCommands.lpush(KEY_1, VALUE_1); @@ -90,7 +94,7 @@ void lPushXShouldPrependValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_2, VALUE_1); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pushShouldThrowErrorForMoreThanOneValueWhenUsingExistsOption() { assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() -> connection.listCommands() .push(Mono.just( @@ -98,7 +102,7 @@ void pushShouldThrowErrorForMoreThanOneValueWhenUsingExistsOption() { .blockFirst()); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lLenShouldReturnSizeCorrectly() { nativeCommands.lpush(KEY_1, VALUE_1, VALUE_2); @@ -106,7 +110,7 @@ void lLenShouldReturnSizeCorrectly() { assertThat(connection.listCommands().lLen(KEY_1_BBUFFER).block()).isEqualTo(2L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lRangeShouldReturnValuesCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -115,7 +119,7 @@ void lRangeShouldReturnValuesCorrectly() { VALUE_3_BBUFFER); } - @ParameterizedRedisTest // DATAREDIS-852 + @Test // DATAREDIS-852 void lRangeShouldReturnValuesCorrectlyWithMinUnbounded() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -127,7 +131,7 @@ void lRangeShouldReturnValuesCorrectlyWithMinUnbounded() { .expectNext(VALUE_1_BBUFFER).expectNext(VALUE_2_BBUFFER).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-852 + @Test // DATAREDIS-852 void lRangeShouldReturnValuesCorrectlyWithMaxUnbounded() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -139,7 +143,7 @@ void lRangeShouldReturnValuesCorrectlyWithMaxUnbounded() { .expectNext(VALUE_2_BBUFFER).expectNext(VALUE_3_BBUFFER).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lTrimShouldReturnValuesCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -148,7 +152,7 @@ void lTrimShouldReturnValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).doesNotContain(VALUE_1); } - @ParameterizedRedisTest // DATAREDIS-852 + @Test // DATAREDIS-852 void lTrimShouldReturnValuesCorrectlyWithMinUnbounded() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -160,7 +164,7 @@ void lTrimShouldReturnValuesCorrectlyWithMinUnbounded() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-852 + @Test // DATAREDIS-852 void lTrimShouldReturnValuesCorrectlyWithMaxUnbounded() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -172,7 +176,7 @@ void lTrimShouldReturnValuesCorrectlyWithMaxUnbounded() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lIndexShouldReturnValueCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -180,7 +184,7 @@ void lIndexShouldReturnValueCorrectly() { assertThat(connection.listCommands().lIndex(KEY_1_BBUFFER, 1).block()).isEqualTo(VALUE_2_BBUFFER); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lInsertShouldAddValueCorrectlyBeforeExisting() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2); @@ -191,7 +195,7 @@ void lInsertShouldAddValueCorrectlyBeforeExisting() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_1, VALUE_3, VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lInsertShouldAddValueCorrectlyAfterExisting() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2); @@ -202,7 +206,7 @@ void lInsertShouldAddValueCorrectlyAfterExisting() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_1, VALUE_2, VALUE_3); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("LMOVE") void lMoveShouldMoveValueCorrectly() { @@ -216,7 +220,7 @@ void lMoveShouldMoveValueCorrectly() { assertThat(nativeCommands.lrange(SAME_SLOT_KEY_2, 0, -1)).containsExactly(VALUE_3, VALUE_2, VALUE_3); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("LMOVE") void blMoveShouldMoveValueCorrectly() { @@ -234,7 +238,7 @@ void blMoveShouldMoveValueCorrectly() { assertThat(nativeCommands.lrange(SAME_SLOT_KEY_2, 0, -1)).containsExactly(VALUE_3, VALUE_2, VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lSetSouldSetValueCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2); @@ -244,7 +248,7 @@ void lSetSouldSetValueCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).doesNotContain(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lRemSouldRemoveAllValuesCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_1, VALUE_3); @@ -254,7 +258,7 @@ void lRemSouldRemoveAllValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).doesNotContain(VALUE_1); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lRemSouldRemoveFirstValuesCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_1, VALUE_3); @@ -263,7 +267,7 @@ void lRemSouldRemoveFirstValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_2, VALUE_1, VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lRemSouldRemoveLastValuesCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_1, VALUE_3); @@ -272,7 +276,7 @@ void lRemSouldRemoveLastValuesCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_1, VALUE_2, VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void lPopSouldRemoveFirstValueCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -284,7 +288,7 @@ void lPopSouldRemoveFirstValueCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).isEmpty(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void rPopSouldRemoveFirstValueCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -293,7 +297,7 @@ void rPopSouldRemoveFirstValueCorrectly() { assertThat(nativeCommands.lrange(KEY_1, 0, -1)).containsExactly(VALUE_1, VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void blPopShouldReturnFirstAvailable() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -306,7 +310,7 @@ void blPopShouldReturnFirstAvailable() { assertThat(result.getValue()).isEqualTo(VALUE_1_BBUFFER); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void brPopShouldReturnLastAvailable() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -319,7 +323,7 @@ void brPopShouldReturnLastAvailable() { assertThat(result.getValue()).isEqualTo(VALUE_3_BBUFFER); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void rPopLPushShouldWorkCorrectly() { nativeCommands.rpush(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -332,7 +336,7 @@ void rPopLPushShouldWorkCorrectly() { assertThat(nativeCommands.lindex(KEY_2, 0)).isEqualTo(VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void brPopLPushShouldWorkCorrectly() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -348,7 +352,7 @@ void brPopLPushShouldWorkCorrectly() { assertThat(nativeCommands.lindex(KEY_2, 0)).isEqualTo(VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lPos() { @@ -361,7 +365,7 @@ void lPos() { } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lPosRank() { @@ -374,7 +378,7 @@ void lPosRank() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lPosNegativeRank() { @@ -387,7 +391,7 @@ void lPosNegativeRank() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lPosCount() { @@ -401,7 +405,7 @@ void lPosCount() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lPosRankCount() { @@ -416,7 +420,7 @@ void lPosRankCount() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lPosCountZero() { diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveNumberCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveNumberCommandsIntegrationTests.java index 0b80066cfc..333af16c4f 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveNumberCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveNumberCommandsIntegrationTests.java @@ -16,40 +16,43 @@ package org.springframework.data.redis.connection.lettuce; import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.data.Offset.*; import static org.assertj.core.data.Offset.offset; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; /** * @author Christoph Strobl */ +@ParameterizedClass public class LettuceReactiveNumberCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveNumberCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void incrByDoubleShouldIncreaseValueCorrectly() { assertThat(connection.numberCommands().incrBy(KEY_1_BBUFFER, 1.5D).block()).isCloseTo(1.5D, offset(0D)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void incrByIntegerShouldIncreaseValueCorrectly() { assertThat(connection.numberCommands().incrBy(KEY_1_BBUFFER, 3).block()).isEqualTo(3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void decrByDoubleShouldDecreaseValueCorrectly() { assertThat(connection.numberCommands().decrBy(KEY_1_BBUFFER, 1.5D).block()).isCloseTo(-1.5D, offset(0D)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void decrByIntegerShouldDecreaseValueCorrectly() { assertThat(connection.numberCommands().decrBy(KEY_1_BBUFFER, 3).block()).isEqualTo(-3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hIncrByDoubleShouldIncreaseValueCorrectly() { nativeCommands.hset(KEY_1, KEY_1, "2"); @@ -58,7 +61,7 @@ void hIncrByDoubleShouldIncreaseValueCorrectly() { offset(0D)); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void hIncrByIntegerShouldIncreaseValueCorrectly() { nativeCommands.hset(KEY_1, KEY_1, "2"); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveScriptingCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveScriptingCommandsIntegrationTests.java index 17114f4405..b7a04f3f11 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveScriptingCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveScriptingCommandsIntegrationTests.java @@ -22,21 +22,24 @@ import java.nio.ByteBuffer; import java.util.Arrays; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.connection.ReturnType; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass public class LettuceReactiveScriptingCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveScriptingCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void scriptExistsShouldReturnState() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -49,7 +52,7 @@ void scriptExistsShouldReturnState() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void scriptFlushShouldRemoveScripts() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -69,7 +72,7 @@ void scriptFlushShouldRemoveScripts() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void evalShaShouldReturnKey() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -83,7 +86,7 @@ void evalShaShouldReturnKey() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683, DATAREDIS-711 + @Test // DATAREDIS-683, DATAREDIS-711 void evalShaShouldReturnMulti() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -97,7 +100,7 @@ void evalShaShouldReturnMulti() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void evalShaShouldFail() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -108,7 +111,7 @@ void evalShaShouldFail() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void evalShouldReturnStatus() { ByteBuffer script = wrap("return redis.call('set','%s','ghk')".formatted(SAME_SLOT_KEY_1)); @@ -119,7 +122,7 @@ void evalShouldReturnStatus() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void evalShouldReturnBooleanFalse() { ByteBuffer script = wrap("return false"); @@ -129,7 +132,7 @@ void evalShouldReturnBooleanFalse() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683, DATAREDIS-711 + @Test // DATAREDIS-683, DATAREDIS-711 void evalShouldReturnMultiNumbers() { ByteBuffer script = wrap("return {1,2}"); @@ -139,7 +142,7 @@ void evalShouldReturnMultiNumbers() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void evalShouldFailWithScriptError() { ByteBuffer script = wrap("return {1,2"); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveServerCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveServerCommandsIntegrationTests.java index ce6a8ebefe..377fdbcef9 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveServerCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveServerCommandsIntegrationTests.java @@ -20,31 +20,34 @@ import reactor.test.StepVerifier; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.connection.RedisServerCommands.FlushOption; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Mark Paluch * @author Christoph Strobl * @author Dennis Neufeld */ +@ParameterizedClass public class LettuceReactiveServerCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveServerCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void pingShouldRespondCorrectly() { connection.ping().as(StepVerifier::create).expectNext("PONG").verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void lastSaveShouldRespondCorrectly() { connection.serverCommands().lastSave().as(StepVerifier::create).expectNextCount(1).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659, DATAREDIS-667 + @Test // DATAREDIS-659, DATAREDIS-667 void saveShouldRespondCorrectly() { assumeThat(connectionProvider).isInstanceOf(StandaloneConnectionProvider.class); @@ -52,12 +55,12 @@ void saveShouldRespondCorrectly() { connection.serverCommands().save().as(StepVerifier::create).expectNext("OK").verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void dbSizeShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNextCount(1).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void flushDbShouldRespondCorrectly() { connection.serverCommands().flushDb() // @@ -72,7 +75,7 @@ void flushDbShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // GH-2187 + @Test // GH-2187 void flushDbSyncShouldRespondCorrectly() { connection.serverCommands().flushDb() // @@ -89,7 +92,7 @@ void flushDbSyncShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // GH-2187 + @Test // GH-2187 void flushDbAsyncShouldRespondCorrectly() { connection.serverCommands().flushDb() // @@ -106,7 +109,7 @@ void flushDbAsyncShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void flushAllShouldRespondCorrectly() { connection.serverCommands().flushAll() // @@ -121,7 +124,7 @@ void flushAllShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // GH-2187 + @Test // GH-2187 void flushAllSyncShouldRespondCorrectly() { connection.serverCommands().flushAll() // @@ -136,7 +139,7 @@ void flushAllSyncShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // GH-2187 + @Test // GH-2187 void flushAllAsyncShouldRespondCorrectly() { connection.serverCommands().flushAll() // @@ -151,7 +154,7 @@ void flushAllAsyncShouldRespondCorrectly() { connection.serverCommands().dbSize().as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void infoShouldRespondCorrectly() { if (connection instanceof LettuceReactiveRedisClusterConnection) { @@ -172,7 +175,7 @@ void infoShouldRespondCorrectly() { } } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void standaloneInfoWithSectionShouldRespondCorrectly() { if (connection instanceof LettuceReactiveRedisClusterConnection) { @@ -194,7 +197,7 @@ void standaloneInfoWithSectionShouldRespondCorrectly() { } } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void getConfigShouldRespondCorrectly() { if (connection instanceof LettuceReactiveRedisClusterConnection) { @@ -214,7 +217,7 @@ void getConfigShouldRespondCorrectly() { } } - @ParameterizedRedisTest // GH-2798 + @Test // GH-2798 void setConfigShouldRespondCorrectly() { if (!(connection instanceof LettuceReactiveRedisClusterConnection)) { @@ -231,7 +234,7 @@ void setConfigShouldRespondCorrectly() { } } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void setConfigShouldApplyConfiguration() { final String slowLogKey = "slowlog-max-len"; @@ -266,17 +269,17 @@ void setConfigShouldApplyConfiguration() { } } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void configResetstatShouldRespondCorrectly() { connection.serverCommands().resetConfigStats().as(StepVerifier::create).expectNext("OK").verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void timeShouldRespondCorrectly() { connection.serverCommands().time().as(StepVerifier::create).expectNextCount(1).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void setClientNameShouldSetName() { // see lettuce-io/lettuce-core#563 @@ -286,7 +289,7 @@ void setClientNameShouldSetName() { connection.serverCommands().getClientName().as(StepVerifier::create).expectNext("foo").verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-659 + @Test // DATAREDIS-659 void getClientListShouldReportClient() { connection.serverCommands().getClientList().as(StepVerifier::create).expectNextCount(1).thenCancel().verify(); } diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSetCommandsIntegrationIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSetCommandsIntegrationIntegrationTests.java index f8046aef2c..3b616c3dc0 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSetCommandsIntegrationIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSetCommandsIntegrationIntegrationTests.java @@ -21,9 +21,11 @@ import java.util.Arrays; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link LettuceReactiveSetCommands}. @@ -31,24 +33,25 @@ * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass public class LettuceReactiveSetCommandsIntegrationIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveSetCommandsIntegrationIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sAddShouldAddSingleValue() { assertThat(connection.setCommands().sAdd(KEY_1_BBUFFER, VALUE_1_BBUFFER).block()).isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sAddShouldAddValues() { assertThat(connection.setCommands().sAdd(KEY_1_BBUFFER, Arrays.asList(VALUE_1_BBUFFER, VALUE_2_BBUFFER)).block()) .isEqualTo(2L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sRemShouldRemoveSingleValue() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -57,7 +60,7 @@ void sRemShouldRemoveSingleValue() { assertThat(nativeCommands.sismember(KEY_1, VALUE_1)).isFalse(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sRemShouldRemoveValues() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -68,7 +71,7 @@ void sRemShouldRemoveValues() { assertThat(nativeCommands.sismember(KEY_1, VALUE_2)).isFalse(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sPopShouldRetrieveRandomValue() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -76,7 +79,7 @@ void sPopShouldRetrieveRandomValue() { assertThat(connection.setCommands().sPop(KEY_1_BBUFFER).block()).isNotNull(); } - @ParameterizedRedisTest // DATAREDIS-668 + @Test // DATAREDIS-668 void sPopCountShouldRetrieveValues() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -84,12 +87,12 @@ void sPopCountShouldRetrieveValues() { connection.setCommands().sPop(KEY_1_BBUFFER, 2).as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sPopShouldReturnNullWhenNotPresent() { assertThat(connection.setCommands().sPop(KEY_1_BBUFFER).block()).isNull(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sMoveShouldMoveValueCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -99,7 +102,7 @@ void sMoveShouldMoveValueCorrectly() { assertThat(nativeCommands.sismember(KEY_2, VALUE_3)).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sMoveShouldReturnFalseIfValueIsNotAMember() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -109,7 +112,7 @@ void sMoveShouldReturnFalseIfValueIsNotAMember() { assertThat(nativeCommands.sismember(KEY_2, VALUE_3)).isFalse(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sMoveShouldReturnOperateCorrectlyWhenValueAlreadyPresentInTarget() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -120,7 +123,7 @@ void sMoveShouldReturnOperateCorrectlyWhenValueAlreadyPresentInTarget() { assertThat(nativeCommands.sismember(KEY_2, VALUE_3)).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sCardShouldCountValuesCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -128,7 +131,7 @@ void sCardShouldCountValuesCorrectly() { assertThat(connection.setCommands().sCard(KEY_1_BBUFFER).block()).isEqualTo(3L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sIsMemberShouldReturnTrueWhenValueContainedInKey() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -136,7 +139,7 @@ void sIsMemberShouldReturnTrueWhenValueContainedInKey() { assertThat(connection.setCommands().sIsMember(KEY_1_BBUFFER, VALUE_1_BBUFFER).block()).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sIsMemberShouldReturnFalseWhenValueNotContainedInKey() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -144,7 +147,7 @@ void sIsMemberShouldReturnFalseWhenValueNotContainedInKey() { assertThat(connection.setCommands().sIsMember(KEY_1_BBUFFER, VALUE_3_BBUFFER).block()).isFalse(); } - @ParameterizedRedisTest // GH-2037 + @Test // GH-2037 @EnabledOnCommand("SMISMEMBER") void sMIsMemberShouldReturnCorrectly() { @@ -156,7 +159,7 @@ void sMIsMemberShouldReturnCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525, DATAREDIS-647 + @Test // DATAREDIS-525, DATAREDIS-647 void sInterShouldIntersectSetsCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -171,7 +174,7 @@ void sInterShouldIntersectSetsCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sInterStoreShouldReturnSizeCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -182,7 +185,7 @@ void sInterStoreShouldReturnSizeCorrectly() { assertThat(nativeCommands.sismember(KEY_3, VALUE_2)).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sUnionShouldCombineSetsCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -193,7 +196,7 @@ void sUnionShouldCombineSetsCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sUnionStoreShouldReturnSizeCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -203,7 +206,7 @@ void sUnionStoreShouldReturnSizeCorrectly() { .isEqualTo(3L); } - @ParameterizedRedisTest // DATAREDIS-525, DATAREDIS-647 + @Test // DATAREDIS-525, DATAREDIS-647 void sDiffShouldBeExcecutedCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -218,7 +221,7 @@ void sDiffShouldBeExcecutedCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sDiffStoreShouldBeExcecutedCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2); @@ -228,7 +231,7 @@ void sDiffStoreShouldBeExcecutedCorrectly() { .isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sMembersReadsValuesFromSetCorrectly() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -238,7 +241,7 @@ void sMembersReadsValuesFromSetCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void sScanShouldIterateOverSet() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -253,7 +256,7 @@ void sScanShouldIterateOverSet() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sRandMemberReturnsRandomMember() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); @@ -262,7 +265,7 @@ void sRandMemberReturnsRandomMember() { VALUE_3_BBUFFER); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void sRandMemberReturnsRandomMembers() { nativeCommands.sadd(KEY_1, VALUE_1, VALUE_2, VALUE_3); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java index b181ef6a60..939061be37 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStreamCommandsIntegrationTests.java @@ -25,6 +25,8 @@ import org.assertj.core.data.Offset; import org.junit.Ignore; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; import org.springframework.data.domain.Range; import org.springframework.data.redis.RedisSystemException; @@ -35,7 +37,6 @@ import org.springframework.data.redis.connection.stream.RecordId; import org.springframework.data.redis.connection.stream.StreamOffset; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link LettuceReactiveStreamCommands}. @@ -45,6 +46,7 @@ * @author Tugdual Grall * @author Dengliming */ +@ParameterizedClass @EnabledOnCommand("XADD") public class LettuceReactiveStreamCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { @@ -52,7 +54,7 @@ public LettuceReactiveStreamCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xAddShouldAddMessage() { connection.streamCommands().xAdd(KEY_1_BBUFFER, Collections.singletonMap(KEY_2_BBUFFER, VALUE_2_BBUFFER)) // @@ -66,7 +68,7 @@ void xAddShouldAddMessage() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xDelShouldRemoveMessage() { RecordId messageId = connection.streamCommands() @@ -83,7 +85,7 @@ void xDelShouldRemoveMessage() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xRangeShouldReportMessages() { connection.streamCommands().xAdd(KEY_1_BBUFFER, Collections.singletonMap(KEY_1_BBUFFER, VALUE_1_BBUFFER)) // @@ -116,7 +118,7 @@ void xRangeShouldReportMessages() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xReadShouldReadMessage() { connection.streamCommands().xAdd(KEY_1_BBUFFER, Collections.singletonMap(KEY_1_BBUFFER, VALUE_1_BBUFFER)) // @@ -134,7 +136,7 @@ void xReadShouldReadMessage() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xReadGroupShouldReadMessage() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -154,7 +156,7 @@ void xReadGroupShouldReadMessage() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xRevRangeShouldReportMessages() { connection.streamCommands().xAdd(KEY_1_BBUFFER, Collections.singletonMap(KEY_1_BBUFFER, VALUE_1_BBUFFER)) // @@ -177,7 +179,7 @@ void xRevRangeShouldReportMessages() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xGroupCreateShouldCreateGroup() { nativeCommands.xadd(KEY_1, Collections.singletonMap(KEY_2, VALUE_2)); @@ -188,7 +190,7 @@ void xGroupCreateShouldCreateGroup() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xGroupCreateShouldCreateGroupBeforeStream() { connection.streamCommands().xGroupCreate(KEY_1_BBUFFER, "group-1", ReadOffset.latest(), false) .as(StepVerifier::create) // @@ -201,7 +203,7 @@ void xGroupCreateShouldCreateGroupBeforeStream() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 @Ignore("commands sent correctly - however lettuce returns false") void xGroupDelConsumerShouldRemoveConsumer() { @@ -216,7 +218,7 @@ void xGroupDelConsumerShouldRemoveConsumer() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void xGroupDestroyShouldDestroyGroup() { String id = nativeCommands.xadd(KEY_1, Collections.singletonMap(KEY_2, VALUE_2)); @@ -227,7 +229,7 @@ void xGroupDestroyShouldDestroyGroup() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xPendingShouldLoadOverviewCorrectly() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -252,7 +254,7 @@ void xPendingShouldLoadOverviewCorrectly() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xPendingShouldLoadEmptyOverviewCorrectly() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -269,7 +271,7 @@ void xPendingShouldLoadEmptyOverviewCorrectly() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xPendingShouldLoadPendingMessages() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -294,7 +296,7 @@ void xPendingShouldLoadPendingMessages() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xPendingShouldLoadPendingMessagesForConsumer() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -319,7 +321,7 @@ void xPendingShouldLoadPendingMessagesForConsumer() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xPendingShouldLoadPendingMessagesForNonExistingConsumer() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -340,7 +342,7 @@ void xPendingShouldLoadPendingMessagesForNonExistingConsumer() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xPendingShouldLoadEmptyPendingMessages() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -354,7 +356,7 @@ void xPendingShouldLoadEmptyPendingMessages() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void xClaim() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); @@ -376,7 +378,7 @@ void xClaim() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfo() { String firstRecord = nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -397,7 +399,7 @@ void xinfo() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfoNoGroup() { String firstRecord = nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -415,7 +417,7 @@ void xinfoNoGroup() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfoGroups() { nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -433,7 +435,7 @@ void xinfoGroups() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfoGroupsNoGroup() { nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -443,7 +445,7 @@ void xinfoGroupsNoGroup() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfoGroupsNoConsumer() { nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -459,7 +461,7 @@ void xinfoGroupsNoConsumer() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfoConsumers() { nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -477,7 +479,7 @@ void xinfoConsumers() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1119 + @Test // DATAREDIS-1119 void xinfoConsumersNoConsumer() { nativeCommands.xadd(KEY_1, KEY_2, VALUE_2); @@ -487,7 +489,7 @@ void xinfoConsumersNoConsumer() { connection.streamCommands().xInfoConsumers(KEY_1_BBUFFER, "my-group").as(StepVerifier::create).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1226 + @Test // DATAREDIS-1226 void xClaimJustId() { String initialMessage = nativeCommands.xadd(KEY_1, KEY_1, VALUE_1); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommandsIntegrationTests.java index 530ec229b9..a2bb284ec1 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommandsIntegrationTests.java @@ -20,6 +20,7 @@ import static org.springframework.data.redis.connection.BitFieldSubCommands.*; import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy.Overflow.*; import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType.*; +import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.*; import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.offset; import reactor.core.publisher.Flux; @@ -38,6 +39,8 @@ import java.util.stream.Stream; import org.assertj.core.data.Offset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; import org.springframework.data.domain.Range; import org.springframework.data.domain.Range.Bound; @@ -52,7 +55,6 @@ import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.data.redis.test.util.HexStringUtils; import org.springframework.data.redis.util.ByteUtils; @@ -61,13 +63,14 @@ * @author Mark Paluch * @author Michele Mancioppi */ +@ParameterizedClass public class LettuceReactiveStringCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { public LettuceReactiveStringCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETEX") void getExShouldWorkCorrectly() { @@ -80,7 +83,7 @@ void getExShouldWorkCorrectly() { assertThat(nativeCommands.ttl(KEY_1)).isGreaterThan(1L); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETDEL") void getDelShouldWorkCorrectly() { @@ -93,7 +96,8 @@ void getDelShouldWorkCorrectly() { assertThat(nativeCommands.exists(KEY_1)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test + // DATAREDIS-525 void getSetShouldReturnPreviousValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -105,7 +109,7 @@ void getSetShouldReturnPreviousValueCorrectly() { assertThat(nativeCommands.get(KEY_1)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525, DATAREDIS-645 + @Test // DATAREDIS-525, DATAREDIS-645 void getSetShouldNotEmitPreviousValueCorrectlyWhenNotExists() { connection.stringCommands().getSet(KEY_1_BBUFFER, VALUE_2_BBUFFER).as(StepVerifier::create).verifyComplete(); @@ -113,7 +117,7 @@ void getSetShouldNotEmitPreviousValueCorrectlyWhenNotExists() { assertThat(nativeCommands.get(KEY_1)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setShouldAddValueCorrectly() { connection.stringCommands().set(KEY_1_BBUFFER, VALUE_1_BBUFFER).as(StepVerifier::create) // @@ -123,7 +127,7 @@ void setShouldAddValueCorrectly() { assertThat(nativeCommands.get(KEY_1)).isEqualTo(VALUE_1); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setShouldAddValuesCorrectly() { List setCommands = Arrays.asList(SetCommand.set(KEY_1_BBUFFER).value(VALUE_1_BBUFFER), @@ -137,7 +141,7 @@ void setShouldAddValuesCorrectly() { assertThat(nativeCommands.get(KEY_2)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getShouldRetrieveValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -146,12 +150,12 @@ void getShouldRetrieveValueCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525, DATAREDIS-645 + @Test // DATAREDIS-525, DATAREDIS-645 void getShouldNotEmitValueValueIfAbsent() { connection.stringCommands().get(KEY_1_BBUFFER).as(StepVerifier::create).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getShouldRetrieveValuesCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -165,7 +169,7 @@ void getShouldRetrieveValuesCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getShouldRetrieveValuesWithNullCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -181,7 +185,7 @@ void getShouldRetrieveValuesWithNullCorrectly() { } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void mGetShouldRetrieveValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -193,7 +197,7 @@ void mGetShouldRetrieveValueCorrectly() { } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void mGetShouldRetrieveNullValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -205,7 +209,7 @@ void mGetShouldRetrieveNullValueCorrectly() { assertThat(result.block()).containsExactly(VALUE_1_BBUFFER, null, VALUE_3_BBUFFER); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void mGetShouldRetrieveValuesCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -225,7 +229,7 @@ void mGetShouldRetrieveValuesCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setNXshouldOnlySetValueWhenNotPresent() { connection.stringCommands().setNX(KEY_1_BBUFFER, VALUE_1_BBUFFER).as(StepVerifier::create) // @@ -233,7 +237,7 @@ void setNXshouldOnlySetValueWhenNotPresent() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setNXshouldNotSetValueWhenAlreadyPresent() { nativeCommands.setnx(KEY_1, VALUE_1); @@ -243,7 +247,7 @@ void setNXshouldNotSetValueWhenAlreadyPresent() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setEXshouldSetKeyAndExpirationTime() { connection.stringCommands().setEX(KEY_1_BBUFFER, VALUE_1_BBUFFER, Expiration.seconds(3)).as(StepVerifier::create) // @@ -253,7 +257,7 @@ void setEXshouldSetKeyAndExpirationTime() { assertThat(nativeCommands.ttl(KEY_1) > 1).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void pSetEXshouldSetKeyAndExpirationTime() { connection.stringCommands().pSetEX(KEY_1_BBUFFER, VALUE_1_BBUFFER, Expiration.milliseconds(600)) @@ -264,7 +268,7 @@ void pSetEXshouldSetKeyAndExpirationTime() { assertThat(nativeCommands.pttl(KEY_1) > 1).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void mSetShouldAddMultipleKeyValuePairs() { Map map = new LinkedHashMap<>(); @@ -277,7 +281,7 @@ void mSetShouldAddMultipleKeyValuePairs() { assertThat(nativeCommands.get(KEY_2)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void mSetNXShouldAddMultipleKeyValuePairs() { assumeTrue(connectionProvider instanceof StandaloneConnectionProvider); @@ -292,7 +296,7 @@ void mSetNXShouldAddMultipleKeyValuePairs() { assertThat(nativeCommands.get(KEY_2)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void mSetNXShouldNotAddMultipleKeyValuePairsWhenAlreadyExit() { assumeTrue(connectionProvider instanceof StandaloneConnectionProvider); @@ -309,7 +313,7 @@ void mSetNXShouldNotAddMultipleKeyValuePairsWhenAlreadyExit() { assertThat(nativeCommands.get(KEY_2)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void appendShouldDoItsThing() { connection.stringCommands().append(KEY_1_BBUFFER, VALUE_1_BBUFFER).as(StepVerifier::create) // @@ -321,7 +325,7 @@ void appendShouldDoItsThing() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getRangeShouldReturnSubstringCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -331,7 +335,7 @@ void getRangeShouldReturnSubstringCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getRangeShouldReturnSubstringCorrectlyWithMinUnbound() { nativeCommands.set(KEY_1, VALUE_1); @@ -344,7 +348,7 @@ void getRangeShouldReturnSubstringCorrectlyWithMinUnbound() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getRangeShouldReturnSubstringCorrectlyWithMaxUnbound() { nativeCommands.set(KEY_1, VALUE_1); @@ -357,7 +361,7 @@ void getRangeShouldReturnSubstringCorrectlyWithMaxUnbound() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setRangeShouldReturnNewStringLengthCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -367,7 +371,7 @@ void setRangeShouldReturnNewStringLengthCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void getBitShouldReturnValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -381,7 +385,7 @@ void getBitShouldReturnValueCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void setBitShouldReturnValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -393,7 +397,7 @@ void setBitShouldReturnValueCorrectly() { assertThat(nativeCommands.getbit(KEY_1, 1)).isEqualTo(0L); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void bitCountShouldReturnValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -403,7 +407,7 @@ void bitCountShouldReturnValueCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void bitCountShouldCountInRangeCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -413,7 +417,7 @@ void bitCountShouldCountInRangeCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-562 + @Test // DATAREDIS-562 void bitFieldSetShouldWorkCorrectly() { connection.stringCommands().bitField(KEY_1_BBUFFER, create().set(INT_8).valueAt(offset(0L)).to(10L)) @@ -425,7 +429,7 @@ void bitFieldSetShouldWorkCorrectly() { .expectNext(Collections.singletonList(10L)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-562 + @Test // DATAREDIS-562 void bitFieldGetShouldWorkCorrectly() { connection.stringCommands().bitField(KEY_1_BBUFFER, create().get(INT_8).valueAt(offset(0L))) @@ -433,7 +437,7 @@ void bitFieldGetShouldWorkCorrectly() { .expectNext(Collections.singletonList(0L)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-562 + @Test // DATAREDIS-562 void bitFieldIncrByShouldWorkCorrectly() { connection.stringCommands().bitField(KEY_1_BBUFFER, create().incr(INT_8).valueAt(offset(100L)).by(1L)) @@ -441,7 +445,7 @@ void bitFieldIncrByShouldWorkCorrectly() { .expectNext(Collections.singletonList(1L)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-562 + @Test // DATAREDIS-562 void bitFieldIncrByWithOverflowShouldWorkCorrectly() { connection.stringCommands() @@ -462,7 +466,7 @@ void bitFieldIncrByWithOverflowShouldWorkCorrectly() { .expectNext(Collections.singletonList(null)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-562 + @Test // DATAREDIS-562 void bitfieldShouldAllowMultipleSubcommands() { connection.stringCommands() @@ -471,7 +475,7 @@ void bitfieldShouldAllowMultipleSubcommands() { .expectNext(Arrays.asList(1L, 0L)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void bitOpAndShouldWorkAsExpected() { assumeTrue(connectionProvider instanceof StandaloneConnectionProvider); @@ -487,7 +491,7 @@ void bitOpAndShouldWorkAsExpected() { assertThat(nativeCommands.get(KEY_3)).isEqualTo("value-0"); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void bitOpOrShouldWorkAsExpected() { assumeTrue(connectionProvider instanceof StandaloneConnectionProvider); @@ -503,7 +507,7 @@ void bitOpOrShouldWorkAsExpected() { assertThat(nativeCommands.get(KEY_3)).isEqualTo(VALUE_3); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void bitNotShouldThrowExceptionWhenMoreThanOnSourceKey() { assumeTrue(connectionProvider instanceof StandaloneConnectionProvider); @@ -514,7 +518,7 @@ void bitNotShouldThrowExceptionWhenMoreThanOnSourceKey() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void strLenShouldReturnValueCorrectly() { nativeCommands.set(KEY_1, VALUE_1); @@ -524,7 +528,7 @@ void strLenShouldReturnValueCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-697 + @Test // DATAREDIS-697 void bitPosShouldReturnPositionCorrectly() { nativeBinaryCommands.set(KEY_1_BBUFFER, ByteBuffer.wrap(HexStringUtils.hexToBytes("fff000"))); @@ -532,7 +536,7 @@ void bitPosShouldReturnPositionCorrectly() { connection.stringCommands().bitPos(KEY_1_BBUFFER, false).as(StepVerifier::create).expectNext(12L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-697 + @Test // DATAREDIS-697 void bitPosShouldReturnPositionInRangeCorrectly() { nativeBinaryCommands.set(KEY_1_BBUFFER, ByteBuffer.wrap(HexStringUtils.hexToBytes("fff0f0"))); @@ -542,7 +546,7 @@ void bitPosShouldReturnPositionInRangeCorrectly() { .expectNext(16L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1103 + @Test // DATAREDIS-1103 void setKeepTTL() { long expireSeconds = 10; @@ -557,7 +561,7 @@ void setKeepTTL() { assertThat(nativeCommands.get(KEY_1)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // GH-2853 + @Test // GH-2853 void setGetMono() { nativeCommands.set(KEY_1, VALUE_1); @@ -570,7 +574,7 @@ void setGetMono() { assertThat(nativeCommands.get(KEY_1)).isEqualTo(VALUE_2); } - @ParameterizedRedisTest // GH-2853 + @Test // GH-2853 void setGetFlux() { nativeCommands.set(KEY_1, VALUE_1); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java index 1dac69219b..886783ca29 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommandsIntegrationTests.java @@ -28,6 +28,9 @@ import java.util.Arrays; import java.util.function.Function; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.domain.Range; import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.data.redis.connection.ReactiveZSetCommands.ZAddCommand; @@ -35,7 +38,6 @@ import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link LettuceReactiveZSetCommands}. @@ -44,6 +46,7 @@ * @author Mark Paluch * @author Michele Mancioppi */ +@ParameterizedClass public class LettuceReactiveZSetCommandsIntegrationTests extends LettuceReactiveCommandsTestSupport { private static final Range ONE_TO_TWO = Range.closed(1L, 2L); @@ -56,12 +59,12 @@ public LettuceReactiveZSetCommandsIntegrationTests(Fixture fixture) { super(fixture); } - @ParameterizedRedisTest // DATAREDIS-525 + @Test // DATAREDIS-525 void zAddShouldAddValuesWithScores() { assertThat(connection.zSetCommands().zAdd(KEY_1_BBUFFER, 3.5D, VALUE_1_BBUFFER).block()).isEqualTo(1L); } - @ParameterizedRedisTest // GH-2731 + @Test // GH-2731 void zAddShouldConsiderAbsentPresentUpsertFlags() { Tuple tuple = Tuple.of(VALUE_1_BYTES, 3.5D); @@ -99,7 +102,7 @@ void zAddShouldConsiderAbsentPresentUpsertFlags() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2731 + @Test // GH-2731 void zAddShouldConsiderLessThan() { Tuple tuple = Tuple.of(VALUE_1_BYTES, 3.5D); @@ -130,7 +133,7 @@ void zAddShouldConsiderLessThan() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2731 + @Test // GH-2731 void zAddShouldConsiderGreaterThan() { Tuple tuple = Tuple.of(VALUE_1_BYTES, 3.5D); @@ -161,7 +164,7 @@ void zAddShouldConsiderGreaterThan() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2731 + @Test // GH-2731 void zAddShouldConsiderIncrFlag() { Tuple tuple = Tuple.of(VALUE_1_BYTES, 3.5D); @@ -178,7 +181,7 @@ void zAddShouldConsiderIncrFlag() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2731 + @Test // GH-2731 void zAddShouldConsiderChFlag() { Tuple tuple = Tuple.of(VALUE_1_BYTES, 3.5D); @@ -204,7 +207,7 @@ private Flux zAdd(ByteBuffer key, Tuple tuple, Function(); - pooledFactories.put(RedisStanalone.class, STANDALONE); + pooledFactories.put(RedisStandalone.class, STANDALONE); pooledFactories.put(RedisSentinel.class, SENTINEL); pooledFactories.put(RedisCluster.class, CLUSTER); unpooledFactories = new HashMap<>(); - unpooledFactories.put(RedisStanalone.class, STANDALONE_UNPOOLED); + unpooledFactories.put(RedisStandalone.class, STANDALONE_UNPOOLED); unpooledFactories.put(RedisSentinel.class, SENTINEL_UNPOOLED); unpooledFactories.put(RedisCluster.class, CLUSTER_UNPOOLED); } @@ -169,7 +169,7 @@ private static LettuceClientConfiguration defaultClientConfiguration() { * Obtain a {@link LettuceConnectionFactory} described by {@code qualifier}. Instances are managed by this extension * and will be shut down on JVM shutdown. * - * @param qualifier an be any of {@link RedisStanalone}, {@link RedisSentinel}, {@link RedisCluster}. + * @param qualifier can be any of {@link RedisStandalone}, {@link RedisSentinel}, {@link RedisCluster}. * @return the managed {@link LettuceConnectionFactory}. */ public static LettuceConnectionFactory getConnectionFactory(Class extends Annotation> qualifier) { @@ -180,7 +180,7 @@ public static LettuceConnectionFactory getConnectionFactory(Class extends Anno * Obtain a {@link LettuceConnectionFactory} described by {@code qualifier}. Instances are managed by this extension * and will be shut down on JVM shutdown. * - * @param qualifier an be any of {@link RedisStanalone}, {@link RedisSentinel}, {@link RedisCluster}. + * @param qualifier can be any of {@link RedisStandalone}, {@link RedisSentinel}, {@link RedisCluster}. * @return the managed {@link LettuceConnectionFactory}. */ public static LettuceConnectionFactory getConnectionFactory(Class extends Annotation> qualifier, boolean pooled) { @@ -198,7 +198,7 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { - ExtensionContext.Store store = extensionContext.getStore(NAMESPACE); + ExtensionContext.Store store = getSessionStore(extensionContext, NAMESPACE); Class extends Annotation> qualifier = getQualifier(parameterContext); @@ -215,11 +215,11 @@ private static Class extends Annotation> getQualifier(ParameterContext paramet return RedisCluster.class; } - return RedisStanalone.class; + return RedisStandalone.class; } static class ManagedLettuceConnectionFactory extends LettuceConnectionFactory - implements ConnectionFactoryTracker.Managed, Closeable { + implements ConnectionFactoryTracker.Managed, ShutdownQueue.ShutdownCloseable { private volatile boolean mayClose; @@ -270,7 +270,7 @@ public String toString() { } @Override - public void close() throws IOException { + public void close() { mayClose = true; destroy(); diff --git a/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java b/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java index 485b6b1414..7bbb9fc73a 100644 --- a/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java +++ b/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java @@ -29,7 +29,6 @@ import org.springframework.data.redis.StringObjectFactory; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; -import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.GenericToStringSerializer; @@ -37,7 +36,7 @@ import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Parameters for testing implementations of {@link AbstractOperations} @@ -53,8 +52,8 @@ abstract public class AbstractOperationsTestParams { public static Collection testParams() { List params = new ArrayList<>(); - params.addAll(testParams(LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class))); - params.addAll(testParams(JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class))); + params.addAll(testParams(LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class))); + params.addAll(testParams(JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class))); return params; } diff --git a/src/test/java/org/springframework/data/redis/core/BoundOperationsProxyFactoryRuntimeHintTests.java b/src/test/java/org/springframework/data/redis/core/BoundOperationsProxyFactoryRuntimeHintTests.java index ffd9e4f772..125eb39ddb 100644 --- a/src/test/java/org/springframework/data/redis/core/BoundOperationsProxyFactoryRuntimeHintTests.java +++ b/src/test/java/org/springframework/data/redis/core/BoundOperationsProxyFactoryRuntimeHintTests.java @@ -26,7 +26,7 @@ import org.springframework.data.redis.connection.DataType; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Christoph Strobl @@ -38,7 +38,7 @@ class BoundOperationsProxyFactoryRuntimeHintTests { void boundOpsRuntimeHints() { LettuceConnectionFactory connectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate template = new RedisTemplate<>(); template.setConnectionFactory(connectionFactory); template.afterPropertiesSet(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultGeoOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultGeoOperationsIntegrationTests.java index 0000db4885..b94a9b2551 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultGeoOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultGeoOperationsIntegrationTests.java @@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; +import static org.assertj.core.data.Offset.*; import static org.assertj.core.data.Offset.offset; import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*; import static org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.*; @@ -28,6 +29,9 @@ import org.assertj.core.data.Offset; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.DataAccessException; import org.springframework.data.geo.Circle; @@ -42,8 +46,6 @@ import org.springframework.data.redis.domain.geo.BoundingBox; import org.springframework.data.redis.domain.geo.GeoReference; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.lang.Nullable; /** @@ -53,6 +55,7 @@ * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") @EnabledOnCommand("GEOADD") public class DefaultGeoOperationsIntegrationTests { @@ -92,7 +95,7 @@ void setUp() { }); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void testGeoAdd() { Long numAdded = geoOperations.add(keyFactory.instance(), POINT_PALERMO, valueFactory.instance()); @@ -100,7 +103,7 @@ void testGeoAdd() { assertThat(numAdded).isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void testGeoAddWithLocationMap() { Map memberCoordinateMap = new HashMap<>(); @@ -112,7 +115,8 @@ void testGeoAddWithLocationMap() { assertThat(numAdded).isEqualTo(2L); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test + // DATAREDIS-438, DATAREDIS-614 void geoDistShouldReturnDistanceInMetersByDefault() { K key = keyFactory.instance(); @@ -127,7 +131,7 @@ void geoDistShouldReturnDistanceInMetersByDefault() { assertThat(dist.getUnit()).isEqualTo("m"); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoDistShouldReturnDistanceInKilometersCorrectly() { K key = keyFactory.instance(); @@ -142,7 +146,7 @@ void geoDistShouldReturnDistanceInKilometersCorrectly() { assertThat(dist.getUnit()).isEqualTo("km"); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoDistShouldReturnDistanceInMilesCorrectly() { K key = keyFactory.instance(); @@ -157,7 +161,7 @@ void geoDistShouldReturnDistanceInMilesCorrectly() { assertThat(dist.getUnit()).isEqualTo("mi"); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoDistShouldReturnDistanceInFeeCorrectly() { K key = keyFactory.instance(); @@ -172,7 +176,7 @@ void geoDistShouldReturnDistanceInFeeCorrectly() { assertThat(dist.getUnit()).isEqualTo("ft"); } - @ParameterizedRedisTest // DATAREDIS-1214 + @Test // DATAREDIS-1214 void geoDistShouldReturnNullIfNoDistanceCalculable() { K key = keyFactory.instance(); @@ -188,7 +192,7 @@ void geoDistShouldReturnNullIfNoDistanceCalculable() { assertThat(dist).isNull(); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void testGeoHash() { K key = keyFactory.instance(); @@ -205,7 +209,7 @@ void testGeoHash() { assertThat(result.get(1)).isEqualTo("sqdtr74hyu0"); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void testGeoPos() { K key = keyFactory.instance(); @@ -228,7 +232,7 @@ void testGeoPos() { assertThat(result.get(2)).isNull(); } - @ParameterizedRedisTest // GH-2279 + @Test // GH-2279 void geoRadius() { K key = keyFactory.instance(); @@ -250,7 +254,7 @@ public GeoResults execute(RedisOperations operations) throws DataAc assertThat(results.getContent().get(0).getDistance().getValue()).isCloseTo(0, Offset.offset(0.005)); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusShouldReturnMembersCorrectly() { K key = keyFactory.instance(); @@ -266,7 +270,7 @@ void geoRadiusShouldReturnMembersCorrectly() { assertThat(result.getContent()).hasSize(2); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusShouldReturnLocationsWithDistance() { K key = keyFactory.instance(); @@ -290,7 +294,7 @@ void geoRadiusShouldReturnLocationsWithDistance() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member2); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusShouldReturnLocationsWithCoordinates() { K key = keyFactory.instance(); @@ -318,7 +322,7 @@ void geoRadiusShouldReturnLocationsWithCoordinates() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member1); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusShouldReturnLocationsWithCoordinatesAndDistance() { K key = keyFactory.instance(); @@ -350,7 +354,7 @@ void geoRadiusShouldReturnLocationsWithCoordinatesAndDistance() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member1); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusByMemberShouldReturnMembersCorrectly() { K key = keyFactory.instance(); @@ -366,7 +370,7 @@ void geoRadiusByMemberShouldReturnMembersCorrectly() { assertThat(result.getContent()).hasSize(3); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusByMemberShouldReturnDistanceCorrectly() { K key = keyFactory.instance(); @@ -388,7 +392,7 @@ void geoRadiusByMemberShouldReturnDistanceCorrectly() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member3); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusByMemberShouldReturnCoordinates() { K key = keyFactory.instance(); @@ -417,7 +421,7 @@ void geoRadiusByMemberShouldReturnCoordinates() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member1); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusByMemberShouldReturnCoordinatesAndDistance() { K key = keyFactory.instance(); @@ -449,7 +453,7 @@ void geoRadiusByMemberShouldReturnCoordinatesAndDistance() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member3); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void testGeoRemove() { K key = keyFactory.instance(); @@ -460,7 +464,7 @@ void testGeoRemove() { assertThat(geoOperations.remove(key, member1)).isEqualTo(1L); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchWithinShouldReturnMembers() { @@ -491,7 +495,7 @@ void geoSearchWithinShouldReturnMembers() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member3); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchByMemberShouldReturnResults() { @@ -522,7 +526,7 @@ void geoSearchByMemberShouldReturnResults() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member3); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchByPointWithinBoundingBoxShouldReturnMembers() { @@ -554,7 +558,7 @@ void geoSearchByPointWithinBoundingBoxShouldReturnMembers() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member3); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchByMemberWithinBoundingBoxShouldReturnMembers() { @@ -585,7 +589,7 @@ void geoSearchByMemberWithinBoundingBoxShouldReturnMembers() { assertThat(result.getContent().get(1).getContent().getName()).isEqualTo(member3); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCHSTORE") void geoSearchAndStoreWithinShouldReturnMembers() { diff --git a/src/test/java/org/springframework/data/redis/core/DefaultHashOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultHashOperationsIntegrationTests.java index 4982e72973..174a49ec78 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultHashOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultHashOperationsIntegrationTests.java @@ -29,6 +29,9 @@ import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.RawObjectFactory; @@ -39,9 +42,7 @@ import org.springframework.data.redis.core.ExpireChanges.ExpiryChangeState; import org.springframework.data.redis.core.types.Expirations.TimeToLive; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration test of {@link DefaultHashOperations} @@ -53,6 +54,7 @@ * @param Hash key type * @param Hash value type */ +@ParameterizedClass @MethodSource("testParams") public class DefaultHashOperationsIntegrationTests { @@ -77,7 +79,7 @@ public static Collection testParams() { ObjectFactory rawFactory = new RawObjectFactory(); JedisConnectionFactory jedisConnectionFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate stringTemplate = new StringRedisTemplate(); stringTemplate.setConnectionFactory(jedisConnectionFactory); @@ -100,7 +102,7 @@ void setUp() { }); } - @ParameterizedRedisTest + @Test void testEntries() { K key = keyFactory.instance(); HK key1 = hashKeyFactory.instance(); @@ -116,7 +118,7 @@ void testEntries() { } } - @ParameterizedRedisTest + @Test void testDelete() { K key = keyFactory.instance(); HK key1 = hashKeyFactory.instance(); @@ -130,7 +132,7 @@ void testDelete() { assertThat(numDeleted.longValue()).isEqualTo(2L); } - @ParameterizedRedisTest // DATAREDIS-305 + @Test // DATAREDIS-305 void testHScanReadsValuesFully() throws IOException { K key = keyFactory.instance(); @@ -155,7 +157,7 @@ void testHScanReadsValuesFully() throws IOException { assertThat(count).isEqualTo(hashOps.size(key)); } - @ParameterizedRedisTest // DATAREDIS-698 + @Test // DATAREDIS-698 void lengthOfValue() throws IOException { assumeThat(hashValueFactory instanceof StringObjectFactory).isTrue(); @@ -172,7 +174,7 @@ void lengthOfValue() throws IOException { assertThat(hashOps.lengthOfValue(key, key1)).isEqualTo(Long.valueOf(val1.toString().length())); } - @ParameterizedRedisTest // GH-2048 + @Test // GH-2048 void randomField() { K key = keyFactory.instance(); @@ -187,7 +189,7 @@ void randomField() { assertThat(hashOps.randomKeys(key, 2)).hasSize(2).contains(key1, key2); } - @ParameterizedRedisTest // GH-2048 + @Test // GH-2048 void randomValue() { assumeThat(hashKeyFactory).isNotInstanceOf(RawObjectFactory.class); @@ -213,7 +215,7 @@ void randomValue() { } @EnabledOnCommand("HEXPIRE") // GH-3054 - @ParameterizedRedisTest + @Test void testExpireAndGetExpireMillis() { K key = keyFactory.instance(); @@ -237,7 +239,7 @@ void testExpireAndGetExpireMillis() { }); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireAndGetExpireSeconds() { @@ -268,7 +270,7 @@ void testExpireAndGetExpireSeconds() { }); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testBoundExpireAndGetExpireSeconds() { @@ -300,7 +302,7 @@ void testBoundExpireAndGetExpireSeconds() { }); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireAtAndGetExpireMillis() { @@ -325,7 +327,7 @@ void testExpireAtAndGetExpireMillis() { }); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void expireThrowsErrorOfNanoPrecision() { @@ -336,7 +338,7 @@ void expireThrowsErrorOfNanoPrecision() { .isThrownBy(() -> redisTemplate.opsForHash().getTimeToLive(key, TimeUnit.NANOSECONDS, List.of(key1))); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireWithOptionsNone() { @@ -355,7 +357,7 @@ void testExpireWithOptionsNone() { assertThat(expire.allOk()).isTrue(); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireWithOptions() { @@ -381,7 +383,7 @@ void testExpireWithOptions() { assertThat(changes.skipped()).containsExactly(key2); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testPersistAndGetExpireMillis() { diff --git a/src/test/java/org/springframework/data/redis/core/DefaultHyperLogLogOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultHyperLogLogOperationsIntegrationTests.java index be31c3932e..955bead704 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultHyperLogLogOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultHyperLogLogOperationsIntegrationTests.java @@ -20,15 +20,17 @@ import java.util.Collection; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") public class DefaultHyperLogLogOperationsIntegrationTests { @@ -58,7 +60,7 @@ void setUp() { }); } - @ParameterizedRedisTest // DATAREDIS-308 + @Test // DATAREDIS-308 @SuppressWarnings("unchecked") void addShouldAddDistinctValuesCorrectly() { @@ -70,7 +72,7 @@ void addShouldAddDistinctValuesCorrectly() { assertThat(hyperLogLogOps.add(key, v1, v2, v3)).isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-308 + @Test // DATAREDIS-308 @SuppressWarnings("unchecked") void addShouldNotAddExistingValuesCorrectly() { @@ -83,7 +85,7 @@ void addShouldNotAddExistingValuesCorrectly() { assertThat(hyperLogLogOps.add(key, v2)).isEqualTo(0L); } - @ParameterizedRedisTest // DATAREDIS-308 + @Test // DATAREDIS-308 @SuppressWarnings("unchecked") void sizeShouldCountValuesCorrectly() { @@ -96,7 +98,7 @@ void sizeShouldCountValuesCorrectly() { assertThat(hyperLogLogOps.size(key)).isEqualTo(3L); } - @ParameterizedRedisTest // DATAREDIS-308 + @Test // DATAREDIS-308 @SuppressWarnings("unchecked") void sizeShouldCountValuesOfMultipleKeysCorrectly() { @@ -114,7 +116,7 @@ void sizeShouldCountValuesOfMultipleKeysCorrectly() { assertThat(hyperLogLogOps.size(key, key2)).isGreaterThan(3L); } - @ParameterizedRedisTest // DATAREDIS-308 + @Test // DATAREDIS-308 @SuppressWarnings("unchecked") void unionShouldMergeValuesOfMultipleKeysCorrectly() throws InterruptedException { diff --git a/src/test/java/org/springframework/data/redis/core/DefaultListOperationsIntegrationIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultListOperationsIntegrationIntegrationTests.java index 4965b45032..2b77a25ac5 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultListOperationsIntegrationIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultListOperationsIntegrationIntegrationTests.java @@ -25,14 +25,15 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.StringObjectFactory; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link DefaultListOperations} @@ -44,6 +45,7 @@ * @param Key test * @param Value test */ +@ParameterizedClass @MethodSource("testParams") public class DefaultListOperationsIntegrationIntegrationTests { @@ -77,7 +79,7 @@ void setUp() { }); } - @ParameterizedRedisTest + @Test void testLeftPushWithPivot() { K key = keyFactory.instance(); @@ -91,7 +93,7 @@ void testLeftPushWithPivot() { assertThat(listOps.range(key, 0, -1)).containsSequence(v2, v3, v1); } - @ParameterizedRedisTest + @Test void testLeftPushIfPresent() { K key = keyFactory.instance(); @@ -105,7 +107,7 @@ void testLeftPushIfPresent() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testLeftPushAll() { K key = keyFactory.instance(); @@ -118,7 +120,7 @@ void testLeftPushAll() { assertThat(listOps.range(key, 0, -1)).contains(v3, v2, v1); } - @ParameterizedRedisTest // DATAREDIS-611 + @Test // DATAREDIS-611 @EnabledIfLongRunningTest void testLeftPopDuration() { @@ -134,7 +136,7 @@ void testLeftPopDuration() { assertThat(listOps.leftPop(key, Duration.ofSeconds(1))).isEqualTo(v1); } - @ParameterizedRedisTest // DATAREDIS-611 + @Test // DATAREDIS-611 @EnabledIfLongRunningTest void testRightPopDuration() { @@ -150,7 +152,7 @@ void testRightPopDuration() { assertThat(listOps.rightPop(key, Duration.ofSeconds(1))).isEqualTo(v2); } - @ParameterizedRedisTest + @Test @EnabledIfLongRunningTest void testRightPopAndLeftPushTimeout() { // 1 ms timeout gets upgraded to 1 sec timeout at the moment @@ -165,7 +167,7 @@ void testRightPopAndLeftPushTimeout() { assertThat(listOps.rightPopAndLeftPush(key, key2, 1, TimeUnit.MILLISECONDS)).isEqualTo(v1); } - @ParameterizedRedisTest // DATAREDIS-611 + @Test // DATAREDIS-611 @EnabledIfLongRunningTest void testRightPopAndLeftPushDuration() { // 1 ms timeout gets upgraded to 1 sec timeout at the moment @@ -180,7 +182,7 @@ void testRightPopAndLeftPushDuration() { assertThat(listOps.rightPopAndLeftPush(key, key2, Duration.ofMillis(1))).isEqualTo(v1); } - @ParameterizedRedisTest + @Test void testRightPopAndLeftPush() { K key = keyFactory.instance(); @@ -192,7 +194,7 @@ void testRightPopAndLeftPush() { assertThat(listOps.rightPopAndLeftPush(key, key2)).isEqualTo(v1); } - @ParameterizedRedisTest + @Test void testRightPushWithPivot() { K key = keyFactory.instance(); @@ -206,7 +208,7 @@ void testRightPushWithPivot() { assertThat(listOps.range(key, 0, -1)).containsSequence(v1, v3, v2); } - @ParameterizedRedisTest + @Test void testRightPushIfPresent() { K key = keyFactory.instance(); @@ -220,7 +222,7 @@ void testRightPushIfPresent() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testRightPushAll() { K key = keyFactory.instance(); @@ -233,7 +235,7 @@ void testRightPushAll() { assertThat(listOps.range(key, 0, -1)).containsSequence(v1, v2, v3); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void testRightPushAllCollection() { @@ -247,26 +249,26 @@ void testRightPushAllCollection() { assertThat(listOps.range(key, 0, -1)).containsSequence(v1, v2, v3); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void rightPushAllShouldThrowExceptionWhenCalledWithEmptyCollection() { assertThatIllegalArgumentException() .isThrownBy(() -> listOps.rightPushAll(keyFactory.instance(), Collections. emptyList())); } - @ParameterizedRedisTest + @Test // DATAREDIS-288 void rightPushAllShouldThrowExceptionWhenCollectionContainsNullValue() { assertThatIllegalArgumentException() .isThrownBy(() -> listOps.rightPushAll(keyFactory.instance(), Arrays.asList(valueFactory.instance(), null))); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void rightPushAllShouldThrowExceptionWhenCalledWithNull() { assertThatIllegalArgumentException() .isThrownBy(() -> listOps.rightPushAll(keyFactory.instance(), (Collection) null)); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void testLeftPushAllCollection() { assumeThat(redisTemplate.getConnectionFactory() instanceof LettuceConnectionFactory).isTrue(); @@ -281,25 +283,25 @@ void testLeftPushAllCollection() { assertThat(listOps.range(key, 0, -1)).containsSequence(v3, v2, v1); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void leftPushAllShouldThrowExceptionWhenCalledWithEmptyCollection() { assertThatIllegalArgumentException() .isThrownBy(() -> listOps.leftPushAll(keyFactory.instance(), Collections. emptyList())); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void leftPushAllShouldThrowExceptionWhenCollectionContainsNullValue() { assertThatIllegalArgumentException() .isThrownBy(() -> listOps.leftPushAll(keyFactory.instance(), Arrays.asList(valueFactory.instance(), null))); } - @ParameterizedRedisTest // DATAREDIS-288 + @Test // DATAREDIS-288 void leftPushAllShouldThrowExceptionWhenCalledWithNull() { assertThatIllegalArgumentException() .isThrownBy(() -> listOps.leftPushAll(keyFactory.instance(), (Collection) null)); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("LMOVE") void move() { @@ -322,7 +324,7 @@ void move() { assertThat(listOps.range(target, 0, -1)).containsExactly(v4, v1); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("BLMOVE") void moveWithTimeout() { @@ -346,7 +348,7 @@ void moveWithTimeout() { assertThat(listOps.range(target, 0, -1)).containsExactly(v4, v1); } - @ParameterizedRedisTest // GH-2937 + @Test // GH-2937 void getFirst() { K key = keyFactory.instance(); @@ -360,7 +362,7 @@ void getFirst() { assertThat(listOps.getFirst(key)).isEqualTo(v1); } - @ParameterizedRedisTest // GH-2937 + @Test // GH-2937 void getLast() { K key = keyFactory.instance(); @@ -374,7 +376,7 @@ void getLast() { assertThat(listOps.getLast(key)).isEqualTo(v3); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void indexOf() { @@ -389,7 +391,7 @@ void indexOf() { assertThat(listOps.indexOf(key, v1)).isEqualTo(0); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lastIndexOf() { diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveGeoOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveGeoOperationsIntegrationTests.java index 795e1a16af..9458a74ba6 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveGeoOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveGeoOperationsIntegrationTests.java @@ -20,7 +20,6 @@ import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*; import static org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.*; -import org.springframework.data.redis.domain.geo.GeoReference; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -31,6 +30,10 @@ import java.util.Map; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; + import org.springframework.data.geo.Circle; import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; @@ -39,10 +42,9 @@ import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture; +import org.springframework.data.redis.domain.geo.GeoReference; import org.springframework.data.redis.domain.geo.GeoShape; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveGeoOperations}. @@ -50,6 +52,7 @@ * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("testParams") @EnabledOnCommand("GEOADD") public class DefaultReactiveGeoOperationsIntegrationTests { @@ -88,7 +91,7 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoAdd() { K key = keyFactory.instance(); @@ -98,7 +101,7 @@ void geoAdd() { .as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoAddLocation() { K key = keyFactory.instance(); @@ -111,7 +114,8 @@ void geoAddLocation() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test + // DATAREDIS-602, DATAREDIS-614 void geoAddMapOfLocations() { K key = keyFactory.instance(); @@ -126,7 +130,7 @@ void geoAddMapOfLocations() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoAddIterableOfLocations() { K key = keyFactory.instance(); @@ -140,7 +144,7 @@ void geoAddIterableOfLocations() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoAddPublisherOfLocations() { K key = keyFactory.instance(); @@ -158,7 +162,7 @@ void geoAddPublisherOfLocations() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoDistShouldReturnDistanceInMetersByDefault() { K key = keyFactory.instance(); @@ -178,7 +182,7 @@ void geoDistShouldReturnDistanceInMetersByDefault() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoDistShouldReturnDistanceInKilometersCorrectly() { K key = keyFactory.instance(); @@ -198,7 +202,7 @@ void geoDistShouldReturnDistanceInKilometersCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoHash() { K key = keyFactory.instance(); @@ -212,7 +216,7 @@ void geoHash() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoHashShouldReturnMultipleElements() { K key = keyFactory.instance(); @@ -229,7 +233,7 @@ void geoHashShouldReturnMultipleElements() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoPos() { K key = keyFactory.instance(); @@ -247,7 +251,7 @@ void geoPos() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoPosShouldReturnMultipleElements() { K key = keyFactory.instance(); @@ -271,7 +275,7 @@ void geoPosShouldReturnMultipleElements() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadius() { K key = keyFactory.instance(); @@ -286,7 +290,7 @@ void geoRadius() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoRadiusShouldReturnLocationsWithDistance() { K key = keyFactory.instance(); @@ -313,7 +317,7 @@ void geoRadiusShouldReturnLocationsWithDistance() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 + @Test // DATAREDIS-438, DATAREDIS-614 void geoRadiusByMemberShouldReturnMembersCorrectly() { K key = keyFactory.instance(); @@ -328,7 +332,7 @@ void geoRadiusByMemberShouldReturnMembersCorrectly() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoRadiusByMemberWithin100_000MetersShouldReturnLocations() { K key = keyFactory.instance(); @@ -350,7 +354,7 @@ void geoRadiusByMemberWithin100_000MetersShouldReturnLocations() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoRadiusByMemberWithin100KMShouldReturnLocations() { K key = keyFactory.instance(); @@ -372,7 +376,7 @@ void geoRadiusByMemberWithin100KMShouldReturnLocations() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoRadiusByMemberShouldReturnLocationsWithDistance() { K key = keyFactory.instance(); @@ -400,7 +404,7 @@ void geoRadiusByMemberShouldReturnLocationsWithDistance() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void geoRemove() { K key = keyFactory.instance(); @@ -419,7 +423,7 @@ void geoRemove() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-614 + @Test // DATAREDIS-602, DATAREDIS-614 void delete() { K key = keyFactory.instance(); @@ -436,7 +440,7 @@ void delete() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchShouldReturnLocationsWithDistance() { @@ -466,7 +470,7 @@ void geoSearchShouldReturnLocationsWithDistance() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2043 + @Test // GH-2043 @EnabledOnCommand("GEOSEARCH") void geoSearchAndStoreShouldStoreItems() { diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveHashOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveHashOperationsIntegrationTests.java index a387f2ae3c..e40dd63ec7 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveHashOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveHashOperationsIntegrationTests.java @@ -32,7 +32,10 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.RawObjectFactory; @@ -47,8 +50,6 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.condition.EnabledOnCommand; import org.springframework.data.redis.test.extension.LettuceTestClientResources; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveHashOperations}. @@ -56,6 +57,7 @@ * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultReactiveHashOperationsIntegrationTests { @@ -110,7 +112,8 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test + // DATAREDIS-602 void remove() { K key = keyFactory.instance(); @@ -128,7 +131,7 @@ void remove() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void hasKey() { K key = keyFactory.instance(); @@ -151,7 +154,7 @@ void hasKey() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void get() { K key = keyFactory.instance(); @@ -169,14 +172,14 @@ void get() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-824 + @Test // DATAREDIS-824 void getAbsentKey() { hashOperations.get(keyFactory.instance(), hashKeyFactory.instance()).as(StepVerifier::create) // .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void multiGet() { assumeThat(hashKeyFactory instanceof StringObjectFactory && hashValueFactory instanceof StringObjectFactory) @@ -198,7 +201,7 @@ void multiGet() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-824 + @Test // DATAREDIS-824 void multiGetAbsentKeys() { assumeThat(hashKeyFactory instanceof StringObjectFactory && hashValueFactory instanceof StringObjectFactory) @@ -212,7 +215,7 @@ void multiGetAbsentKeys() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void increment() { assumeThat(hashValueFactory instanceof StringObjectFactory).isTrue(); @@ -237,7 +240,7 @@ void increment() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2048 + @Test // GH-2048 @EnabledOnCommand("HRANDFIELD") void randomField() { @@ -272,7 +275,7 @@ void randomField() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-2048 + @Test // GH-2048 @EnabledOnCommand("HRANDFIELD") void randomValue() { @@ -312,7 +315,7 @@ void randomValue() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 @DisabledOnOs(value = MAC, architectures = "aarch64") @SuppressWarnings("unchecked") void incrementDouble() { @@ -339,7 +342,7 @@ void incrementDouble() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void keys() { assumeThat(hashKeyFactory instanceof StringObjectFactory).isTrue(); @@ -359,7 +362,7 @@ void keys() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void size() { K key = keyFactory.instance(); @@ -377,7 +380,7 @@ void size() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void putAll() { K key = keyFactory.instance(); @@ -400,7 +403,7 @@ void putAll() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void put() { K key = keyFactory.instance(); @@ -413,7 +416,7 @@ void put() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void putIfAbsent() { K key = keyFactory.instance(); @@ -432,7 +435,7 @@ void putIfAbsent() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void values() { assumeThat(hashValueFactory instanceof StringObjectFactory).isTrue(); @@ -452,7 +455,7 @@ void values() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void entries() { assumeThat(hashKeyFactory instanceof StringObjectFactory && hashValueFactory instanceof StringObjectFactory) @@ -479,7 +482,7 @@ void entries() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void scan() { assumeThat(hashKeyFactory instanceof StringObjectFactory && hashValueFactory instanceof StringObjectFactory) @@ -507,7 +510,7 @@ void scan() { } @EnabledOnCommand("HEXPIRE") // GH-3054 - @ParameterizedRedisTest + @Test void testExpireAndGetExpireMillis() { K key = keyFactory.instance(); @@ -531,7 +534,7 @@ void testExpireAndGetExpireMillis() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireWithOptions() { @@ -568,7 +571,7 @@ void testExpireWithOptions() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireAndGetExpireSeconds() { @@ -594,7 +597,7 @@ void testExpireAndGetExpireSeconds() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireAtAndGetExpireMillis() { @@ -619,7 +622,7 @@ void testExpireAtAndGetExpireMillis() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testPersistAndGetExpireMillis() { @@ -648,7 +651,7 @@ void testPersistAndGetExpireMillis() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void delete() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperationsIntegrationTests.java index 183704a76e..c2d499dff0 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperationsIntegrationTests.java @@ -22,13 +22,14 @@ import java.util.Collection; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveHyperLogLogOperations}. @@ -36,6 +37,7 @@ * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultReactiveHyperLogLogOperationsIntegrationTests { @@ -67,7 +69,8 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test + // DATAREDIS-602 void add() { K key = keyFactory.instance(); @@ -79,7 +82,7 @@ void add() { hyperLogLogOperations.size(key).as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void union() { K mergedKey = keyFactory.instance(); @@ -101,7 +104,7 @@ void union() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void delete() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveListOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveListOperationsIntegrationTests.java index f42aaa9af4..4d17c30067 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveListOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveListOperationsIntegrationTests.java @@ -24,6 +24,9 @@ import java.util.Collection; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ByteBufferObjectFactory; import org.springframework.data.redis.ObjectFactory; @@ -32,8 +35,6 @@ import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture; import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveListOperations}. @@ -42,6 +43,7 @@ * @author Christoph Strobl * @author John Blum */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultReactiveListOperationsIntegrationTests { @@ -73,7 +75,8 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test + // DATAREDIS-602 void trim() { K key = keyFactory.instance(); @@ -96,7 +99,7 @@ void trim() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void size() { K key = keyFactory.instance(); @@ -118,7 +121,7 @@ void size() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPush() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -144,7 +147,7 @@ void leftPush() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPushAll() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -165,7 +168,7 @@ void leftPushAll() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPushIfPresent() { K key = keyFactory.instance(); @@ -188,7 +191,7 @@ void leftPushIfPresent() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPushWithPivot() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -216,7 +219,7 @@ void leftPushWithPivot() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPush() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -241,7 +244,7 @@ void rightPush() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPushAll() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -259,7 +262,7 @@ void rightPushAll() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPushIfPresent() { K key = keyFactory.instance(); @@ -271,7 +274,7 @@ void rightPushIfPresent() { listOperations.rightPushIfPresent(key, value2).as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPushWithPivot() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -296,7 +299,7 @@ void rightPushWithPivot() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("LMOVE") void move() { @@ -328,7 +331,7 @@ void move() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("BLMOVE") void moveWithTimeout() { @@ -361,7 +364,7 @@ void moveWithTimeout() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void set() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -381,7 +384,7 @@ void set() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void remove() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -403,7 +406,7 @@ void remove() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void index() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -417,7 +420,7 @@ void index() { listOperations.index(key, 1).as(StepVerifier::create).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // GH-2937 + @Test // GH-2937 void getFirst() { K key = keyFactory.instance(); @@ -430,7 +433,7 @@ void getFirst() { listOperations.getFirst(key).as(StepVerifier::create).expectNext(v1).verifyComplete(); } - @ParameterizedRedisTest // GH-2937 + @Test // GH-2937 void getLast() { K key = keyFactory.instance(); @@ -443,7 +446,7 @@ void getLast() { listOperations.getLast(key).as(StepVerifier::create).expectNext(v3).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void indexOf() { @@ -457,7 +460,7 @@ void indexOf() { listOperations.indexOf(key, v1).as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lastIndexOf() { @@ -471,7 +474,7 @@ void lastIndexOf() { listOperations.lastIndexOf(key, v1).as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPop() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -485,7 +488,7 @@ void leftPop() { listOperations.leftPop(key).as(StepVerifier::create).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // GH-2692 + @Test // GH-2692 void leftPopWithCount() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -500,7 +503,7 @@ void leftPopWithCount() { listOperations.leftPop(key, 2).as(StepVerifier::create).expectNext(value3).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPop() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -514,7 +517,7 @@ void rightPop() { listOperations.rightPop(key).as(StepVerifier::create).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // GH-2692 + @Test // GH-2692 void rightPopWithCount() { assumeThat(this.valueFactory).isInstanceOf(ByteBufferObjectFactory.class); @@ -529,7 +532,7 @@ void rightPopWithCount() { listOperations.rightPop(key, 2).as(StepVerifier::create).expectNext(value1).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPopWithTimeout() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -543,7 +546,7 @@ void leftPopWithTimeout() { listOperations.leftPop(key, Duration.ZERO).as(StepVerifier::create).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void leftPopWithMillisecondTimeoutShouldFail() { K key = keyFactory.instance(); @@ -551,7 +554,7 @@ void leftPopWithMillisecondTimeoutShouldFail() { assertThatIllegalArgumentException().isThrownBy(() -> listOperations.leftPop(key, Duration.ofMillis(1001))); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPopWithTimeout() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -565,7 +568,7 @@ void rightPopWithTimeout() { listOperations.rightPop(key, Duration.ZERO).as(StepVerifier::create).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rightPopAndLeftPush() { assumeThat(this.valueFactory).isNotInstanceOf(ByteBufferObjectFactory.class); @@ -582,7 +585,7 @@ void rightPopAndLeftPush() { listOperations.size(target).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 @EnabledIfLongRunningTest void rightPopAndLeftPushWithTimeout() { @@ -604,7 +607,7 @@ void rightPopAndLeftPushWithTimeout() { listOperations.size(target).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void delete() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveSetOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveSetOperationsIntegrationTests.java index 37b497f893..9cd9e1de31 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveSetOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveSetOperationsIntegrationTests.java @@ -24,6 +24,9 @@ import java.util.Collection; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ByteBufferObjectFactory; import org.springframework.data.redis.ObjectFactory; @@ -31,8 +34,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveSetOperations}. @@ -40,6 +41,7 @@ * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultReactiveSetOperationsIntegrationTests { @@ -71,7 +73,8 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test + // DATAREDIS-602 void add() { K key = keyFactory.instance(); @@ -82,7 +85,7 @@ void add() { setOperations.add(key, value1, value2).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void remove() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -98,7 +101,7 @@ void remove() { setOperations.remove(key, value1, value2).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void pop() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -113,7 +116,7 @@ void pop() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-668 + @Test // DATAREDIS-668 void popWithCount() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -128,7 +131,7 @@ void popWithCount() { setOperations.size(key).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void move() { K key = keyFactory.instance(); @@ -142,7 +145,7 @@ void move() { setOperations.size(otherKey).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void isMember() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -155,7 +158,7 @@ void isMember() { setOperations.isMember(key, value1).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // GH-2037 + @Test // GH-2037 @EnabledOnCommand("SMISMEMBER") void isMembers() { @@ -172,7 +175,7 @@ void isMembers() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-873 + @Test // DATAREDIS-602, DATAREDIS-873 void intersect() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -200,7 +203,7 @@ void intersect() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-873 + @Test // DATAREDIS-602, DATAREDIS-873 void intersectAndStore() { K key = keyFactory.instance(); @@ -227,7 +230,7 @@ void intersectAndStore() { setOperations.isMember(destKey, shared).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-873 + @Test // DATAREDIS-602, DATAREDIS-873 void difference() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -255,7 +258,7 @@ void difference() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-873 + @Test // DATAREDIS-602, DATAREDIS-873 void differenceAndStore() { K key = keyFactory.instance(); @@ -278,7 +281,7 @@ void differenceAndStore() { setOperations.isMember(destKey, onlyInKey).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-873 + @Test // DATAREDIS-602, DATAREDIS-873 void union() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -304,7 +307,7 @@ void union() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-873 + @Test // DATAREDIS-602, DATAREDIS-873 void unionAndStore() { K key = keyFactory.instance(); @@ -330,7 +333,7 @@ void unionAndStore() { setOperations.isMember(destKey, onlyInOtherKey).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void members() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -344,7 +347,7 @@ void members() { .consumeNextWith(actual -> assertThat(actual).isIn(value1, value2)).expectNextCount(1).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void scan() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -363,7 +366,7 @@ void scan() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void randomMember() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -379,7 +382,7 @@ void randomMember() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void randomMembers() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -393,7 +396,7 @@ void randomMembers() { setOperations.randomMembers(key, 3).as(StepVerifier::create).expectNextCount(3).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void distinctRandomMembers() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -409,7 +412,7 @@ void distinctRandomMembers() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void delete() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java index f8e5360e49..e1bd326c9f 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveStreamOperationsIntegrationTests.java @@ -26,6 +26,9 @@ import java.util.Map; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.domain.Range; import org.springframework.data.domain.Range.Bound; @@ -53,8 +56,6 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveStreamOperations}. @@ -64,6 +65,7 @@ * @author Marcin Zielinski * @author jinkshower */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") @EnabledOnCommand("XADD") @@ -112,7 +114,8 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test + // DATAREDIS-864 void addShouldAddMessage() { K key = keyFactory.instance(); @@ -135,7 +138,7 @@ void addShouldAddMessage() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void addShouldAddReadSimpleMessage() { assumeTrue(!(serializer instanceof Jackson2JsonRedisSerializer) @@ -158,7 +161,7 @@ void addShouldAddReadSimpleMessage() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void addShouldAddReadSimpleMessageWithRawSerializer() { assumeTrue(!(serializer instanceof Jackson2JsonRedisSerializer) @@ -188,7 +191,7 @@ void addShouldAddReadSimpleMessageWithRawSerializer() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMaxLenShouldLimitMessagesSize() { K key = keyFactory.instance(); @@ -215,7 +218,7 @@ void addMaxLenShouldLimitMessagesSize() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMaxLenShouldLimitSimpleMessagesSize() { assumeTrue(!(serializer instanceof Jackson2JsonRedisSerializer) @@ -242,7 +245,7 @@ void addMaxLenShouldLimitSimpleMessagesSize() { }).expectNextCount(0).verifyComplete(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMaxLenShouldLimitSimpleMessageWithRawSerializerSize() { assumeTrue(!(serializer instanceof Jackson2JsonRedisSerializer) @@ -278,7 +281,7 @@ void addMaxLenShouldLimitSimpleMessageWithRawSerializerSize() { }).expectNextCount(0).verifyComplete(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMinIdShouldEvictLowerIdMessages() { K key = keyFactory.instance(); @@ -301,7 +304,7 @@ void addMinIdShouldEvictLowerIdMessages() { }).expectNextCount(0).verifyComplete(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMakeNoStreamShouldNotCreateStreamWhenNoStreamExists() { K key = keyFactory.instance(); @@ -317,7 +320,7 @@ void addMakeNoStreamShouldNotCreateStreamWhenNoStreamExists() { streamOperations.range(key, Range.unbounded()).as(StepVerifier::create).expectNextCount(0L).verifyComplete(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMakeNoStreamShouldCreateStreamWhenStreamExists() { K key = keyFactory.instance(); @@ -335,7 +338,7 @@ void addMakeNoStreamShouldCreateStreamWhenStreamExists() { streamOperations.range(key, Range.unbounded()).as(StepVerifier::create).expectNextCount(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void rangeShouldReportMessages() { K key = keyFactory.instance(); @@ -356,7 +359,7 @@ void rangeShouldReportMessages() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void reverseRangeShouldReportMessages() { K key = keyFactory.instance(); @@ -372,7 +375,7 @@ void reverseRangeShouldReportMessages() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void reverseRangeShouldConvertSimpleMessages() { assumeTrue(!(serializer instanceof Jackson2JsonRedisSerializer) @@ -390,7 +393,7 @@ void reverseRangeShouldConvertSimpleMessages() { .consumeNextWith(it -> assertThat(it.getId()).isEqualTo(messageId1)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void readShouldReadMessage() { // assumeFalse(valueFactory instanceof PersonObjectFactory); @@ -416,7 +419,7 @@ void readShouldReadMessage() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void readShouldReadMessages() { assumeFalse(valueFactory instanceof PersonObjectFactory); @@ -434,7 +437,7 @@ void readShouldReadMessages() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void sizeShouldReportStreamSize() { K key = keyFactory.instance(); @@ -456,7 +459,7 @@ void sizeShouldReportStreamSize() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void pendingShouldReadMessageSummary() { K key = keyFactory.instance(); @@ -479,7 +482,7 @@ void pendingShouldReadMessageSummary() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void pendingShouldReadMessageDetails() { K key = keyFactory.instance(); @@ -504,7 +507,7 @@ void pendingShouldReadMessageDetails() { }).verifyComplete(); } - @ParameterizedRedisTest // GH-2465 + @Test // GH-2465 void claimShouldReadMessageDetails() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveValueOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveValueOperationsIntegrationTests.java index 7dfeb0266d..e188fdcf54 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveValueOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveValueOperationsIntegrationTests.java @@ -21,12 +21,11 @@ import static org.springframework.data.redis.connection.BitFieldSubCommands.*; import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldIncrBy.Overflow.*; import static org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldType.*; +import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.*; import static org.springframework.data.redis.connection.BitFieldSubCommands.Offset.offset; -import org.junit.jupiter.api.condition.DisabledOnOs; import reactor.test.StepVerifier; -import java.nio.ByteBuffer; import java.time.Duration; import java.util.Arrays; import java.util.Collection; @@ -35,6 +34,10 @@ import java.util.Map; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.connection.RedisConnection; @@ -43,8 +46,6 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link DefaultReactiveValueOperations}. @@ -53,6 +54,7 @@ * @author Christoph Strobl * @author Jiahe Cai */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultReactiveValueOperationsIntegrationTests { @@ -87,7 +89,8 @@ void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test + // DATAREDIS-602 void set() { K key = keyFactory.instance(); @@ -98,7 +101,7 @@ void set() { valueOperations.get(key).as(StepVerifier::create).expectNext(value).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void setWithExpiry() { K key = keyFactory.instance(); @@ -115,7 +118,7 @@ void setWithExpiry() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-779 + @Test // DATAREDIS-602, DATAREDIS-779 void setIfAbsent() { K key = keyFactory.instance(); @@ -126,7 +129,7 @@ void setIfAbsent() { valueOperations.setIfAbsent(key, value).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-782 + @Test // DATAREDIS-782 void setIfAbsentWithExpiry() { K key = keyFactory.instance(); @@ -146,7 +149,7 @@ void setIfAbsentWithExpiry() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602, DATAREDIS-779 + @Test // DATAREDIS-602, DATAREDIS-779 void setIfPresent() { K key = keyFactory.instance(); @@ -162,7 +165,7 @@ void setIfPresent() { valueOperations.get(key).as(StepVerifier::create).expectNext(laterValue).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-782 + @Test // DATAREDIS-782 void setIfPresentWithExpiry() { K key = keyFactory.instance(); @@ -186,7 +189,7 @@ void setIfPresentWithExpiry() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void multiSet() { K key1 = keyFactory.instance(); @@ -204,7 +207,7 @@ void multiSet() { valueOperations.get(key2).as(StepVerifier::create).expectNext(value2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void multiSetIfAbsent() { K key1 = keyFactory.instance(); @@ -225,7 +228,7 @@ void multiSetIfAbsent() { valueOperations.get(key2).as(StepVerifier::create).expectNextCount(0).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void get() { K key = keyFactory.instance(); @@ -238,7 +241,7 @@ void get() { valueOperations.get(key).as(StepVerifier::create).expectNext(value).verifyComplete(); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETEX") void getAndExpire() { @@ -254,7 +257,7 @@ void getAndExpire() { .assertNext(actual -> assertThat(actual).isGreaterThan(Duration.ZERO)).verifyComplete(); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETDEL") void getAndDelete() { @@ -268,7 +271,7 @@ void getAndDelete() { redisTemplate.hasKey(key).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETEX") void getAndPersist() { @@ -282,7 +285,7 @@ void getAndPersist() { redisTemplate.getExpire(key).as(StepVerifier::create).expectNext(Duration.ZERO).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void getAndSet() { K key = keyFactory.instance(); @@ -298,7 +301,7 @@ void getAndSet() { valueOperations.get(key).as(StepVerifier::create).expectNext(nextValue).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void multiGet() { K key1 = keyFactory.instance(); @@ -318,7 +321,7 @@ void multiGet() { .expectNext(Arrays.asList(value2, value1, absentValue)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void append() { assumeTrue(serializer instanceof StringRedisSerializer); @@ -333,7 +336,7 @@ void append() { valueOperations.get(key).as(StepVerifier::create).expectNext((V) (value + "foo")).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void getRange() { assumeTrue(serializer instanceof StringRedisSerializer); @@ -348,7 +351,7 @@ void getRange() { valueOperations.get(key, 1, 4).as(StepVerifier::create).expectNext(substring).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void setRange() { assumeTrue(serializer instanceof StringRedisSerializer); @@ -368,7 +371,7 @@ void setRange() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void size() { assumeTrue(serializer instanceof StringRedisSerializer); @@ -381,7 +384,7 @@ void size() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void setBit() { K key = keyFactory.instance(); @@ -390,7 +393,7 @@ void setBit() { valueOperations.setBit(key, 2, true).as(StepVerifier::create).expectNext(false).expectComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void getBit() { K key = keyFactory.instance(); @@ -400,7 +403,7 @@ void getBit() { valueOperations.getBit(key, 1).as(StepVerifier::create).expectNext(false).expectComplete(); } - @ParameterizedRedisTest // DATAREDIS-562 + @Test // DATAREDIS-562 void bitField() { K key = keyFactory.instance(); @@ -419,7 +422,7 @@ void bitField() { .expectNext(Collections.singletonList(null)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void delete() { K key = keyFactory.instance(); @@ -432,7 +435,7 @@ void delete() { valueOperations.size(key).as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void increment() { K key = keyFactory.instance(); @@ -442,7 +445,7 @@ void increment() { valueOperations.increment(key).as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void incrementByLongDelta() { K key = keyFactory.instance(); @@ -454,7 +457,7 @@ void incrementByLongDelta() { valueOperations.increment(key, 1L).as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 @DisabledOnOs(value = MAC, architectures = "aarch64") void incrementByFloatDelta() { @@ -467,7 +470,7 @@ void incrementByFloatDelta() { valueOperations.increment(key, 0.2).as(StepVerifier::create).expectNext(0.0).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void decrement() { K key = keyFactory.instance(); @@ -477,7 +480,7 @@ void decrement() { valueOperations.decrement(key).as(StepVerifier::create).expectNext(-2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void decrementByLongDelta() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java index d0e1afa11a..ec60bd744e 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultReactiveZSetOperationsIntegrationTests.java @@ -18,6 +18,8 @@ import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; +import reactor.test.StepVerifier; + import java.time.Duration; import java.util.Arrays; import java.util.Collection; @@ -26,6 +28,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; + import org.springframework.data.domain.Range; import org.springframework.data.redis.ByteBufferObjectFactory; import org.springframework.data.redis.ObjectFactory; @@ -38,10 +44,6 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; - -import reactor.test.StepVerifier; /** * Integration tests for {@link DefaultReactiveZSetOperations}. @@ -50,6 +52,7 @@ * @author Christoph Strobl * @author Andrey Shlykov */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultReactiveZSetOperationsIntegrationTests { @@ -90,7 +93,7 @@ public void before() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void add() { K key = keyFactory.instance(); @@ -99,7 +102,8 @@ void add() { zSetOperations.add(key, value, 42.1).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test + // DATAREDIS-602 void addAll() { K key = keyFactory.instance(); @@ -118,7 +122,7 @@ void addAll() { zSetOperations.score(key, value1).as(StepVerifier::create).expectNext(52.1d).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void remove() { K key = keyFactory.instance(); @@ -131,7 +135,7 @@ void remove() { zSetOperations.remove(key, value).as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void incrementScore() { K key = keyFactory.instance(); @@ -142,7 +146,7 @@ void incrementScore() { zSetOperations.incrementScore(key, value, 1.1).as(StepVerifier::create).expectNext(43.2).verifyComplete(); } - @ParameterizedRedisTest // GH-2049 + @Test // GH-2049 @EnabledOnCommand("ZRANDMEMBER") void randomMember() { @@ -162,7 +166,7 @@ void randomMember() { zSetOperations.distinctRandomMembers(key, 2).as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // GH-2049 + @Test // GH-2049 @Disabled("https://github.com/redis/redis/issues/9160") @EnabledOnCommand("ZRANDMEMBER") void randomMemberWithScore() { @@ -183,7 +187,7 @@ void randomMemberWithScore() { zSetOperations.distinctRandomMembersWithScore(key, 2).as(StepVerifier::create).expectNextCount(2).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rank() { K key = keyFactory.instance(); @@ -196,7 +200,7 @@ void rank() { zSetOperations.rank(key, value1).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRank() { K key = keyFactory.instance(); @@ -209,7 +213,7 @@ void reverseRank() { zSetOperations.reverseRank(key, value1).as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void range() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -227,7 +231,7 @@ void range() { } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeWithScores() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -244,7 +248,7 @@ void rangeWithScores() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeByScore() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -261,7 +265,7 @@ void rangeByScore() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeByScoreWithScores() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -278,7 +282,7 @@ void rangeByScoreWithScores() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeByScoreWithLimit() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -296,7 +300,7 @@ void rangeByScoreWithLimit() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeByScoreWithScoresWithLimit() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -314,7 +318,7 @@ void rangeByScoreWithScoresWithLimit() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRange() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -332,7 +336,7 @@ void reverseRange() { } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeWithScores() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -349,7 +353,7 @@ void reverseRangeWithScores() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeByScore() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -366,7 +370,7 @@ void reverseRangeByScore() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeByScoreWithScores() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -383,7 +387,7 @@ void reverseRangeByScoreWithScores() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeByScoreWithLimit() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -401,7 +405,7 @@ void reverseRangeByScoreWithLimit() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeByScoreWithScoresWithLimit() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -419,7 +423,7 @@ void reverseRangeByScoreWithScoresWithLimit() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 void rangeAndStoreByLex() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -439,7 +443,7 @@ void rangeAndStoreByLex() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 @Disabled("https://github.com/spring-projects/spring-data-redis/issues/2441") void rangeAndStoreByScore() { @@ -465,7 +469,7 @@ void rangeAndStoreByScore() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 void reverseRangeAndStoreByLex() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -485,7 +489,7 @@ void reverseRangeAndStoreByLex() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 @Disabled("https://github.com/spring-projects/spring-data-redis/issues/2441") void reverseRangeAndStoreByScore() { @@ -511,7 +515,7 @@ void reverseRangeAndStoreByScore() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void scan() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -534,7 +538,7 @@ void scan() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void count() { K key = keyFactory.instance(); @@ -548,7 +552,7 @@ void count() { zSetOperations.count(key, Range.closed(0d, 10d)).as(StepVerifier::create).expectNext(1L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void lexCount() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -568,7 +572,7 @@ void lexCount() { zSetOperations.lexCount(key, Range.rightOpen("b", "f")).as(StepVerifier::create).expectNext(4L).verifyComplete(); } - @ParameterizedRedisTest // GH-2007 + @Test // GH-2007 @EnabledOnCommand("ZPOPMIN") void popMin() { @@ -591,7 +595,7 @@ void popMin() { .expectNext(new DefaultTypedTuple<>(value4, 4D)).verifyComplete(); } - @ParameterizedRedisTest // GH-2007 + @Test // GH-2007 @EnabledOnCommand("ZPOPMAX") void popMax() { @@ -614,7 +618,7 @@ void popMax() { .expectNext(new DefaultTypedTuple<>(value1, 1D)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void size() { K key = keyFactory.instance(); @@ -627,7 +631,7 @@ void size() { zSetOperations.size(key).as(StepVerifier::create).expectNext(2L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void score() { K key = keyFactory.instance(); @@ -641,7 +645,7 @@ void score() { zSetOperations.score(key, value2).as(StepVerifier::create).expectNext(10d).verifyComplete(); } - @ParameterizedRedisTest // GH-2038 + @Test // GH-2038 @EnabledOnCommand("ZMSCORE") void scores() { @@ -656,7 +660,7 @@ void scores() { .expectNext(Arrays.asList(42.1d, 10d, null)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void removeRange() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -672,7 +676,7 @@ void removeRange() { zSetOperations.range(key, ZERO_TO_FIVE).as(StepVerifier::create).expectNext(value1).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void removeRangeByScore() { assumeThat(valueFactory instanceof ByteBufferObjectFactory).isFalse(); @@ -691,7 +695,7 @@ void removeRangeByScore() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2041 + @Test // GH-2041 void difference() { K key = keyFactory.instance(); @@ -713,7 +717,7 @@ void difference() { .expectNext(new DefaultTypedTuple<>(onlyInKey, 10D)).verifyComplete(); } - @ParameterizedRedisTest // GH-2041 + @Test // GH-2041 void differenceAndStore() { K key = keyFactory.instance(); @@ -737,7 +741,7 @@ void differenceAndStore() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZINTER") void intersect() { @@ -763,7 +767,7 @@ void intersect() { .as(StepVerifier::create).expectNext(new DefaultTypedTuple<>(shared, 33D)).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void intersectAndStore() { K key = keyFactory.instance(); @@ -788,7 +792,7 @@ void intersectAndStore() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-746 + @Test // DATAREDIS-746 void intersectAndStoreWithAggregation() { K key = keyFactory.instance(); @@ -820,7 +824,7 @@ void intersectAndStoreWithAggregation() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZUNION") void union() { @@ -853,7 +857,7 @@ void union() { }).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void unionAndStore() { K key = keyFactory.instance(); @@ -874,7 +878,7 @@ void unionAndStore() { zSetOperations.range(destKey, Range.closed(0L, 100L)).as(StepVerifier::create).expectNextCount(3).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-746 + @Test // DATAREDIS-746 void unionAndStoreWithAggregation() { K key = keyFactory.instance(); @@ -900,7 +904,7 @@ void unionAndStoreWithAggregation() { zSetOperations.score(destKey, shared).as(StepVerifier::create).expectNext(33d).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeByLex() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -918,7 +922,7 @@ void rangeByLex() { } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rangeByLexWithLimit() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -941,7 +945,7 @@ void rangeByLexWithLimit() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeByLex() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -958,7 +962,7 @@ void reverseRangeByLex() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void reverseRangeByLexLimit() { assumeThat(serializer instanceof StringRedisSerializer).isTrue(); @@ -981,7 +985,7 @@ void reverseRangeByLexLimit() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void delete() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsIntegrationTests.java index 67e31a2163..9844ce228e 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultSetOperationsIntegrationTests.java @@ -24,11 +24,12 @@ import java.util.Set; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link DefaultSetOperations} @@ -38,6 +39,7 @@ * @author Thomas Darimont * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") @SuppressWarnings("unchecked") public class DefaultSetOperationsIntegrationTests { @@ -69,7 +71,7 @@ void setUp() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testDistinctRandomMembers() { K setKey = keyFactory.instance(); @@ -84,7 +86,7 @@ void testDistinctRandomMembers() { assertThat(members).contains(v1, v2); } - @ParameterizedRedisTest + @Test void testRandomMembersWithDuplicates() { K setKey = keyFactory.instance(); @@ -97,7 +99,7 @@ void testRandomMembersWithDuplicates() { assertThat(members).hasSize(2).contains(v1); } - @ParameterizedRedisTest + @Test void testRandomMembersNegative() { try { @@ -107,7 +109,7 @@ void testRandomMembersNegative() { } } - @ParameterizedRedisTest + @Test void testDistinctRandomMembersNegative() { try { @@ -118,7 +120,7 @@ void testDistinctRandomMembersNegative() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testMove() { K key1 = keyFactory.instance(); @@ -135,7 +137,7 @@ void testMove() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testPop() { K key = keyFactory.instance(); @@ -147,7 +149,7 @@ void testPop() { assertThat(setOps.members(key)).isEmpty(); } - @ParameterizedRedisTest // DATAREDIS-668 + @Test // DATAREDIS-668 void testPopWithCount() { K key = keyFactory.instance(); @@ -162,7 +164,7 @@ void testPopWithCount() { assertThat(result.get(0)).isInstanceOf(v1.getClass()); } - @ParameterizedRedisTest + @Test void testRandomMember() { K key = keyFactory.instance(); @@ -173,7 +175,7 @@ void testRandomMember() { assertThat(setOps.randomMember(key)).isEqualTo(v1); } - @ParameterizedRedisTest + @Test void testAdd() { K key = keyFactory.instance(); @@ -185,7 +187,7 @@ void testAdd() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testRemove() { K key = keyFactory.instance(); @@ -200,7 +202,7 @@ void testRemove() { assertThat(setOps.members(key)).containsOnly(v3); } - @ParameterizedRedisTest // DATAREDIS-304 + @Test // DATAREDIS-304 @SuppressWarnings("unchecked") void testSSCanReadsValuesFully() throws IOException { @@ -221,7 +223,7 @@ void testSSCanReadsValuesFully() throws IOException { assertThat(count).isEqualTo(setOps.size(key)); } - @ParameterizedRedisTest // DATAREDIS-873 + @Test // DATAREDIS-873 void diffShouldReturnDifference() { K sourceKey1 = keyFactory.instance(); @@ -238,7 +240,7 @@ void diffShouldReturnDifference() { assertThat(setOps.difference(Arrays.asList(sourceKey1, sourceKey2))).contains(v1); } - @ParameterizedRedisTest // DATAREDIS-873 + @Test // DATAREDIS-873 void diffAndStoreShouldReturnDifferenceShouldReturnNumberOfElementsInDestination() { K sourceKey1 = keyFactory.instance(); @@ -256,7 +258,7 @@ void diffAndStoreShouldReturnDifferenceShouldReturnNumberOfElementsInDestination assertThat(setOps.differenceAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey)).isEqualTo(1L); } - @ParameterizedRedisTest // DATAREDIS-873 + @Test // DATAREDIS-873 void unionShouldConcatSets() { K sourceKey1 = keyFactory.instance(); @@ -273,7 +275,7 @@ void unionShouldConcatSets() { assertThat(setOps.union(Arrays.asList(sourceKey1, sourceKey2))).contains(v1, v2, v3, v4); } - @ParameterizedRedisTest // DATAREDIS-873 + @Test // DATAREDIS-873 void unionAndStoreShouldReturnDifferenceShouldReturnNumberOfElementsInDestination() { K sourceKey1 = keyFactory.instance(); @@ -291,7 +293,7 @@ void unionAndStoreShouldReturnDifferenceShouldReturnNumberOfElementsInDestinatio assertThat(setOps.unionAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey)).isEqualTo(4L); } - @ParameterizedRedisTest // DATAREDIS-873 + @Test // DATAREDIS-873 void intersectShouldReturnElements() { K sourceKey1 = keyFactory.instance(); @@ -308,7 +310,7 @@ void intersectShouldReturnElements() { assertThat(setOps.intersect(Arrays.asList(sourceKey1, sourceKey2))).hasSize(2); } - @ParameterizedRedisTest // DATAREDIS-448, DATAREDIS-873 + @Test // DATAREDIS-448, DATAREDIS-873 void intersectAndStoreShouldReturnNumberOfElementsInDestination() { K sourceKey1 = keyFactory.instance(); @@ -327,7 +329,7 @@ void intersectAndStoreShouldReturnNumberOfElementsInDestination() { assertThat(setOps.intersectAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey)).isEqualTo(2L); } - @ParameterizedRedisTest // GH-2037 + @Test // GH-2037 @EnabledOnCommand("SMISMEMBER") void isMember() { diff --git a/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java index 6dc4f8dc3d..9df8d711d3 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultStreamOperationsIntegrationTests.java @@ -25,6 +25,9 @@ import java.util.List; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.domain.Range; import org.springframework.data.domain.Range.Bound; @@ -51,9 +54,7 @@ import org.springframework.data.redis.test.condition.EnabledOnRedisVersion; import org.springframework.data.redis.test.condition.RedisDetector; import org.springframework.data.redis.test.extension.RedisCluster; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration test of {@link DefaultStreamOperations} @@ -63,6 +64,7 @@ * @author Marcin Zielinski * @author jinkshower */ +@ParameterizedClass @MethodSource("testParams") @EnabledOnCommand("XADD") public class DefaultStreamOperationsIntegrationTests { @@ -90,7 +92,7 @@ public static Collection testParams() { List params = new ArrayList<>(); params.addAll(AbstractOperationsTestParams - .testParams(JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class))); + .testParams(JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class))); if (RedisDetector.isClusterAvailable()) { params.addAll(AbstractOperationsTestParams @@ -98,7 +100,7 @@ public static Collection testParams() { } params.addAll(AbstractOperationsTestParams - .testParams(LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class))); + .testParams(LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class))); if (RedisDetector.isClusterAvailable()) { params.addAll(AbstractOperationsTestParams @@ -117,7 +119,7 @@ void setUp() { }); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void addShouldAddMessage() { K key = keyFactory.instance(); @@ -140,7 +142,8 @@ void addShouldAddMessage() { } } - @ParameterizedRedisTest // DATAREDIS-864 + @Test + // DATAREDIS-864 void addShouldAddReadSimpleMessage() { K key = keyFactory.instance(); @@ -160,7 +163,7 @@ void addShouldAddReadSimpleMessage() { assertThat(message.getValue()).isEqualTo(value); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMaxLenShouldLimitMessagesSize() { K key = keyFactory.instance(); @@ -189,7 +192,7 @@ void addMaxLenShouldLimitMessagesSize() { } } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMaxLenShouldLimitSimpleMessagesSize() { K key = keyFactory.instance(); @@ -215,7 +218,7 @@ void addMaxLenShouldLimitSimpleMessagesSize() { assertThat(message.getValue()).isEqualTo(newValue); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMinIdShouldEvictLowerIdMessages() { K key = keyFactory.instance(); @@ -249,7 +252,7 @@ void addMinIdShouldEvictLowerIdMessages() { } } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMinIdShouldEvictLowerIdSimpleMessages() { K key = keyFactory.instance(); @@ -279,7 +282,7 @@ void addMinIdShouldEvictLowerIdSimpleMessages() { assertThat(message2.getValue()).isEqualTo(value); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMakeNoStreamShouldNotCreateStreamWhenNoStreamExists() { K key = keyFactory.instance(); @@ -293,7 +296,7 @@ void addMakeNoStreamShouldNotCreateStreamWhenNoStreamExists() { assertThat(streamOps.range(key, Range.unbounded())).isEmpty(); } - @ParameterizedRedisTest // GH-2915 + @Test // GH-2915 void addMakeNoStreamShouldCreateStreamWhenStreamExists() { K key = keyFactory.instance(); @@ -309,7 +312,7 @@ void addMakeNoStreamShouldCreateStreamWhenStreamExists() { assertThat(streamOps.range(key, Range.unbounded())).hasSize(2); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void simpleMessageReadWriteSymmetry() { K key = keyFactory.instance(); @@ -331,7 +334,7 @@ void simpleMessageReadWriteSymmetry() { assertThat(message.getValue().values()).containsExactly(value); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void rangeShouldReportMessages() { K key = keyFactory.instance(); @@ -352,7 +355,7 @@ void rangeShouldReportMessages() { assertThat(message.getId()).isEqualTo(messageId1); } - @ParameterizedRedisTest // GH-2044 + @Test // GH-2044 @EnabledOnRedisVersion("6.2") void exclusiveRangeShouldReportMessages() { @@ -374,7 +377,7 @@ void exclusiveRangeShouldReportMessages() { assertThat(messages).hasSize(1).extracting(MapRecord::getId).contains(messageId1); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void reverseRangeShouldReportMessages() { K key = keyFactory.instance(); @@ -389,7 +392,7 @@ void reverseRangeShouldReportMessages() { assertThat(messages).hasSize(2).extracting("id").containsSequence(messageId2, messageId1); } - @ParameterizedRedisTest // GH-2044 + @Test // GH-2044 @EnabledOnRedisVersion("6.2") void exclusiveReverseRangeShouldReportMessages() { @@ -412,7 +415,7 @@ void exclusiveReverseRangeShouldReportMessages() { assertThat(messages).hasSize(2).extracting(MapRecord::getId).containsSequence(messageId2, messageId1); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void reverseRangeShouldConvertSimpleMessages() { K key = keyFactory.instance(); @@ -433,7 +436,7 @@ void reverseRangeShouldConvertSimpleMessages() { assertThat(message.getValue()).isEqualTo(value); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void readShouldReadMessage() { K key = keyFactory.instance(); @@ -456,7 +459,7 @@ void readShouldReadMessage() { } } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void readShouldReadSimpleMessage() { K key = keyFactory.instance(); @@ -478,7 +481,7 @@ void readShouldReadSimpleMessage() { assertThat(message.getValue()).isEqualTo(value); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void readShouldReadMessages() { K key = keyFactory.instance(); @@ -494,7 +497,7 @@ void readShouldReadMessages() { assertThat(messages).hasSize(2); } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void readShouldReadMessageWithConsumerGroup() { K key = keyFactory.instance(); @@ -519,7 +522,7 @@ void readShouldReadMessageWithConsumerGroup() { } } - @ParameterizedRedisTest // DATAREDIS-864 + @Test // DATAREDIS-864 void sizeShouldReportStreamSize() { K key = keyFactory.instance(); @@ -533,7 +536,7 @@ void sizeShouldReportStreamSize() { assertThat(streamOps.size(key)).isEqualTo(2); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void pendingShouldReadMessageSummary() { // XPENDING summary not supported by Jedis assumeThat(redisTemplate.getRequiredConnectionFactory()).isInstanceOf(LettuceConnectionFactory.class); @@ -553,7 +556,7 @@ void pendingShouldReadMessageSummary() { assertThat(pending.getGroupName()).isEqualTo("my-group"); } - @ParameterizedRedisTest // DATAREDIS-1084 + @Test // DATAREDIS-1084 void pendingShouldReadMessageDetails() { K key = keyFactory.instance(); @@ -573,7 +576,7 @@ void pendingShouldReadMessageDetails() { assertThat(pending.get(0).getTotalDeliveryCount()).isOne(); } - @ParameterizedRedisTest // GH-2465 + @Test // GH-2465 void claimShouldReadMessageDetails() { K key = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultValueOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultValueOperationsIntegrationTests.java index abc601bb8d..51b5b52643 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultValueOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultValueOperationsIntegrationTests.java @@ -27,12 +27,14 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; + import org.springframework.data.redis.DoubleObjectFactory; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link DefaultValueOperations} @@ -45,6 +47,7 @@ * @author Mark Paluch * @author Hendrik Duerkop */ +@ParameterizedClass @MethodSource("testParams") public class DefaultValueOperationsIntegrationTests { @@ -74,7 +77,7 @@ void setUp() { }); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void testIncrement() { K key = keyFactory.instance(); @@ -88,7 +91,7 @@ void testIncrement() { assertThat(valueOps.get(key)).isEqualTo((Long) value + 1); } - @ParameterizedRedisTest + @Test void testIncrementLong() { K key = keyFactory.instance(); @@ -105,7 +108,7 @@ void testIncrementLong() { assertThat(valueOps.get(key)).isEqualTo((Long) value - 20); } - @ParameterizedRedisTest // DATAREDIS-247 + @Test // DATAREDIS-247 void testIncrementDouble() { assumeThat(valueFactory).isInstanceOf(DoubleObjectFactory.class); @@ -122,7 +125,7 @@ void testIncrementDouble() { assertThat((Double) valueOps.get(key)).isBetween(value + 1.39 - 10, value + 1.41 - 10); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void testDecrement() { K key = keyFactory.instance(); @@ -136,7 +139,7 @@ void testDecrement() { assertThat(valueOps.get(key)).isEqualTo((Long) value - 1); } - @ParameterizedRedisTest // DATAREDIS-784 + @Test // DATAREDIS-784 void testDecrementByLong() { K key = keyFactory.instance(); @@ -150,7 +153,7 @@ void testDecrementByLong() { assertThat(valueOps.get(key)).isEqualTo((Long) value - 5); } - @ParameterizedRedisTest + @Test void testMultiSetIfAbsent() { Map keysAndValues = new HashMap<>(); @@ -166,7 +169,7 @@ void testMultiSetIfAbsent() { assertThat(valueOps.multiGet(keysAndValues.keySet())).containsExactlyElementsOf(keysAndValues.values()); } - @ParameterizedRedisTest + @Test void testMultiSetIfAbsentFailure() { K key1 = keyFactory.instance(); @@ -184,7 +187,7 @@ void testMultiSetIfAbsentFailure() { assertThat(valueOps.multiSetIfAbsent(keysAndValues)).isFalse(); } - @ParameterizedRedisTest + @Test void testMultiSet() { Map keysAndValues = new HashMap<>(); @@ -201,7 +204,7 @@ void testMultiSet() { assertThat(valueOps.multiGet(keysAndValues.keySet())).containsExactlyElementsOf(keysAndValues.values()); } - @ParameterizedRedisTest + @Test void testGetSet() { K key = keyFactory.instance(); @@ -212,7 +215,7 @@ void testGetSet() { assertThat(valueOps.get(key)).isEqualTo(value); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETEX") void testGetAndExpire() { @@ -226,7 +229,7 @@ void testGetAndExpire() { assertThat(redisTemplate.getExpire(key)).isGreaterThan(1); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETEX") void testGetAndPersist() { @@ -239,7 +242,7 @@ void testGetAndPersist() { assertThat(redisTemplate.getExpire(key)).isEqualTo(-1); } - @ParameterizedRedisTest // GH-2050 + @Test // GH-2050 @EnabledOnCommand("GETDEL") void testGetAndDelete() { @@ -252,7 +255,7 @@ void testGetAndDelete() { assertThat(redisTemplate.hasKey(key)).isFalse(); } - @ParameterizedRedisTest + @Test void testGetAndSet() { K key = keyFactory.instance(); @@ -264,7 +267,7 @@ void testGetAndSet() { assertThat(valueOps.getAndSet(key, value2)).isEqualTo(value1); } - @ParameterizedRedisTest + @Test void testSetWithExpiration() { K key = keyFactory.instance(); @@ -277,7 +280,7 @@ void testSetWithExpiration() { assertThat(expire).isLessThan(TimeUnit.SECONDS.toMillis(6)).isGreaterThan(TimeUnit.MILLISECONDS.toMillis(1)); } - @ParameterizedRedisTest // DATAREDIS-815 + @Test // DATAREDIS-815 void testSetWithExpirationEX() { K key = keyFactory.instance(); @@ -290,7 +293,7 @@ void testSetWithExpirationEX() { assertThat(expire).isLessThan(TimeUnit.SECONDS.toMillis(6)).isGreaterThan(TimeUnit.MILLISECONDS.toMillis(1)); } - @ParameterizedRedisTest // DATAREDIS-815 + @Test // DATAREDIS-815 void testSetWithExpirationPX() { K key = keyFactory.instance(); @@ -304,7 +307,7 @@ void testSetWithExpirationPX() { assertThat(expire).isGreaterThan(TimeUnit.MILLISECONDS.toMillis(1)); } - @ParameterizedRedisTest // DATAREDIS-271 + @Test // DATAREDIS-271 @EnabledIfLongRunningTest void testSetWithExpirationWithTimeUnitMilliseconds() { @@ -316,7 +319,7 @@ void testSetWithExpirationWithTimeUnitMilliseconds() { await().atMost(Duration.ofMillis(500L)).until(() -> !redisTemplate.hasKey(key)); } - @ParameterizedRedisTest + @Test void testSetGetWithExpiration() { K key = keyFactory.instance(); @@ -329,7 +332,7 @@ void testSetGetWithExpiration() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest + @Test void testSetGetWithExpirationDuration() { K key = keyFactory.instance(); @@ -342,7 +345,7 @@ void testSetGetWithExpirationDuration() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest + @Test void testAppend() { K key = keyFactory.instance(); @@ -356,7 +359,7 @@ void testAppend() { assertThat(valueOps.get(key)).isEqualTo(value + "aaa"); } - @ParameterizedRedisTest + @Test void testGetRange() { K key = keyFactory.instance(); @@ -369,7 +372,7 @@ void testGetRange() { assertThat(valueOps.get(key, 0, 1)).hasSize(2); } - @ParameterizedRedisTest + @Test void testSetRange() { K key = keyFactory.instance(); @@ -384,7 +387,7 @@ void testSetRange() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest + @Test void testSetIfAbsent() { K key = keyFactory.instance(); @@ -395,7 +398,7 @@ void testSetIfAbsent() { assertThat(valueOps.setIfAbsent(key, value2)).isFalse(); } - @ParameterizedRedisTest // DATAREDIS-782 + @Test // DATAREDIS-782 void testSetIfAbsentWithExpiration() { K key = keyFactory.instance(); @@ -410,7 +413,7 @@ void testSetIfAbsentWithExpiration() { assertThat(expire).isLessThan(TimeUnit.SECONDS.toMillis(6)).isGreaterThan(TimeUnit.MILLISECONDS.toMillis(1)); } - @ParameterizedRedisTest // DATAREDIS-815 + @Test // DATAREDIS-815 void testSetIfAbsentWithExpirationEX() { K key = keyFactory.instance(); @@ -425,7 +428,7 @@ void testSetIfAbsentWithExpirationEX() { assertThat(expire).isLessThan(TimeUnit.SECONDS.toMillis(6)).isGreaterThan(TimeUnit.MILLISECONDS.toMillis(1)); } - @ParameterizedRedisTest // DATAREDIS-815 + @Test // DATAREDIS-815 void testSetIfAbsentWithExpirationPX() { K key = keyFactory.instance(); @@ -440,7 +443,7 @@ void testSetIfAbsentWithExpirationPX() { assertThat(expire).isLessThan(TimeUnit.SECONDS.toMillis(6)).isGreaterThan(TimeUnit.MILLISECONDS.toMillis(1)); } - @ParameterizedRedisTest // DATAREDIS-786 + @Test // DATAREDIS-786 void setIfPresentReturnsTrueWhenKeyExists() { K key = keyFactory.instance(); @@ -453,12 +456,12 @@ void setIfPresentReturnsTrueWhenKeyExists() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest // DATAREDIS-786 + @Test // DATAREDIS-786 void setIfPresentReturnsFalseWhenKeyDoesNotExist() { assertThat(valueOps.setIfPresent(keyFactory.instance(), valueFactory.instance())).isFalse(); } - @ParameterizedRedisTest // DATAREDIS-786 + @Test // DATAREDIS-786 void setIfPresentShouldSetExpirationCorrectly() { K key = keyFactory.instance(); @@ -475,7 +478,7 @@ void setIfPresentShouldSetExpirationCorrectly() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest // DATAREDIS-815 + @Test // DATAREDIS-815 void testSetIfPresentWithExpirationEX() { K key = keyFactory.instance(); @@ -492,7 +495,7 @@ void testSetIfPresentWithExpirationEX() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest // DATAREDIS-815 + @Test // DATAREDIS-815 void testSetIfPresentWithExpirationPX() { K key = keyFactory.instance(); @@ -509,7 +512,7 @@ void testSetIfPresentWithExpirationPX() { assertThat(valueOps.get(key)).isEqualTo(value2); } - @ParameterizedRedisTest + @Test void testSize() { K key = keyFactory.instance(); @@ -521,7 +524,7 @@ void testSize() { } @SuppressWarnings({ "unchecked", "rawtypes" }) - @ParameterizedRedisTest + @Test void testRawKeys() { K key1 = keyFactory.instance(); @@ -533,7 +536,7 @@ void testRawKeys() { } @SuppressWarnings({ "unchecked", "rawtypes" }) - @ParameterizedRedisTest + @Test void testRawKeysCollection() { K key1 = keyFactory.instance(); @@ -545,7 +548,7 @@ void testRawKeysCollection() { } @SuppressWarnings("rawtypes") - @ParameterizedRedisTest + @Test void testDeserializeKey() { K key = keyFactory.instance(); @@ -555,7 +558,7 @@ void testDeserializeKey() { assertThat(((DefaultValueOperations) valueOps).deserializeKey((byte[]) key)).isNotNull(); } - @ParameterizedRedisTest // DATAREDIS-197 + @Test // DATAREDIS-197 void testSetAndGetBit() { assumeThat(redisTemplate).isInstanceOf(StringRedisTemplate.class); diff --git a/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java index dcfd41feb4..4855b3db69 100644 --- a/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/DefaultZSetOperationsIntegrationTests.java @@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; +import static org.assertj.core.data.Offset.*; import static org.assertj.core.data.Offset.offset; import java.io.IOException; @@ -29,6 +30,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.domain.Range; import org.springframework.data.redis.DoubleAsStringObjectFactory; @@ -42,8 +46,6 @@ import org.springframework.data.redis.connection.zset.Weights; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link DefaultZSetOperations} @@ -57,6 +59,7 @@ * @param Value type */ @SuppressWarnings("unchecked") +@ParameterizedClass @MethodSource("testParams") public class DefaultZSetOperationsIntegrationTests { @@ -86,7 +89,7 @@ void setUp() { }); } - @ParameterizedRedisTest + @Test void testCount() { K key1 = keyFactory.instance(); @@ -99,7 +102,7 @@ void testCount() { assertThat(zSetOps.count(key1, 2.7, 5.7)).isEqualTo(Long.valueOf(1)); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void testLexCountUnbounded() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -117,7 +120,8 @@ void testLexCountUnbounded() { assertThat(zSetOps.lexCount(key, Range.unbounded())).isEqualTo(3); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test + // DATAREDIS-729 void testLexCountBounded() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -135,7 +139,7 @@ void testLexCountBounded() { assertThat(zSetOps.lexCount(key, Range.rightUnbounded(Range.Bound.exclusive(value1.toString())))).isEqualTo(2); } - @ParameterizedRedisTest // GH-2007 + @Test // GH-2007 @EnabledOnCommand("ZPOPMIN") void testPopMin() { @@ -159,7 +163,7 @@ void testPopMin() { assertThat(zSetOps.popMin(key, 1, TimeUnit.SECONDS)).isEqualTo(new DefaultTypedTuple<>(value4, 4d)); } - @ParameterizedRedisTest // GH-2007 + @Test // GH-2007 @EnabledOnCommand("ZPOPMAX") void testPopMax() { @@ -183,7 +187,7 @@ void testPopMax() { assertThat(zSetOps.popMax(key, 1, TimeUnit.SECONDS)).isEqualTo(new DefaultTypedTuple<>(value1, 1d)); } - @ParameterizedRedisTest + @Test void testIncrementScore() { K key1 = keyFactory.instance(); @@ -198,7 +202,7 @@ void testIncrementScore() { assertThat(tuple).isEqualTo(new DefaultTypedTuple<>(value1, 5.7)); } - @ParameterizedRedisTest // GH-2049 + @Test // GH-2049 @EnabledOnCommand("ZRANDMEMBER") void testRandomMember() { @@ -216,7 +220,7 @@ void testRandomMember() { assertThat(zSetOps.distinctRandomMembers(key, 2)).hasSize(2).containsAnyOf(value1, value2, value3); } - @ParameterizedRedisTest // GH-2049 + @Test // GH-2049 @Disabled("https://github.com/redis/redis/issues/9160") @EnabledOnCommand("ZRANDMEMBER") void testRandomMemberWithScore() { @@ -241,7 +245,7 @@ void testRandomMemberWithScore() { new DefaultTypedTuple<>(value3, 5.8d)); } - @ParameterizedRedisTest + @Test void testRangeByScoreOffsetCount() { K key = keyFactory.instance(); @@ -256,7 +260,7 @@ void testRangeByScoreOffsetCount() { assertThat(zSetOps.rangeByScore(key, 1.5, 4.7, 0, 1)).containsOnly(value1); } - @ParameterizedRedisTest + @Test void testRangeByScoreWithScoresOffsetCount() { K key = keyFactory.instance(); @@ -272,7 +276,7 @@ void testRangeByScoreWithScoresOffsetCount() { assertThat(tuples).hasSize(1).contains(new DefaultTypedTuple<>(value1, 1.9)); } - @ParameterizedRedisTest + @Test void testReverseRangeByScoreOffsetCount() { K key = keyFactory.instance(); @@ -287,7 +291,7 @@ void testReverseRangeByScoreOffsetCount() { assertThat(zSetOps.reverseRangeByScore(key, 1.5, 4.7, 0, 1)).containsOnly(value2); } - @ParameterizedRedisTest + @Test void testReverseRangeByScoreWithScoresOffsetCount() { K key = keyFactory.instance(); @@ -304,7 +308,7 @@ void testReverseRangeByScoreWithScoresOffsetCount() { assertThat(tuples).hasSize(1).contains(new DefaultTypedTuple<>(value2, 3.7)); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexUnbounded() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -323,7 +327,7 @@ void testRangeByLexUnbounded() { assertThat(tuples).hasSize(3).contains(value1); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexBounded() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -342,7 +346,7 @@ void testRangeByLexBounded() { assertThat(tuples).hasSize(1).contains(value2); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexUnboundedWithLimit() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -361,7 +365,7 @@ void testRangeByLexUnboundedWithLimit() { assertThat(tuples).hasSize(2).containsSequence(value2, value3); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void testReverseRangeByLexUnboundedWithLimit() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -380,7 +384,7 @@ void testReverseRangeByLexUnboundedWithLimit() { assertThat(tuples).hasSize(2).containsSequence(value2, value1); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexBoundedWithLimit() { assumeThat(valueFactory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -400,7 +404,7 @@ void testRangeByLexBoundedWithLimit() { assertThat(tuples).hasSize(1).startsWith(value2); } - @ParameterizedRedisTest + @Test void testAddMultiple() { K key = keyFactory.instance(); @@ -417,7 +421,7 @@ void testAddMultiple() { assertThat(zSetOps.range(key, 0, -1)).containsExactly(value3, value1, value2); } - @ParameterizedRedisTest + @Test void testRemove() { K key = keyFactory.instance(); @@ -435,7 +439,7 @@ void testRemove() { assertThat(zSetOps.range(key, 0, -1)).containsOnly(value2); } - @ParameterizedRedisTest + @Test void testScore() { K key = keyFactory.instance(); @@ -450,7 +454,7 @@ void testScore() { assertThat(zSetOps.score(key, value1, value2, valueFactory.instance())).containsExactly(1.9d, 3.7d, null); } - @ParameterizedRedisTest + @Test void zCardRetrievesDataCorrectly() { K key = keyFactory.instance(); @@ -467,7 +471,7 @@ void zCardRetrievesDataCorrectly() { assertThat(zSetOps.zCard(key)).isEqualTo(3L); } - @ParameterizedRedisTest + @Test void sizeRetrievesDataCorrectly() { K key = keyFactory.instance(); @@ -484,7 +488,7 @@ void sizeRetrievesDataCorrectly() { assertThat(zSetOps.size(key)).isEqualTo(3L); } - @ParameterizedRedisTest // DATAREDIS-306 + @Test // DATAREDIS-306 void testZScanShouldReadEntireValueRange() throws IOException { K key = keyFactory.instance(); @@ -514,7 +518,7 @@ void testZScanShouldReadEntireValueRange() throws IOException { assertThat(count).isEqualTo(3); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZDIFF") void testZsetDiff() { @@ -532,7 +536,7 @@ void testZsetDiff() { assertThat(zSetOps.differenceWithScores(key1, key2)).containsOnly(new DefaultTypedTuple<>(value1, 1d)); } - @ParameterizedRedisTest // DATAREDIS-746, GH-2042 + @Test // DATAREDIS-746, GH-2042 @EnabledOnCommand("ZDIFFSTORE") void testZsetDiffStore() { @@ -552,7 +556,7 @@ void testZsetDiffStore() { assertThat(zSetOps.rangeWithScores(key3, 0, -1)).containsOnly(new DefaultTypedTuple<>(value1, 1d)); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZINTER") void testZsetIntersect() { @@ -569,7 +573,7 @@ void testZsetIntersect() { assertThat(zSetOps.intersect(key1, Collections.singletonList(key2))).containsExactly(value2); } - @ParameterizedRedisTest // DATAREDIS-746, GH-2042 + @Test // DATAREDIS-746, GH-2042 @EnabledOnCommand("ZINTER") void testZsetIntersectWithAggregate() { @@ -590,7 +594,7 @@ void testZsetIntersectWithAggregate() { assertThat(zSetOps.score(key1, value2)).isCloseTo(2.0, offset(0.1)); } - @ParameterizedRedisTest // DATAREDIS-746 + @Test // DATAREDIS-746 void testZsetIntersectWithAggregateWeights() { K key1 = keyFactory.instance(); @@ -606,7 +610,7 @@ void testZsetIntersectWithAggregateWeights() { assertThat(zSetOps.score(key1, value1)).isCloseTo(6.0, offset(0.1)); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZUNION") void testZsetUnion() { @@ -623,7 +627,7 @@ void testZsetUnion() { assertThat(zSetOps.union(key1, Collections.singletonList(key2))).containsOnly(value1, value2); } - @ParameterizedRedisTest // DATAREDIS-746, GH-2042 + @Test // DATAREDIS-746, GH-2042 @EnabledOnCommand("ZUNION") void testZsetUnionWithAggregate() { @@ -645,7 +649,7 @@ void testZsetUnionWithAggregate() { assertThat(zSetOps.score(key1, value2)).isCloseTo(2.0, offset(0.1)); } - @ParameterizedRedisTest // DATAREDIS-746 + @Test // DATAREDIS-746 void testZsetUnionWithAggregateWeights() { K key1 = keyFactory.instance(); diff --git a/src/test/java/org/springframework/data/redis/core/MultithreadedRedisTemplateIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/MultithreadedRedisTemplateIntegrationTests.java index c0ad3a2893..c56902b5f9 100644 --- a/src/test/java/org/springframework/data/redis/core/MultithreadedRedisTemplateIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/MultithreadedRedisTemplateIntegrationTests.java @@ -23,20 +23,23 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; + import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Artem Bilian * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") public class MultithreadedRedisTemplateIntegrationTests { @@ -48,13 +51,14 @@ public MultithreadedRedisTemplateIntegrationTests(RedisConnectionFactory factory public static Collection testParams() { - JedisConnectionFactory jedis = JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); - LettuceConnectionFactory lettuce = LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + JedisConnectionFactory jedis = JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); + LettuceConnectionFactory lettuce = LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); return Arrays.asList(jedis, lettuce); } - @ParameterizedRedisTest // DATAREDIS-300 + @Test + // DATAREDIS-300 void assertResouresAreReleasedProperlyWhenSharingRedisTemplate() throws InterruptedException { final RedisTemplate template = new RedisTemplate<>(); diff --git a/src/test/java/org/springframework/data/redis/core/ReactiveOperationsTestParams.java b/src/test/java/org/springframework/data/redis/core/ReactiveOperationsTestParams.java index 77895e3bb2..2d7294126e 100644 --- a/src/test/java/org/springframework/data/redis/core/ReactiveOperationsTestParams.java +++ b/src/test/java/org/springframework/data/redis/core/ReactiveOperationsTestParams.java @@ -42,7 +42,7 @@ import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; import org.springframework.data.redis.test.condition.RedisDetector; import org.springframework.data.redis.test.extension.RedisCluster; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.lang.Nullable; /** @@ -63,7 +63,7 @@ abstract public class ReactiveOperationsTestParams { ObjectFactory personFactory = new PersonObjectFactory(); LettuceConnectionFactory lettuceConnectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); ReactiveRedisTemplate objectTemplate = new ReactiveRedisTemplate<>(lettuceConnectionFactory, RedisSerializationContext.java(ReactiveOperationsTestParams.class.getClassLoader())); diff --git a/src/test/java/org/springframework/data/redis/core/ReactiveRedisTemplateIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/ReactiveRedisTemplateIntegrationTests.java index f887c1ba22..357b3ae5a8 100644 --- a/src/test/java/org/springframework/data/redis/core/ReactiveRedisTemplateIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/ReactiveRedisTemplateIntegrationTests.java @@ -33,6 +33,9 @@ import java.util.function.Function; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.ObjectFactory; @@ -58,8 +61,6 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link ReactiveRedisTemplate}. @@ -68,6 +69,7 @@ * @author Christoph Strobl * @author Dahye Anne Lee */ +@ParameterizedClass @MethodSource("testParams") public class ReactiveRedisTemplateIntegrationTests { @@ -97,7 +99,7 @@ void before() { connection.close(); } - @ParameterizedRedisTest // GH-2040 + @Test // GH-2040 @EnabledOnCommand("COPY") void copy() { @@ -121,7 +123,7 @@ void copy() { redisTemplate.opsForValue().get(targetKey).as(StepVerifier::create).expectNext(nextValue).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void exists() { K key = keyFactory.instance(); @@ -134,7 +136,7 @@ void exists() { redisTemplate.hasKey(key).as(StepVerifier::create).expectNext(true).verifyComplete(); } - @ParameterizedRedisTest // GH-2883 + @Test // GH-2883 void countExistingKeysIfValidKeyExists() { K key = keyFactory.instance(); @@ -151,14 +153,14 @@ void countExistingKeysIfValidKeyExists() { .verifyComplete(); } - @ParameterizedRedisTest // GH-2883 + @Test // GH-2883 void countExistingKeysIfNotValidKeyExists() { K key = keyFactory.instance(); redisTemplate.countExistingKeys(List.of(key)).as(StepVerifier::create).expectNext(0L).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-743 + @Test // DATAREDIS-743 void scan() { assumeThat(valueFactory.instance() instanceof Person).isFalse(); @@ -175,7 +177,7 @@ void scan() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void type() { K key = keyFactory.instance(); @@ -188,7 +190,7 @@ void type() { redisTemplate.type(key).as(StepVerifier::create).expectNext(DataType.STRING).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void rename() { K oldName = keyFactory.instance(); @@ -203,7 +205,7 @@ void rename() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void renameNx() { K oldName = keyFactory.instance(); @@ -228,7 +230,7 @@ void renameNx() { .verify(); } - @ParameterizedRedisTest // DATAREDIS-693 + @Test // DATAREDIS-693 void unlink() { K single = keyFactory.instance(); @@ -241,7 +243,7 @@ void unlink() { redisTemplate.hasKey(single).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-693 + @Test // DATAREDIS-693 void unlinkMany() { K key1 = keyFactory.instance(); @@ -258,7 +260,7 @@ void unlinkMany() { redisTemplate.hasKey(key2).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-913 + @Test // DATAREDIS-913 void unlinkManyPublisher() { K key1 = keyFactory.instance(); @@ -277,7 +279,7 @@ void unlinkManyPublisher() { redisTemplate.hasKey(key2).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-913 + @Test // DATAREDIS-913 void deleteManyPublisher() { K key1 = keyFactory.instance(); @@ -296,7 +298,7 @@ void deleteManyPublisher() { redisTemplate.hasKey(key2).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 @SuppressWarnings("unchecked") void executeScript() { @@ -314,7 +316,7 @@ void executeScript() { execute.as(StepVerifier::create).expectNext(value).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-683 + @Test // DATAREDIS-683 void executeScriptWithElementReaderAndWriter() { K key = keyFactory.instance(); @@ -339,7 +341,7 @@ void executeScriptWithElementReaderAndWriter() { execute.as(StepVerifier::create).expectNext(person).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void expire() { K key = keyFactory.instance(); @@ -353,7 +355,7 @@ void expire() { .consumeNextWith(actual -> assertThat(actual).isGreaterThan(Duration.ofSeconds(8))).verifyComplete(); } - @ParameterizedRedisTest // GH-3114 + @Test // GH-3114 @EnabledOnCommand("SPUBLISH") // Redis 7.0 void expireWithCondition() { @@ -371,7 +373,7 @@ void expireWithCondition() { .consumeNextWith(actual -> assertThat(actual).isGreaterThan(Duration.ofSeconds(5))).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void preciseExpire() { K key = keyFactory.instance(); @@ -385,7 +387,7 @@ void preciseExpire() { .consumeNextWith(actual -> assertThat(actual).isGreaterThan(Duration.ofSeconds(8))).verifyComplete(); } - @ParameterizedRedisTest // GH-3114 + @Test // GH-3114 @EnabledOnCommand("SPUBLISH") // Redis 7.0 void preciseExpireWithCondition() { @@ -403,7 +405,7 @@ void preciseExpireWithCondition() { .consumeNextWith(actual -> assertThat(actual).isGreaterThan(Duration.ofSeconds(5))).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void expireAt() { K key = keyFactory.instance(); @@ -420,7 +422,7 @@ void expireAt() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void preciseExpireAt() { K key = keyFactory.instance(); @@ -437,7 +439,7 @@ void preciseExpireAt() { .verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void getTtlForAbsentKeyShouldCompleteWithoutValue() { K key = keyFactory.instance(); @@ -445,7 +447,7 @@ void getTtlForAbsentKeyShouldCompleteWithoutValue() { redisTemplate.getExpire(key).as(StepVerifier::create).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void getTtlForKeyWithoutExpiryShouldCompleteWithZeroDuration() { K key = keyFactory.instance(); @@ -456,7 +458,7 @@ void getTtlForKeyWithoutExpiryShouldCompleteWithZeroDuration() { redisTemplate.getExpire(key).as(StepVerifier::create).expectNext(Duration.ZERO).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void move() { try (ReactiveRedisClusterConnection connection = redisTemplate.getConnectionFactory() @@ -473,7 +475,7 @@ void move() { redisTemplate.hasKey(key).as(StepVerifier::create).expectNext(false).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldApplyCustomSerializationContextToValues() { Person key = new PersonObjectFactory().instance(); @@ -494,7 +496,7 @@ void shouldApplyCustomSerializationContextToValues() { valueOperations.get(key).as(StepVerifier::create).expectNext(value).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-602 + @Test // DATAREDIS-602 void shouldApplyCustomSerializationContextToHash() { RedisSerializationContext serializationContext = redisTemplate.getSerializationContext(); @@ -517,7 +519,7 @@ void shouldApplyCustomSerializationContextToHash() { hashOperations.get(key, hashField).as(StepVerifier::create).expectNext(hashValue).verifyComplete(); } - @ParameterizedRedisTest // DATAREDIS-612 + @Test // DATAREDIS-612 @EnabledIfLongRunningTest void listenToChannelShouldReceiveChannelMessagesCorrectly() throws InterruptedException { @@ -539,7 +541,7 @@ void listenToChannelShouldReceiveChannelMessagesCorrectly() throws InterruptedEx .verify(Duration.ofSeconds(3)); } - @ParameterizedRedisTest // GH-1622 + @Test // GH-1622 @EnabledIfLongRunningTest void listenToLaterChannelShouldReceiveChannelMessagesCorrectly() { @@ -562,7 +564,7 @@ void listenToLaterChannelShouldReceiveChannelMessagesCorrectly() { .verify(Duration.ofSeconds(3)); } - @ParameterizedRedisTest // DATAREDIS-612 + @Test // DATAREDIS-612 void listenToPatternShouldReceiveChannelMessagesCorrectly() { String channel = "my-channel"; @@ -586,7 +588,7 @@ void listenToPatternShouldReceiveChannelMessagesCorrectly() { .verify(Duration.ofSeconds(3)); } - @ParameterizedRedisTest // GH-1622 + @Test // GH-1622 void listenToPatternLaterShouldReceiveChannelMessagesCorrectly() { String channel = "my-channel"; diff --git a/src/test/java/org/springframework/data/redis/core/RedisClusterTemplateIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/RedisClusterTemplateIntegrationTests.java index c2b5f55b01..31e6e497dd 100644 --- a/src/test/java/org/springframework/data/redis/core/RedisClusterTemplateIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/RedisClusterTemplateIntegrationTests.java @@ -22,6 +22,8 @@ import java.util.Collection; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; import org.junit.runners.Parameterized.Parameters; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -42,12 +44,12 @@ import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; import org.springframework.data.redis.test.condition.EnabledOnRedisClusterAvailable; import org.springframework.data.redis.test.extension.RedisCluster; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass @EnabledOnRedisClusterAvailable public class RedisClusterTemplateIntegrationTests extends RedisTemplateIntegrationTests { @@ -56,93 +58,93 @@ public RedisClusterTemplateIntegrationTests(RedisTemplate redisTemplate, O super(redisTemplate, keyFactory, valueFactory); } - @ParameterizedRedisTest + @Test @Disabled("Pipeline not supported in cluster mode") public void testExecutePipelinedNonNullRedisCallback() { assertThatExceptionOfType(InvalidDataAccessApiUsageException.class) .isThrownBy(super::testExecutePipelinedNonNullRedisCallback); } - @ParameterizedRedisTest + @Test @Disabled("Pipeline not supported in cluster mode") public void testExecutePipelinedTx() { super.testExecutePipelinedTx(); } - @ParameterizedRedisTest + @Test @Disabled("Watch only supported on same connection...") public void testWatch() { super.testWatch(); } - @ParameterizedRedisTest + @Test @Disabled("Watch only supported on same connection...") public void testUnwatch() { super.testUnwatch(); } - @ParameterizedRedisTest + @Test @Disabled("EXEC only supported on same connection...") public void testExec() { super.testExec(); } - @ParameterizedRedisTest + @Test @Disabled("Pipeline not supported in cluster mode") public void testExecutePipelinedNonNullSessionCallback() { assertThatExceptionOfType(InvalidDataAccessApiUsageException.class) .isThrownBy(super::testExecutePipelinedNonNullSessionCallback); } - @ParameterizedRedisTest + @Test @Disabled("PubSub not supported in cluster mode") public void testConvertAndSend() { super.testConvertAndSend(); } - @ParameterizedRedisTest + @Test @Disabled("Watch only supported on same connection...") public void testExecConversionDisabled() { super.testExecConversionDisabled(); } - @ParameterizedRedisTest + @Test @Disabled("Discard only supported on same connection...") public void testDiscard() { super.testDiscard(); } - @ParameterizedRedisTest + @Test @Disabled("Pipleline not supported in cluster mode") public void testExecutePipelined() { super.testExecutePipelined(); } - @ParameterizedRedisTest + @Test @Disabled("Watch only supported on same connection...") public void testWatchMultipleKeys() { super.testWatchMultipleKeys(); } - @ParameterizedRedisTest + @Test @Disabled("This one fails when using GET options on numbers") public void testSortBulkMapper() { super.testSortBulkMapper(); } - @ParameterizedRedisTest + @Test @Disabled("This one fails when using GET options on numbers") public void testGetExpireMillisUsingTransactions() { super.testGetExpireMillisUsingTransactions(); } - @ParameterizedRedisTest + @Test @Disabled("This one fails when using GET options on numbers") public void testGetExpireMillisUsingPipelining() { super.testGetExpireMillisUsingPipelining(); } - @ParameterizedRedisTest + @Test void testScan() { // Only Lettuce supports cluster-wide scanning diff --git a/src/test/java/org/springframework/data/redis/core/RedisKeyValueTemplateTests.java b/src/test/java/org/springframework/data/redis/core/RedisKeyValueTemplateTests.java index fb464d61a3..dc1b85f283 100644 --- a/src/test/java/org/springframework/data/redis/core/RedisKeyValueTemplateTests.java +++ b/src/test/java/org/springframework/data/redis/core/RedisKeyValueTemplateTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.redis.core; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; @@ -28,6 +28,9 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.annotation.Id; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -37,9 +40,7 @@ import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; import org.springframework.data.redis.core.index.Indexed; import org.springframework.data.redis.core.mapping.RedisMappingContext; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.lang.Nullable; /** @@ -49,6 +50,7 @@ * @author Mark Paluch * @author John Blum */ +@ParameterizedClass @MethodSource("params") public class RedisKeyValueTemplateTests { @@ -64,8 +66,8 @@ public RedisKeyValueTemplateTests(RedisConnectionFactory connectionFactory) { public static List params() { - JedisConnectionFactory jedis = JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); - LettuceConnectionFactory lettuce = LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + JedisConnectionFactory jedis = JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); + LettuceConnectionFactory lettuce = LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); return Arrays.asList(jedis, lettuce); } @@ -95,7 +97,7 @@ void tearDown() throws Exception { adapter.destroy(); } - @ParameterizedRedisTest // DATAREDIS-425 + @Test // DATAREDIS-425 void savesObjectCorrectly() { final Person rand = new Person(); @@ -110,7 +112,8 @@ void savesObjectCorrectly() { }); } - @ParameterizedRedisTest // DATAREDIS-425 + @Test + // DATAREDIS-425 void findProcessesCallbackReturningSingleIdCorrectly() { Person rand = new Person(); @@ -128,7 +131,7 @@ void findProcessesCallbackReturningSingleIdCorrectly() { assertThat(result).contains(mat); } - @ParameterizedRedisTest // DATAREDIS-425 + @Test // DATAREDIS-425 void findProcessesCallbackReturningMultipleIdsCorrectly() { final Person rand = new Person(); @@ -147,7 +150,7 @@ void findProcessesCallbackReturningMultipleIdsCorrectly() { assertThat(result).contains(rand, mat); } - @ParameterizedRedisTest // DATAREDIS-425 + @Test // DATAREDIS-425 void findProcessesCallbackReturningNullCorrectly() { Person rand = new Person(); @@ -164,7 +167,7 @@ void findProcessesCallbackReturningNullCorrectly() { assertThat(result.size()).isEqualTo(0); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdate() { final Person rand = new Person(); @@ -239,7 +242,7 @@ void partialUpdate() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateSimpleType() { final VariousTypes source = new VariousTypes(); @@ -262,7 +265,7 @@ void partialUpdateSimpleType() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateComplexType() { Item callandor = new Item(); @@ -302,7 +305,7 @@ void partialUpdateComplexType() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateObjectType() { Item callandor = new Item(); @@ -344,7 +347,7 @@ void partialUpdateObjectType() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateSimpleTypedMap() { final VariousTypes source = new VariousTypes(); @@ -375,7 +378,7 @@ void partialUpdateSimpleTypedMap() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateComplexTypedMap() { final VariousTypes source = new VariousTypes(); @@ -434,7 +437,7 @@ void partialUpdateComplexTypedMap() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateObjectTypedMap() { final VariousTypes source = new VariousTypes(); @@ -510,7 +513,7 @@ void partialUpdateObjectTypedMap() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateSimpleTypedList() { final VariousTypes source = new VariousTypes(); @@ -544,7 +547,7 @@ void partialUpdateSimpleTypedList() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateComplexTypedList() { final VariousTypes source = new VariousTypes(); @@ -596,7 +599,7 @@ void partialUpdateComplexTypedList() { }); } - @ParameterizedRedisTest // DATAREDIS-471 + @Test // DATAREDIS-471 void partialUpdateObjectTypedList() { final VariousTypes source = new VariousTypes(); @@ -661,7 +664,7 @@ void partialUpdateObjectTypedList() { }); } - @ParameterizedRedisTest // DATAREDIS-530 + @Test // DATAREDIS-530 void partialUpdateShouldLeaveIndexesNotInvolvedInUpdateUntouched() { final Person rand = new Person(); @@ -689,7 +692,7 @@ void partialUpdateShouldLeaveIndexesNotInvolvedInUpdateUntouched() { }); } - @ParameterizedRedisTest // DATAREDIS-530 + @Test // DATAREDIS-530 void updateShouldAlterIndexesCorrectlyWhenValuesGetRemovedFromHash() { final Person rand = new Person(); @@ -718,7 +721,7 @@ void updateShouldAlterIndexesCorrectlyWhenValuesGetRemovedFromHash() { }); } - @ParameterizedRedisTest // DATAREDIS-523 + @Test // DATAREDIS-523 void shouldReadBackExplicitTimeToLive() throws InterruptedException { WithTtl source = new WithTtl(); @@ -732,7 +735,7 @@ void shouldReadBackExplicitTimeToLive() throws InterruptedException { assertThat(target.get().ttl).isGreaterThan(0L); } - @ParameterizedRedisTest // DATAREDIS-523 + @Test // DATAREDIS-523 void shouldReadBackExplicitTimeToLiveToPrimitiveField() throws InterruptedException { WithPrimitiveTtl source = new WithPrimitiveTtl(); @@ -746,7 +749,7 @@ void shouldReadBackExplicitTimeToLiveToPrimitiveField() throws InterruptedExcept assertThat(target.get().ttl).isGreaterThan(0); } - @ParameterizedRedisTest // DATAREDIS-523 + @Test // DATAREDIS-523 void shouldReadBackExplicitTimeToLiveWhenFetchingList() throws InterruptedException { WithTtl source = new WithTtl(); @@ -762,7 +765,7 @@ void shouldReadBackExplicitTimeToLiveWhenFetchingList() throws InterruptedExcept assertThat(target.ttl).isGreaterThan(0); } - @ParameterizedRedisTest // DATAREDIS-523 + @Test // DATAREDIS-523 void shouldReadBackExplicitTimeToLiveAndSetItToMinusOnelIfPersisted() throws InterruptedException { WithTtl source = new WithTtl(); @@ -779,7 +782,7 @@ void shouldReadBackExplicitTimeToLiveAndSetItToMinusOnelIfPersisted() throws Int assertThat(target.get().ttl).isEqualTo(-1L); } - @ParameterizedRedisTest // DATAREDIS-849 + @Test // DATAREDIS-849 void shouldWriteImmutableType() { ImmutableObject source = new ImmutableObject().withValue("foo").withTtl(1234L); @@ -790,7 +793,7 @@ void shouldWriteImmutableType() { assertThat(inserted.id).isNotNull(); } - @ParameterizedRedisTest // DATAREDIS-849 + @Test // DATAREDIS-849 void shouldReadImmutableType() { ImmutableObject source = new ImmutableObject().withValue("foo").withTtl(1234L); diff --git a/src/test/java/org/springframework/data/redis/core/RedisTemplateIntegrationTests.java b/src/test/java/org/springframework/data/redis/core/RedisTemplateIntegrationTests.java index 56f99db3ba..44753946d2 100644 --- a/src/test/java/org/springframework/data/redis/core/RedisTemplateIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/core/RedisTemplateIntegrationTests.java @@ -26,6 +26,9 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -51,8 +54,6 @@ import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; import org.springframework.data.redis.test.condition.EnabledOnCommand; import org.springframework.data.redis.test.extension.LettuceTestClientResources; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.data.redis.test.util.CollectionAwareComparator; /** @@ -68,6 +69,7 @@ * @author Chen Li * @author Vedran Pavic */ +@ParameterizedClass @MethodSource("testParams") public class RedisTemplateIntegrationTests { @@ -95,7 +97,7 @@ void setUp() { }); } - @ParameterizedRedisTest + @Test void testDumpAndRestoreNoTtl() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -107,7 +109,7 @@ void testDumpAndRestoreNoTtl() { assertThat(redisTemplate.boundValueOps(key1).get()).isEqualTo(value1); } - @ParameterizedRedisTest + @Test void testRestoreTtl() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -121,7 +123,7 @@ void testRestoreTtl() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testKeys() throws Exception { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -131,7 +133,7 @@ void testKeys() throws Exception { assertThat(redisTemplate.keys(keyPattern)).isNotNull(); } - @ParameterizedRedisTest // GH-2260 + @Test // GH-2260 void testScan() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -148,14 +150,14 @@ void testScan() { } @SuppressWarnings("rawtypes") - @ParameterizedRedisTest + @Test void testTemplateNotInitialized() throws Exception { RedisTemplate tpl = new RedisTemplate(); tpl.setConnectionFactory(redisTemplate.getConnectionFactory()); assertThatIllegalArgumentException().isThrownBy(() -> tpl.exec()); } - @ParameterizedRedisTest + @Test void testStringTemplateExecutesWithStringConn() { assumeThat(redisTemplate instanceof StringRedisTemplate).isTrue(); String value = redisTemplate.execute((RedisCallback) connection -> { @@ -166,7 +168,7 @@ void testStringTemplateExecutesWithStringConn() { assertThat("it").isEqualTo(value); } - @ParameterizedRedisTest + @Test public void testExec() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -200,7 +202,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti list, 1L, set, true, tupleSet); } - @ParameterizedRedisTest + @Test public void testDiscard() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -218,7 +220,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti assertThat(redisTemplate.boundValueOps(key1).get()).isEqualTo(value1); } - @ParameterizedRedisTest + @Test void testExecCustomSerializer() { assumeThat(redisTemplate instanceof StringRedisTemplate).isTrue(); List results = redisTemplate.execute(new SessionCallback>() { @@ -251,7 +253,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti assertThat(results).containsExactly(true, 5L, 1L, 1L, list, 1L, longSet, true, tupleSet, zSet, true, map); } - @ParameterizedRedisTest + @Test public void testExecConversionDisabled() { LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort()); @@ -277,7 +279,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti } @SuppressWarnings("rawtypes") - @ParameterizedRedisTest + @Test public void testExecutePipelined() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -299,7 +301,7 @@ public void testExecutePipelined() { } @SuppressWarnings("rawtypes") - @ParameterizedRedisTest + @Test void testExecutePipelinedCustomSerializer() { assumeThat(redisTemplate instanceof StringRedisTemplate).isTrue(); @@ -317,7 +319,7 @@ void testExecutePipelinedCustomSerializer() { assertThat(results).containsExactly(true, 5L, 1L, 2L, Arrays.asList(10L, 11L)); } - @ParameterizedRedisTest // DATAREDIS-500 + @Test // DATAREDIS-500 void testExecutePipelinedWidthDifferentHashKeySerializerAndHashValueSerializer() { assumeThat(redisTemplate instanceof StringRedisTemplate).isTrue(); @@ -338,14 +340,14 @@ void testExecutePipelinedWidthDifferentHashKeySerializerAndHashValueSerializer() assertThat(person).isEqualTo(((Map) results.get(0)).get(1L)); } - @ParameterizedRedisTest + @Test public void testExecutePipelinedNonNullRedisCallback() { assertThatExceptionOfType(InvalidDataAccessApiUsageException.class) .isThrownBy(() -> redisTemplate.executePipelined((RedisCallback) connection -> "Hey There")); } @SuppressWarnings({ "rawtypes", "unchecked" }) - @ParameterizedRedisTest + @Test public void testExecutePipelinedTx() { assumeThat(redisTemplate.getConnectionFactory()).isInstanceOf(LettuceConnectionFactory.class); @@ -378,7 +380,7 @@ public Object execute(RedisOperations operations) throws DataAccessException { } @SuppressWarnings({ "rawtypes", "unchecked" }) - @ParameterizedRedisTest + @Test void testExecutePipelinedTxCustomSerializer() { assumeThat(redisTemplate.getConnectionFactory()).isInstanceOf(LettuceConnectionFactory.class); assumeThat(redisTemplate instanceof StringRedisTemplate).isTrue(); @@ -398,7 +400,7 @@ public Object execute(RedisOperations operations) throws DataAccessException { assertThat(pipelinedResults).isEqualTo(Arrays.asList(Arrays.asList(1L, 5L, 0L), true, 2L)); } - @ParameterizedRedisTest + @Test public void testExecutePipelinedNonNullSessionCallback() { assertThatExceptionOfType(InvalidDataAccessApiUsageException.class) .isThrownBy(() -> redisTemplate.executePipelined(new SessionCallback() { @@ -409,7 +411,7 @@ public String execute(RedisOperations operations) throws DataAccessException { })); } - @ParameterizedRedisTest // DATAREDIS-688 + @Test // DATAREDIS-688 void testDelete() { K key1 = keyFactory.instance(); @@ -422,7 +424,7 @@ void testDelete() { assertThat(redisTemplate.hasKey(key1)).isFalse(); } - @ParameterizedRedisTest + @Test void testCopy() { assumeThat(redisTemplate.execute((RedisCallback) it -> it)) @@ -444,7 +446,7 @@ void testCopy() { assertThat(redisTemplate.opsForValue().get(key2)).isEqualTo(value2); } - @ParameterizedRedisTest // DATAREDIS-688 + @Test // DATAREDIS-688 void testDeleteMultiple() { K key1 = keyFactory.instance(); @@ -460,7 +462,7 @@ void testDeleteMultiple() { assertThat(redisTemplate.hasKey(key2)).isFalse(); } - @ParameterizedRedisTest + @Test void testSort() { K key1 = keyFactory.instance(); @@ -474,7 +476,7 @@ void testSort() { assertThat(results).isEqualTo(Collections.singletonList(value1)); } - @ParameterizedRedisTest + @Test void testSortStore() { K key1 = keyFactory.instance(); K key2 = keyFactory.instance(); @@ -485,7 +487,7 @@ void testSortStore() { assertThat(redisTemplate.boundListOps(key2).range(0, -1)).isEqualTo(Collections.singletonList(value1)); } - @ParameterizedRedisTest + @Test public void testSortBulkMapper() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -495,7 +497,7 @@ public void testSortBulkMapper() { assertThat(results).isEqualTo(Collections.singletonList("FOO")); } - @ParameterizedRedisTest + @Test void testExpireAndGetExpireMillis() { K key1 = keyFactory.instance(); @@ -506,7 +508,7 @@ void testExpireAndGetExpireMillis() { assertThat(redisTemplate.getExpire(key1, TimeUnit.MILLISECONDS)).isGreaterThan(0L); } - @ParameterizedRedisTest // GH-3114 + @Test // GH-3114 @EnabledOnCommand("SPUBLISH") // Redis 7.0 void testBoundExpireAndGetExpireSeconds() { @@ -524,7 +526,7 @@ void testBoundExpireAndGetExpireSeconds() { }); } - @ParameterizedRedisTest // GH-3114 + @Test // GH-3114 @EnabledOnCommand("SPUBLISH") // Redis 7.0 void testBoundExpireWithConditionsAndGetExpireSeconds() { @@ -546,7 +548,7 @@ void testBoundExpireWithConditionsAndGetExpireSeconds() { }); } - @ParameterizedRedisTest + @Test void testGetExpireNoTimeUnit() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -557,7 +559,7 @@ void testGetExpireNoTimeUnit() { assertThat(expire > 0L && expire <= 2L).isTrue(); } - @ParameterizedRedisTest + @Test void testGetExpireSeconds() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -566,14 +568,14 @@ void testGetExpireSeconds() { assertThat(redisTemplate.getExpire(key1, TimeUnit.SECONDS)).isEqualTo(Long.valueOf(1)); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 void testGetExpireSecondsForKeyDoesNotExist() { Long expire = redisTemplate.getExpire(keyFactory.instance(), TimeUnit.SECONDS); assertThat(expire).isLessThan(0L); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 void testGetExpireSecondsForKeyExistButHasNoAssociatedExpire() { K key = keyFactory.instance(); @@ -582,7 +584,7 @@ void testGetExpireSecondsForKeyExistButHasNoAssociatedExpire() { assertThat(expire).isLessThan(0L); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 void testGetExpireMillisForKeyDoesNotExist() { Long expire = redisTemplate.getExpire(keyFactory.instance(), TimeUnit.MILLISECONDS); @@ -590,7 +592,7 @@ void testGetExpireMillisForKeyDoesNotExist() { assertThat(expire).isLessThan(0L); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 void testGetExpireMillisForKeyExistButHasNoAssociatedExpire() { K key = keyFactory.instance(); @@ -601,7 +603,7 @@ void testGetExpireMillisForKeyExistButHasNoAssociatedExpire() { assertThat(expire).isLessThan(0L); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 void testGetExpireMillis() { K key = keyFactory.instance(); @@ -614,7 +616,7 @@ void testGetExpireMillis() { assertThat(ttl).isLessThan(25L); } - @ParameterizedRedisTest // GH-3017 + @Test // GH-3017 void testSetGetExpireMillis() { K key = keyFactory.instance(); @@ -631,7 +633,7 @@ void testSetGetExpireMillis() { assertThat(ttl).isLessThan(25L); } - @ParameterizedRedisTest // DATAREDIS-611 + @Test // DATAREDIS-611 void testGetExpireDuration() { K key = keyFactory.instance(); @@ -644,7 +646,7 @@ void testGetExpireDuration() { assertThat(ttl).isLessThan(25L); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 @SuppressWarnings({ "unchecked", "rawtypes" }) public void testGetExpireMillisUsingTransactions() { @@ -668,7 +670,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti assertThat(((Long) result.get(2))).isLessThan(25L); } - @ParameterizedRedisTest // DATAREDIS-526 + @Test // DATAREDIS-526 @SuppressWarnings({ "unchecked", "rawtypes" }) public void testGetExpireMillisUsingPipelining() { @@ -691,7 +693,7 @@ public Object execute(RedisOperations operations) throws DataAccessException { assertThat(((Long) result.get(2))).isLessThan(25L); } - @ParameterizedRedisTest + @Test void testExpireAt() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -700,7 +702,7 @@ void testExpireAt() { await().until(() -> !redisTemplate.hasKey(key1)); } - @ParameterizedRedisTest // DATAREDIS-611 + @Test // DATAREDIS-611 void testExpireAtInstant() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -709,7 +711,7 @@ void testExpireAtInstant() { await().until(() -> !redisTemplate.hasKey(key1)); } - @ParameterizedRedisTest + @Test @EnabledIfLongRunningTest void testExpireAtMillisNotSupported() { @@ -727,7 +729,7 @@ void testExpireAtMillisNotSupported() { await().until(() -> !template2.hasKey((String) key1)); } - @ParameterizedRedisTest + @Test void testRandomKey() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -744,7 +746,7 @@ void testRandomKey() { } } - @ParameterizedRedisTest + @Test void testRename() { K key1 = keyFactory.instance(); K key2 = keyFactory.instance(); @@ -754,7 +756,7 @@ void testRename() { assertThat(redisTemplate.opsForValue().get(key2)).isEqualTo(value1); } - @ParameterizedRedisTest + @Test void testRenameIfAbsent() { K key1 = keyFactory.instance(); K key2 = keyFactory.instance(); @@ -764,7 +766,7 @@ void testRenameIfAbsent() { assertThat(redisTemplate.hasKey(key2)).isTrue(); } - @ParameterizedRedisTest + @Test void testType() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -772,7 +774,7 @@ void testType() { assertThat(redisTemplate.type(key1)).isEqualTo(DataType.STRING); } - @ParameterizedRedisTest // DATAREDIS-506 + @Test // DATAREDIS-506 public void testWatch() { K key1 = keyFactory.instance(); V value1 = valueFactory.instance(); @@ -804,7 +806,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti assertThat(redisTemplate.opsForValue().get(key1)).isEqualTo(value2); } - @ParameterizedRedisTest + @Test public void testUnwatch() { K key1 = keyFactory.instance(); @@ -836,7 +838,7 @@ public List execute(RedisOperations operations) throws DataAccessExcepti assertThat(redisTemplate.opsForValue().get(key1)).isEqualTo(value3); } - @ParameterizedRedisTest // DATAREDIS-506 + @Test // DATAREDIS-506 public void testWatchMultipleKeys() { K key1 = keyFactory.instance(); @@ -873,14 +875,14 @@ public List execute(RedisOperations operations) throws DataAccessExcepti assertThat(redisTemplate.opsForValue().get(key1)).isEqualTo(value2); } - @ParameterizedRedisTest + @Test void testConvertAndSend() { V value1 = valueFactory.instance(); // Make sure basic message sent without Exception on serialization assertThat(redisTemplate.convertAndSend("Channel", value1)).isEqualTo(0L); } - @ParameterizedRedisTest + @Test void testExecuteScriptCustomSerializers() { K key1 = keyFactory.instance(); DefaultRedisScript script = new DefaultRedisScript<>(); @@ -890,12 +892,12 @@ void testExecuteScriptCustomSerializers() { Collections.singletonList(key1))).isEqualTo("Hey"); } - @ParameterizedRedisTest + @Test void clientListShouldReturnCorrectly() { assertThat(redisTemplate.getClientList().size()).isNotEqualTo(0); } - @ParameterizedRedisTest // DATAREDIS-529 + @Test // DATAREDIS-529 void countExistingKeysReturnsNumberOfKeysCorrectly() { Map source = new LinkedHashMap<>(3, 1); diff --git a/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java b/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java index 3676c27c24..c3e099b25e 100644 --- a/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java +++ b/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java @@ -44,7 +44,7 @@ import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.RedisSerializationContext.RedisSerializationContextBuilder; import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.scripting.support.StaticScriptSource; /** @@ -60,7 +60,7 @@ public class DefaultReactiveScriptExecutorTests { @BeforeAll static void setUp() { - connectionFactory = LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + connectionFactory = LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); stringTemplate = new StringRedisTemplate(connectionFactory); stringScriptExecutor = new DefaultReactiveScriptExecutor<>(connectionFactory, RedisSerializationContext.string()); diff --git a/src/test/java/org/springframework/data/redis/core/script/jedis/JedisDefaultScriptExecutorTests.java b/src/test/java/org/springframework/data/redis/core/script/jedis/JedisDefaultScriptExecutorTests.java index 6488a36e02..66145bea68 100644 --- a/src/test/java/org/springframework/data/redis/core/script/jedis/JedisDefaultScriptExecutorTests.java +++ b/src/test/java/org/springframework/data/redis/core/script/jedis/JedisDefaultScriptExecutorTests.java @@ -23,7 +23,7 @@ import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; import org.springframework.data.redis.core.script.AbstractDefaultScriptExecutorTests; import org.springframework.data.redis.core.script.DefaultScriptExecutor; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration test of {@link DefaultScriptExecutor} with {@link Jedis}. @@ -34,7 +34,7 @@ public class JedisDefaultScriptExecutorTests extends AbstractDefaultScriptExecut @Override protected RedisConnectionFactory getConnectionFactory() { - return JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + return JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); } @Disabled("transactional execution is currently not supported with Jedis") diff --git a/src/test/java/org/springframework/data/redis/core/script/lettuce/LettuceDefaultScriptExecutorTests.java b/src/test/java/org/springframework/data/redis/core/script/lettuce/LettuceDefaultScriptExecutorTests.java index 8674f49458..e5d147058d 100644 --- a/src/test/java/org/springframework/data/redis/core/script/lettuce/LettuceDefaultScriptExecutorTests.java +++ b/src/test/java/org/springframework/data/redis/core/script/lettuce/LettuceDefaultScriptExecutorTests.java @@ -19,7 +19,7 @@ import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; import org.springframework.data.redis.core.script.AbstractDefaultScriptExecutorTests; import org.springframework.data.redis.core.script.DefaultScriptExecutor; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration test of {@link DefaultScriptExecutor} with Lettuce. @@ -31,6 +31,6 @@ public class LettuceDefaultScriptExecutorTests extends AbstractDefaultScriptExec @Override protected RedisConnectionFactory getConnectionFactory() { - return LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + return LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); } } diff --git a/src/test/java/org/springframework/data/redis/listener/KeyExpirationEventMessageListenerIntegrationTests.java b/src/test/java/org/springframework/data/redis/listener/KeyExpirationEventMessageListenerIntegrationTests.java index ddf8fdd66b..1f20f0a544 100644 --- a/src/test/java/org/springframework/data/redis/listener/KeyExpirationEventMessageListenerIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/listener/KeyExpirationEventMessageListenerIntegrationTests.java @@ -27,14 +27,12 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import org.springframework.beans.factory.DisposableBean; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Christoph Strobl @@ -53,7 +51,7 @@ void setUp() { publisherMock = mock(ApplicationEventPublisher.class); - this.connectionFactory = JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + this.connectionFactory = JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); container = new RedisMessageListenerContainer(); container.setConnectionFactory(connectionFactory); diff --git a/src/test/java/org/springframework/data/redis/listener/PubSubResubscribeTests.java b/src/test/java/org/springframework/data/redis/listener/PubSubResubscribeTests.java index 63e441d77e..72154e58f1 100644 --- a/src/test/java/org/springframework/data/redis/listener/PubSubResubscribeTests.java +++ b/src/test/java/org/springframework/data/redis/listener/PubSubResubscribeTests.java @@ -31,6 +31,9 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.SyncTaskExecutor; @@ -45,9 +48,7 @@ import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; import org.springframework.data.redis.test.condition.RedisDetector; import org.springframework.data.redis.test.extension.RedisCluster; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Costin Leau @@ -56,6 +57,7 @@ * @author Mark Paluch * @author Vedran Pavic */ +@ParameterizedClass @MethodSource("testParams") @EnabledIfLongRunningTest public class PubSubResubscribeTests { @@ -82,13 +84,13 @@ public static Collection testParams() { // Jedis JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); factories.add(jedisConnFactory); // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); factories.add(lettuceConnFactory); @@ -126,7 +128,7 @@ void tearDown() { bag.clear(); } - @ParameterizedRedisTest + @Test @EnabledIfLongRunningTest void testContainerPatternResubscribe() { @@ -164,7 +166,7 @@ void testContainerPatternResubscribe() { await().atMost(Duration.ofSeconds(2)).until(() -> bag2.contains(payload1) && bag2.contains(payload2)); } - @ParameterizedRedisTest + @Test void testContainerChannelResubscribe() { String payload1 = "do"; @@ -194,7 +196,7 @@ void testContainerChannelResubscribe() { * Validates the behavior of {@link RedisMessageListenerContainer} when it needs to spin up a thread executing its * PatternSubscriptionTask */ - @ParameterizedRedisTest + @Test void testInitializeContainerWithMultipleTopicsIncludingPattern() { assumeFalse(isClusterAware(template.getConnectionFactory())); diff --git a/src/test/java/org/springframework/data/redis/listener/PubSubTestParams.java b/src/test/java/org/springframework/data/redis/listener/PubSubTestParams.java index b034764d48..0adb65310c 100644 --- a/src/test/java/org/springframework/data/redis/listener/PubSubTestParams.java +++ b/src/test/java/org/springframework/data/redis/listener/PubSubTestParams.java @@ -30,7 +30,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.test.condition.RedisDetector; import org.springframework.data.redis.test.extension.RedisCluster; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Costin Leau @@ -45,7 +45,7 @@ public static Collection testParams() { ObjectFactory personFactory = new PersonObjectFactory(); JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getNewConnectionFactory(RedisStanalone.class); + .getNewConnectionFactory(RedisStandalone.class); jedisConnFactory.afterPropertiesSet(); @@ -60,7 +60,7 @@ public static Collection testParams() { // add Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate stringTemplateLtc = new StringRedisTemplate(lettuceConnFactory); RedisTemplate personTemplateLtc = new RedisTemplate<>(); diff --git a/src/test/java/org/springframework/data/redis/listener/PubSubTests.java b/src/test/java/org/springframework/data/redis/listener/PubSubTests.java index 1e0fb72dbb..d973f8ea91 100644 --- a/src/test/java/org/springframework/data/redis/listener/PubSubTests.java +++ b/src/test/java/org/springframework/data/redis/listener/PubSubTests.java @@ -29,6 +29,9 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -37,8 +40,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; import org.springframework.data.redis.test.condition.EnabledIfLongRunningTest; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Base test class for PubSub integration tests @@ -48,6 +49,7 @@ * @author Mark Paluch * @author Vedran Pavic */ +@ParameterizedClass @MethodSource("testParams") public class PubSubTests { @@ -107,7 +109,7 @@ T getT() { return factory.instance(); } - @ParameterizedRedisTest + @Test void testContainerSubscribe() { T payload1 = getT(); T payload2 = getT(); @@ -118,7 +120,7 @@ void testContainerSubscribe() { await().atMost(Duration.ofSeconds(2)).until(() -> bag.contains(payload1) && bag.contains(payload2)); } - @ParameterizedRedisTest + @Test void testMessageBatch() throws Exception { int COUNT = 10; @@ -131,7 +133,7 @@ void testMessageBatch() throws Exception { } } - @ParameterizedRedisTest + @Test @EnabledIfLongRunningTest void testContainerUnsubscribe() throws Exception { T payload1 = getT(); @@ -144,7 +146,7 @@ void testContainerUnsubscribe() throws Exception { assertThat(bag.poll(200, TimeUnit.MILLISECONDS)).isNull(); } - @ParameterizedRedisTest + @Test void testStartNoListeners() { container.removeMessageListener(adapter, new ChannelTopic(CHANNEL)); container.stop(); @@ -152,7 +154,7 @@ void testStartNoListeners() { container.start(); } - @ParameterizedRedisTest // DATAREDIS-251, GH-964 + @Test // DATAREDIS-251, GH-964 void testStartListenersToNoSpecificChannelTest() { assumeThat(isClusterAware(template.getConnectionFactory())).isFalse(); diff --git a/src/test/java/org/springframework/data/redis/listener/ReactiveOperationsTestParams.java b/src/test/java/org/springframework/data/redis/listener/ReactiveOperationsTestParams.java index e31b479145..f0672e9849 100644 --- a/src/test/java/org/springframework/data/redis/listener/ReactiveOperationsTestParams.java +++ b/src/test/java/org/springframework/data/redis/listener/ReactiveOperationsTestParams.java @@ -27,7 +27,7 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; import org.springframework.data.redis.test.condition.RedisDetector; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Parameters for testing implementations of {@link ReactiveRedisMessageListenerContainer} @@ -39,9 +39,9 @@ class ReactiveOperationsTestParams { public static Collection testParams() { LettuceConnectionFactory lettuceConnectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class, false); + .getConnectionFactory(RedisStandalone.class, false); LettuceConnectionFactory poolingConnectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class, true); + .getConnectionFactory(RedisStandalone.class, true); List list = Arrays.asList(new Object[][] { // { lettuceConnectionFactory, "Standalone" }, // @@ -54,7 +54,7 @@ public static Collection testParams() { clusterConfiguration.addClusterNode(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT)); LettuceConnectionFactory lettuceClusterConnectionFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); list = new ArrayList<>(list); list.add(new Object[] { lettuceClusterConnectionFactory, "Cluster" }); diff --git a/src/test/java/org/springframework/data/redis/listener/ReactiveRedisMessageListenerContainerIntegrationTests.java b/src/test/java/org/springframework/data/redis/listener/ReactiveRedisMessageListenerContainerIntegrationTests.java index 4b59bc872d..2b1bc7b3b5 100644 --- a/src/test/java/org/springframework/data/redis/listener/ReactiveRedisMessageListenerContainerIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/listener/ReactiveRedisMessageListenerContainerIntegrationTests.java @@ -37,6 +37,9 @@ import org.awaitility.Awaitility; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.MessageListener; @@ -51,8 +54,6 @@ import org.springframework.data.redis.serializer.RedisSerializationContext; import org.springframework.data.redis.serializer.RedisSerializationContext.SerializationPair; import org.springframework.data.redis.serializer.RedisSerializer; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.lang.Nullable; /** @@ -60,6 +61,7 @@ * * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") public class ReactiveRedisMessageListenerContainerIntegrationTests { @@ -102,7 +104,8 @@ void tearDown() { } } - @ParameterizedRedisTest // DATAREDIS-612, GH-1622 + @Test + // DATAREDIS-612, GH-1622 void shouldReceiveChannelMessages() { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(connectionFactory); @@ -121,7 +124,7 @@ void shouldReceiveChannelMessages() { container.destroy(); } - @ParameterizedRedisTest // GH-1622 + @Test // GH-1622 void receiveChannelShouldNotifySubscriptionListener() throws Exception { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(connectionFactory); @@ -169,7 +172,7 @@ public void onChannelUnsubscribed(byte[] channel, long count) { container.destroy(); } - @ParameterizedRedisTest // DATAREDIS-612, GH-1622 + @Test // DATAREDIS-612, GH-1622 void shouldReceivePatternMessages() { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(connectionFactory); @@ -188,7 +191,7 @@ void shouldReceivePatternMessages() { container.destroy(); } - @ParameterizedRedisTest // GH-1622 + @Test // GH-1622 void receivePatternShouldNotifySubscriptionListener() throws Exception { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(connectionFactory); @@ -238,7 +241,7 @@ public void onPatternUnsubscribed(byte[] pattern, long count) { container.destroy(); } - @ParameterizedRedisTest // DATAREDIS-612, GH-1622 + @Test // DATAREDIS-612, GH-1622 void shouldPublishAndReceiveMessage() throws Exception { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(connectionFactory); @@ -267,7 +270,7 @@ void shouldPublishAndReceiveMessage() throws Exception { container.destroy(); } - @ParameterizedRedisTest // DATAREDIS-612 + @Test // DATAREDIS-612 void listenToChannelShouldReceiveChannelMessagesCorrectly() throws InterruptedException { ReactiveRedisTemplate template = new ReactiveRedisTemplate<>(connectionFactory, @@ -286,7 +289,7 @@ void listenToChannelShouldReceiveChannelMessagesCorrectly() throws InterruptedEx .verify(); } - @ParameterizedRedisTest // DATAREDIS-612 + @Test // DATAREDIS-612 void listenToPatternShouldReceiveMessagesCorrectly() { ReactiveRedisTemplate template = new ReactiveRedisTemplate<>(connectionFactory, @@ -306,7 +309,7 @@ void listenToPatternShouldReceiveMessagesCorrectly() { .verify(); } - @ParameterizedRedisTest // GH-2386 + @Test // GH-2386 void multipleListenShouldTrackSubscriptions() throws Exception { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(connectionFactory); diff --git a/src/test/java/org/springframework/data/redis/listener/RedisMessageListenerContainerIntegrationTests.java b/src/test/java/org/springframework/data/redis/listener/RedisMessageListenerContainerIntegrationTests.java index bea301b046..143c05b021 100644 --- a/src/test/java/org/springframework/data/redis/listener/RedisMessageListenerContainerIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/listener/RedisMessageListenerContainerIntegrationTests.java @@ -29,6 +29,9 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.MessageListener; @@ -39,9 +42,7 @@ import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.lang.Nullable; /** @@ -49,6 +50,7 @@ * * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") class RedisMessageListenerContainerIntegrationTests { @@ -73,11 +75,11 @@ public static Collection testParams() { // Jedis JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); return Arrays.asList(new Object[][] { { jedisConnFactory }, { lettuceConnFactory } }); } @@ -87,7 +89,7 @@ void tearDown() throws Exception { container.destroy(); } - @ParameterizedRedisTest + @Test void notifiesChannelSubscriptionState() throws Exception { AtomicReference onSubscribe = new AtomicReference<>(); @@ -127,7 +129,7 @@ public void onChannelUnsubscribed(byte[] channel, long count) { assertThat(onUnsubscribe).hasValue("a"); } - @ParameterizedRedisTest + @Test void notifiesPatternSubscriptionState() throws Exception { AtomicReference onPsubscribe = new AtomicReference<>(); @@ -167,7 +169,7 @@ public void onPatternUnsubscribed(byte[] pattern, long count) { assertThat(onPunsubscribe).hasValue("a"); } - @ParameterizedRedisTest + @Test void repeatedSubscribeShouldNotifyOnlyOnce() throws Exception { AtomicInteger subscriptions1 = new AtomicInteger(); @@ -215,7 +217,7 @@ public void onPatternSubscribed(byte[] pattern, long count) { assertThat(subscriptions1.get() + subscriptions2.get()).isGreaterThan(0); } - @ParameterizedRedisTest // GH-964 + @Test // GH-964 void subscribeAfterStart() throws Exception { AtomicInteger subscriptions1 = new AtomicInteger(); @@ -263,7 +265,7 @@ public void onPatternSubscribed(byte[] pattern, long count) { assertThat(subscriptions1.get() + subscriptions2.get()).isGreaterThan(0); } - @ParameterizedRedisTest // GH-964 + @Test // GH-964 void multipleStarts() throws Exception { AtomicInteger subscriptions = new AtomicInteger(); @@ -298,7 +300,7 @@ public void onPatternSubscribed(byte[] pattern, long count) { container.destroy(); } - @ParameterizedRedisTest // GH-964 + @Test // GH-964 void shouldRegisterChannelsAndTopics() throws Exception { AtomicInteger subscriptions = new AtomicInteger(); diff --git a/src/test/java/org/springframework/data/redis/listener/SubscriptionConnectionTests.java b/src/test/java/org/springframework/data/redis/listener/SubscriptionConnectionTests.java index 6237e7e48f..9c923b9562 100644 --- a/src/test/java/org/springframework/data/redis/listener/SubscriptionConnectionTests.java +++ b/src/test/java/org/springframework/data/redis/listener/SubscriptionConnectionTests.java @@ -24,6 +24,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.SyncTaskExecutor; @@ -35,9 +38,7 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration tests confirming that {@link RedisMessageListenerContainer} closes connections after unsubscribing @@ -47,6 +48,7 @@ * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass @MethodSource("testParams") public class SubscriptionConnectionTests { @@ -72,11 +74,11 @@ public static Collection testParams() { // Jedis JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); return Arrays.asList(new Object[][] { { jedisConnFactory }, { lettuceConnFactory } }); } @@ -90,7 +92,8 @@ void tearDown() throws Exception { } } - @ParameterizedRedisTest // GH-964 + @Test + // GH-964 void testStopMessageListenerContainers() throws Exception { // Grab all 8 connections from the pool. They should be released on @@ -115,7 +118,7 @@ void testStopMessageListenerContainers() throws Exception { connection.close(); } - @ParameterizedRedisTest + @Test void testRemoveLastListener() throws Exception { // Grab all 8 connections from the pool @@ -141,7 +144,7 @@ void testRemoveLastListener() throws Exception { connection.close(); } - @ParameterizedRedisTest + @Test void testStopListening() throws InterruptedException { // Grab all 8 connections from the pool. diff --git a/src/test/java/org/springframework/data/redis/mapping/Jackson2HashMapperIntegrationTests.java b/src/test/java/org/springframework/data/redis/mapping/Jackson2HashMapperIntegrationTests.java index 8b96474031..da98b81f06 100644 --- a/src/test/java/org/springframework/data/redis/mapping/Jackson2HashMapperIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/mapping/Jackson2HashMapperIntegrationTests.java @@ -15,7 +15,7 @@ */ package org.springframework.data.redis.mapping; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; @@ -24,6 +24,9 @@ import java.util.Objects; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.beans.factory.InitializingBean; import org.springframework.data.redis.Address; @@ -33,9 +36,7 @@ import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.hash.Jackson2HashMapper; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration tests for {@link Jackson2HashMapper}. @@ -44,6 +45,7 @@ * @author Mark Paluch * @author John Blum */ +@ParameterizedClass @MethodSource("params") public class Jackson2HashMapperIntegrationTests { @@ -61,8 +63,8 @@ public Jackson2HashMapperIntegrationTests(RedisConnectionFactory factory) throws public static Collection params() { - return Arrays.asList(JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class), - LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class)); + return Arrays.asList(JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class), + LettuceConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class)); } @BeforeEach @@ -75,7 +77,7 @@ public void setUp() { this.mapper = new Jackson2HashMapper(true); } - @ParameterizedRedisTest // DATAREDIS-423 + @Test // DATAREDIS-423 public void shouldWriteReadHashCorrectly() { Person jon = new Person("jon", "snow", 19); @@ -90,7 +92,7 @@ public void shouldWriteReadHashCorrectly() { assertThat(result).isEqualTo(jon); } - @ParameterizedRedisTest // GH-2565 + @Test // GH-2565 public void shouldPreserveListPropertyOrderOnHashedSource() { User jonDoe = User.as("Jon Doe") diff --git a/src/test/java/org/springframework/data/redis/repository/cdi/RedisCdiDependenciesProducer.java b/src/test/java/org/springframework/data/redis/repository/cdi/RedisCdiDependenciesProducer.java index 67d0053687..48a68512e3 100644 --- a/src/test/java/org/springframework/data/redis/repository/cdi/RedisCdiDependenciesProducer.java +++ b/src/test/java/org/springframework/data/redis/repository/cdi/RedisCdiDependenciesProducer.java @@ -27,7 +27,7 @@ import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.mapping.RedisMappingContext; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Mark Paluch @@ -39,7 +39,7 @@ public class RedisCdiDependenciesProducer { */ @Produces public RedisConnectionFactory redisConnectionFactory() { - return JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + return JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); } /** diff --git a/src/test/java/org/springframework/data/redis/repository/support/QueryByExampleRedisExecutorIntegrationTests.java b/src/test/java/org/springframework/data/redis/repository/support/QueryByExampleRedisExecutorIntegrationTests.java index 0c29bc6e6a..54b636c261 100644 --- a/src/test/java/org/springframework/data/redis/repository/support/QueryByExampleRedisExecutorIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/repository/support/QueryByExampleRedisExecutorIntegrationTests.java @@ -45,7 +45,7 @@ import org.springframework.data.redis.core.mapping.RedisMappingContext; import org.springframework.data.redis.core.mapping.RedisPersistentEntity; import org.springframework.data.redis.repository.core.MappingRedisEntityInformation; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; import org.springframework.data.repository.query.FluentQuery; /** @@ -65,7 +65,7 @@ class QueryByExampleRedisExecutorIntegrationTests { @BeforeAll static void beforeAll() { - connectionFactory = JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class); + connectionFactory = JedisConnectionFactoryExtension.getConnectionFactory(RedisStandalone.class); } @BeforeEach diff --git a/src/test/java/org/springframework/data/redis/support/BoundKeyOperationsIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/BoundKeyOperationsIntegrationTests.java index ad510f97e5..a0bcee113e 100644 --- a/src/test/java/org/springframework/data/redis/support/BoundKeyOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/BoundKeyOperationsIntegrationTests.java @@ -23,6 +23,9 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.core.BoundKeyOperations; @@ -30,8 +33,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.support.atomic.RedisAtomicInteger; import org.springframework.data.redis.support.atomic.RedisAtomicLong; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * @author Costin Leau @@ -39,6 +40,7 @@ * @author Thomas Darimont * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("testParams") public class BoundKeyOperationsIntegrationTests { @@ -77,7 +79,7 @@ void tearDown() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testRename() throws Exception { Object key = keyOps.getKey(); @@ -90,7 +92,8 @@ void testRename() throws Exception { assertThat(keyOps.getKey()).isEqualTo(key); } - @ParameterizedRedisTest // DATAREDIS-251 + @Test + // DATAREDIS-251 void testExpire() throws Exception { assertThat(keyOps.getExpire()).as(keyOps.getClass().getName() + " -> " + keyOps.getKey()) @@ -102,7 +105,7 @@ void testExpire() throws Exception { } } - @ParameterizedRedisTest // DATAREDIS-251 + @Test // DATAREDIS-251 void testPersist() throws Exception { keyOps.persist(); diff --git a/src/test/java/org/springframework/data/redis/support/BoundKeyParams.java b/src/test/java/org/springframework/data/redis/support/BoundKeyParams.java index 89b7270a3d..337f6bdb2b 100644 --- a/src/test/java/org/springframework/data/redis/support/BoundKeyParams.java +++ b/src/test/java/org/springframework/data/redis/support/BoundKeyParams.java @@ -29,7 +29,7 @@ import org.springframework.data.redis.support.collections.DefaultRedisMap; import org.springframework.data.redis.support.collections.DefaultRedisSet; import org.springframework.data.redis.support.collections.RedisList; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Costin Leau @@ -41,7 +41,7 @@ public class BoundKeyParams { public static Collection testParams() { // Jedis JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); StringRedisTemplate templateJS = new StringRedisTemplate(jedisConnFactory); DefaultRedisMap mapJS = new DefaultRedisMap("bound:key:map", templateJS); @@ -50,7 +50,7 @@ public static Collection testParams() { // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); StringRedisTemplate templateLT = new StringRedisTemplate(lettuceConnFactory); DefaultRedisMap mapLT = new DefaultRedisMap("bound:key:mapLT", templateLT); diff --git a/src/test/java/org/springframework/data/redis/support/atomic/AtomicCountersParam.java b/src/test/java/org/springframework/data/redis/support/atomic/AtomicCountersParam.java index 15393f3cc6..dbe1ef59b0 100644 --- a/src/test/java/org/springframework/data/redis/support/atomic/AtomicCountersParam.java +++ b/src/test/java/org/springframework/data/redis/support/atomic/AtomicCountersParam.java @@ -18,14 +18,11 @@ import java.util.Arrays; import java.util.Collection; -import org.springframework.data.redis.connection.RedisStandaloneConfiguration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension; -import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension; -import org.springframework.data.redis.test.extension.LettuceTestClientResources; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Costin Leau @@ -39,11 +36,11 @@ static Collection testParams() { // Jedis JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class, false); + .getConnectionFactory(RedisStandalone.class, false); return Arrays.asList(new Object[][] { { jedisConnFactory }, { lettuceConnFactory } }); } diff --git a/src/test/java/org/springframework/data/redis/support/atomic/CompareAndSetIntegrationIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/atomic/CompareAndSetIntegrationIntegrationTests.java index 6e436a7365..5154db6858 100644 --- a/src/test/java/org/springframework/data/redis/support/atomic/CompareAndSetIntegrationIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/atomic/CompareAndSetIntegrationIntegrationTests.java @@ -20,6 +20,9 @@ import java.util.Collection; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -27,8 +30,6 @@ import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for {@link CompareAndSet}. @@ -36,6 +37,7 @@ * @author Mark Paluch * @author Christoph Strobl */ +@ParameterizedClass @MethodSource("testParams") public class CompareAndSetIntegrationIntegrationTests { @@ -70,7 +72,8 @@ void setUp() { connection.close(); } - @ParameterizedRedisTest // DATAREDIS-843 + @Test + // DATAREDIS-843 void shouldUpdateCounter() { long expected = 5; @@ -84,7 +87,7 @@ void shouldUpdateCounter() { assertThat(valueOps.get(KEY)).isEqualTo(update); } - @ParameterizedRedisTest // DATAREDIS-843 + @Test // DATAREDIS-843 void expectationNotMet() { long expected = 5; @@ -98,7 +101,7 @@ void expectationNotMet() { assertThat(valueOps.get(KEY)).isNull(); } - @ParameterizedRedisTest // DATAREDIS-843 + @Test // DATAREDIS-843 void concurrentUpdate() { long expected = 5; diff --git a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicDoubleIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicDoubleIntegrationTests.java index f8941ffe8a..d23f4d8b7b 100644 --- a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicDoubleIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicDoubleIntegrationTests.java @@ -26,6 +26,9 @@ import org.assertj.core.data.Offset; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.data.redis.connection.RedisConnection; @@ -33,8 +36,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link RedisAtomicDouble} @@ -45,6 +46,7 @@ * @author Mark Paluch * @author Graham MacMaster */ +@ParameterizedClass @MethodSource("testParams") public class RedisAtomicDoubleIntegrationTests { @@ -78,7 +80,7 @@ void before() { this.doubleCounter = new RedisAtomicDouble(getClass().getSimpleName() + ":double", factory); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testCheckAndSet() { doubleCounter.set(0); @@ -87,14 +89,15 @@ void testCheckAndSet() { assertThat(doubleCounter.compareAndSet(10.6, 0)).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test + // DATAREDIS-198 void testIncrementAndGet() { doubleCounter.set(0); assertThat(doubleCounter.incrementAndGet()).isEqualTo(1.0); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testAddAndGet() { doubleCounter.set(0); @@ -102,14 +105,14 @@ void testAddAndGet() { assertThat(doubleCounter.addAndGet(delta)).isCloseTo(delta, Offset.offset(.0001)); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testDecrementAndGet() { doubleCounter.set(1); assertThat(doubleCounter.decrementAndGet()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testGetAndSet() { doubleCounter.set(3.4); @@ -117,7 +120,7 @@ void testGetAndSet() { assertThat(doubleCounter.get()).isEqualTo(1.2); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testGetAndIncrement() { doubleCounter.set(2.3); @@ -125,7 +128,7 @@ void testGetAndIncrement() { assertThat(doubleCounter.get()).isEqualTo(3.3); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testGetAndDecrement() { doubleCounter.set(0.5); @@ -133,7 +136,7 @@ void testGetAndDecrement() { assertThat(doubleCounter.get()).isEqualTo(-0.5); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testGetAndAdd() { doubleCounter.set(0.5); @@ -141,14 +144,14 @@ void testGetAndAdd() { assertThat(doubleCounter.get()).isEqualTo(1.2); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testExpire() { assertThat(doubleCounter.expire(1, TimeUnit.SECONDS)).isTrue(); assertThat(doubleCounter.getExpire()).isGreaterThan(0); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testExpireAt() { doubleCounter.set(7.8); @@ -156,7 +159,7 @@ void testExpireAt() { assertThat(doubleCounter.getExpire()).isGreaterThan(0); } - @ParameterizedRedisTest // DATAREDIS-198 + @Test // DATAREDIS-198 void testRename() { doubleCounter.set(5.6); @@ -165,7 +168,7 @@ void testRename() { assertThat(factory.getConnection().get((getClass().getSimpleName() + ":double").getBytes())).isNull(); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldThrowExceptionIfRedisAtomicDoubleIsUsedWithRedisTemplateAndNoKeySerializer() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -173,7 +176,7 @@ void testShouldThrowExceptionIfRedisAtomicDoubleIsUsedWithRedisTemplateAndNoKeyS .withMessageContaining("a valid key serializer in template is required"); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldThrowExceptionIfRedisAtomicDoubleIsUsedWithRedisTemplateAndNoValueSerializer() { @@ -184,7 +187,7 @@ void testShouldThrowExceptionIfRedisAtomicDoubleIsUsedWithRedisTemplateAndNoValu .withMessageContaining("a valid value serializer in template is required"); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldBeAbleToUseRedisAtomicDoubleWithProperlyConfiguredRedisTemplate() { RedisAtomicDouble ral = new RedisAtomicDouble("DATAREDIS-317.atomicDouble", template); @@ -193,7 +196,7 @@ void testShouldBeAbleToUseRedisAtomicDoubleWithProperlyConfiguredRedisTemplate() assertThat(ral.get()).isEqualTo(32.23); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void getThrowsExceptionWhenKeyHasBeenRemoved() { // setup double @@ -206,7 +209,7 @@ void getThrowsExceptionWhenKeyHasBeenRemoved() { .withMessageContaining("'test' seems to no longer exist"); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void getAndSetReturnsZeroWhenKeyHasBeenRemoved() { // setup double @@ -218,7 +221,7 @@ void getAndSetReturnsZeroWhenKeyHasBeenRemoved() { assertThat(test.getAndSet(2)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void updateAndGetAppliesGivenUpdateFunctionAndReturnsUpdatedValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -240,7 +243,7 @@ void updateAndGetAppliesGivenUpdateFunctionAndReturnsUpdatedValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void updateAndGetUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -261,7 +264,7 @@ void updateAndGetUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndUpdateAppliesGivenUpdateFunctionAndReturnsOriginalValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -283,7 +286,7 @@ void getAndUpdateAppliesGivenUpdateFunctionAndReturnsOriginalValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndUpdateUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -304,7 +307,7 @@ void getAndUpdateUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void accumulateAndGetAppliesGivenAccumulatorFunctionAndReturnsUpdatedValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -326,7 +329,7 @@ void accumulateAndGetAppliesGivenAccumulatorFunctionAndReturnsUpdatedValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void accumulateAndGetUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -348,7 +351,7 @@ void accumulateAndGetUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndAccumulateAppliesGivenAccumulatorFunctionAndReturnsOriginalValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -370,7 +373,7 @@ void getAndAccumulateAppliesGivenAccumulatorFunctionAndReturnsOriginalValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndAccumulateUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); diff --git a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerIntegrationTests.java index d5d9ea8bcc..d5cb512ac2 100644 --- a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicIntegerIntegrationTests.java @@ -24,6 +24,9 @@ import java.util.function.IntUnaryOperator; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.data.redis.connection.RedisConnection; @@ -31,8 +34,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link RedisAtomicInteger} @@ -44,6 +45,7 @@ * @author Mark Paluch * @author Graham MacMaster */ +@ParameterizedClass @MethodSource("testParams") public class RedisAtomicIntegerIntegrationTests { @@ -77,7 +79,7 @@ void before() { this.intCounter = new RedisAtomicInteger(getClass().getSimpleName() + ":int", factory); } - @ParameterizedRedisTest + @Test void testCheckAndSet() { intCounter.set(0); @@ -86,14 +88,14 @@ void testCheckAndSet() { assertThat(intCounter.compareAndSet(10, 0)).isTrue(); } - @ParameterizedRedisTest + @Test void testIncrementAndGet() { intCounter.set(0); assertThat(intCounter.incrementAndGet()).isOne(); } - @ParameterizedRedisTest + @Test void testAddAndGet() { intCounter.set(0); @@ -101,14 +103,14 @@ void testAddAndGet() { assertThat(intCounter.addAndGet(delta)).isEqualTo(delta); } - @ParameterizedRedisTest + @Test void testDecrementAndGet() { intCounter.set(1); assertThat(intCounter.decrementAndGet()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndIncrement() { intCounter.set(1); @@ -116,7 +118,7 @@ void testGetAndIncrement() { assertThat(intCounter.get()).isEqualTo(2); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndAdd() { intCounter.set(1); @@ -124,7 +126,7 @@ void testGetAndAdd() { assertThat(intCounter.get()).isEqualTo(6); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndDecrement() { intCounter.set(1); @@ -132,7 +134,7 @@ void testGetAndDecrement() { assertThat(intCounter.get()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndSet() { intCounter.set(1); @@ -140,7 +142,7 @@ void testGetAndSet() { assertThat(intCounter.get()).isEqualTo(5); } - @ParameterizedRedisTest // DATAREDIS-108, DATAREDIS-843 + @Test // DATAREDIS-108, DATAREDIS-843 void testCompareSet() throws Exception { AtomicBoolean alreadySet = new AtomicBoolean(false); @@ -172,7 +174,7 @@ void testCompareSet() throws Exception { assertThat(failed.get()).withFailMessage("counter already modified").isFalse(); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldThrowExceptionIfRedisAtomicIntegerIsUsedWithRedisTemplateAndNoKeySerializer() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -180,7 +182,7 @@ void testShouldThrowExceptionIfRedisAtomicIntegerIsUsedWithRedisTemplateAndNoKey .withMessageContaining("a valid key serializer in template is required"); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldThrowExceptionIfRedisAtomicIntegerIsUsedWithRedisTemplateAndNoValueSerializer() { RedisTemplate template = new RedisTemplate<>(); @@ -190,7 +192,7 @@ void testShouldThrowExceptionIfRedisAtomicIntegerIsUsedWithRedisTemplateAndNoVal .withMessageContaining("a valid value serializer in template is required"); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldBeAbleToUseRedisAtomicIntegerWithProperlyConfiguredRedisTemplate() { RedisAtomicInteger ral = new RedisAtomicInteger("DATAREDIS-317.atomicInteger", template); @@ -199,7 +201,7 @@ void testShouldBeAbleToUseRedisAtomicIntegerWithProperlyConfiguredRedisTemplate( assertThat(ral.get()).isEqualTo(32); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void getThrowsExceptionWhenKeyHasBeenRemoved() { // setup integer @@ -212,7 +214,7 @@ void getThrowsExceptionWhenKeyHasBeenRemoved() { .withMessageContaining("'test' seems to no longer exist"); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void getAndSetReturnsZeroWhenKeyHasBeenRemoved() { // setup integer @@ -224,7 +226,7 @@ void getAndSetReturnsZeroWhenKeyHasBeenRemoved() { assertThat(test.getAndSet(2)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void updateAndGetAppliesGivenUpdateFunctionAndReturnsUpdatedValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -246,7 +248,7 @@ void updateAndGetAppliesGivenUpdateFunctionAndReturnsUpdatedValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void updateAndGetUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -267,7 +269,7 @@ void updateAndGetUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndUpdateAppliesGivenUpdateFunctionAndReturnsOriginalValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -289,7 +291,7 @@ void getAndUpdateAppliesGivenUpdateFunctionAndReturnsOriginalValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndUpdateUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -310,7 +312,7 @@ void getAndUpdateUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void accumulateAndGetAppliesGivenAccumulatorFunctionAndReturnsUpdatedValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -332,7 +334,7 @@ void accumulateAndGetAppliesGivenAccumulatorFunctionAndReturnsUpdatedValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void accumulateAndGetUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -354,7 +356,7 @@ void accumulateAndGetUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndAccumulateAppliesGivenAccumulatorFunctionAndReturnsOriginalValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(false); @@ -376,7 +378,7 @@ void getAndAccumulateAppliesGivenAccumulatorFunctionAndReturnsOriginalValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndAccumulateUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); diff --git a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicLongIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicLongIntegrationTests.java index 21ba2729f4..4e8dc4542b 100644 --- a/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicLongIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/atomic/RedisAtomicLongIntegrationTests.java @@ -23,6 +23,9 @@ import java.util.function.LongUnaryOperator; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.data.redis.connection.RedisConnection; @@ -30,8 +33,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericToStringSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test of {@link RedisAtomicLong} @@ -43,6 +44,7 @@ * @author Mark Paluch * @author Graham MacMaster */ +@ParameterizedClass @MethodSource("testParams") public class RedisAtomicLongIntegrationTests { @@ -76,7 +78,7 @@ void before() { this.longCounter = new RedisAtomicLong(getClass().getSimpleName() + ":long", factory); } - @ParameterizedRedisTest + @Test void testCheckAndSet() { longCounter.set(0); @@ -85,14 +87,14 @@ void testCheckAndSet() { assertThat(longCounter.compareAndSet(10, 0)).isTrue(); } - @ParameterizedRedisTest + @Test void testIncrementAndGet() { longCounter.set(0); assertThat(longCounter.incrementAndGet()).isOne(); } - @ParameterizedRedisTest + @Test void testAddAndGet() { longCounter.set(0); @@ -100,14 +102,14 @@ void testAddAndGet() { assertThat(longCounter.addAndGet(delta)).isEqualTo(delta); } - @ParameterizedRedisTest + @Test void testDecrementAndGet() { longCounter.set(1); assertThat(longCounter.decrementAndGet()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndIncrement() { longCounter.set(1); @@ -115,7 +117,7 @@ void testGetAndIncrement() { assertThat(longCounter.get()).isEqualTo(2); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndAdd() { longCounter.set(1); @@ -123,7 +125,7 @@ void testGetAndAdd() { assertThat(longCounter.get()).isEqualTo(6); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndDecrement() { longCounter.set(1); @@ -131,7 +133,7 @@ void testGetAndDecrement() { assertThat(longCounter.get()).isZero(); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void testGetAndSet() { longCounter.set(1); @@ -139,7 +141,7 @@ void testGetAndSet() { assertThat(longCounter.get()).isEqualTo(5); } - @ParameterizedRedisTest + @Test void testGetExistingValue() { longCounter.set(5); @@ -147,7 +149,7 @@ void testGetExistingValue() { assertThat(longCounter.get()).isEqualTo(keyCopy.get()); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldThrowExceptionIfAtomicLongIsUsedWithRedisTemplateAndNoKeySerializer() { assertThatExceptionOfType(IllegalArgumentException.class) @@ -155,7 +157,7 @@ void testShouldThrowExceptionIfAtomicLongIsUsedWithRedisTemplateAndNoKeySerializ .withMessageContaining("a valid key serializer in template is required"); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldThrowExceptionIfAtomicLongIsUsedWithRedisTemplateAndNoValueSerializer() { RedisTemplate template = new RedisTemplate<>(); @@ -165,7 +167,7 @@ void testShouldThrowExceptionIfAtomicLongIsUsedWithRedisTemplateAndNoValueSerial .withMessageContaining("a valid value serializer in template is required"); } - @ParameterizedRedisTest // DATAREDIS-317 + @Test // DATAREDIS-317 void testShouldBeAbleToUseRedisAtomicLongWithProperlyConfiguredRedisTemplate() { RedisTemplate template = new RedisTemplate<>(); @@ -180,7 +182,7 @@ void testShouldBeAbleToUseRedisAtomicLongWithProperlyConfiguredRedisTemplate() { assertThat(ral.get()).isEqualTo(32L); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void getThrowsExceptionWhenKeyHasBeenRemoved() { // setup long @@ -193,7 +195,7 @@ void getThrowsExceptionWhenKeyHasBeenRemoved() { .withMessageContaining("'test' seems to no longer exist"); } - @ParameterizedRedisTest // DATAREDIS-469 + @Test // DATAREDIS-469 void getAndSetReturnsZeroWhenKeyHasBeenRemoved() { // setup long @@ -205,7 +207,7 @@ void getAndSetReturnsZeroWhenKeyHasBeenRemoved() { assertThat(test.getAndSet(2)).isZero(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void updateAndGetAppliesGivenUpdateFunctionAndReturnsUpdatedValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -227,7 +229,7 @@ void updateAndGetAppliesGivenUpdateFunctionAndReturnsUpdatedValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void updateAndGetUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -248,7 +250,7 @@ void updateAndGetUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndUpdateAppliesGivenUpdateFunctionAndReturnsOriginalValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -270,7 +272,7 @@ void getAndUpdateAppliesGivenUpdateFunctionAndReturnsOriginalValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndUpdateUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -291,7 +293,7 @@ void getAndUpdateUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void accumulateAndGetAppliesGivenAccumulatorFunctionAndReturnsUpdatedValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -313,7 +315,7 @@ void accumulateAndGetAppliesGivenAccumulatorFunctionAndReturnsUpdatedValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void accumulateAndGetUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -335,7 +337,7 @@ void accumulateAndGetUsesCorrectArguments() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndAccumulateAppliesGivenAccumulatorFunctionAndReturnsOriginalValue() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); @@ -357,7 +359,7 @@ void getAndAccumulateAppliesGivenAccumulatorFunctionAndReturnsOriginalValue() { assertThat(operatorHasBeenApplied).isTrue(); } - @ParameterizedRedisTest // DATAREDIS-874 + @Test // DATAREDIS-874 void getAndAccumulateUsesCorrectArguments() { AtomicBoolean operatorHasBeenApplied = new AtomicBoolean(); diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisCollectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisCollectionIntegrationTests.java index e4a0cbcd8e..e08f2e8774 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisCollectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisCollectionIntegrationTests.java @@ -25,12 +25,12 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Base test for Redis collections. @@ -84,7 +84,7 @@ void tearDown() throws Exception { }); } - @ParameterizedRedisTest + @Test public void testAdd() { T t1 = getT(); assertThat(collection.add(t1)).isTrue(); @@ -93,7 +93,7 @@ public void testAdd() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testAddAll() { T t1 = getT(); T t2 = getT(); @@ -108,7 +108,7 @@ void testAddAll() { assertThat(3).isEqualTo(collection.size()); } - @ParameterizedRedisTest + @Test void testClear() { T t1 = getT(); assertThat(collection).isEmpty(); @@ -118,7 +118,7 @@ void testClear() { assertThat(collection).isEmpty(); } - @ParameterizedRedisTest + @Test void testContainsObject() { T t1 = getT(); assertThat(collection).doesNotContain(t1); @@ -127,7 +127,7 @@ void testContainsObject() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testContainsAll() { T t1 = getT(); T t2 = getT(); @@ -140,17 +140,17 @@ void testContainsAll() { assertThat(collection).contains(t1, t2, t3); } - @ParameterizedRedisTest + @Test void testEquals() { // assertEquals(collection, copyStore(collection)); } - @ParameterizedRedisTest + @Test void testHashCode() { assertThat(collection.hashCode()).isNotEqualTo(collection.getKey().hashCode()); } - @ParameterizedRedisTest + @Test void testIsEmpty() { assertThat(collection).isEmpty(); assertThat(collection.isEmpty()).isTrue(); @@ -162,7 +162,7 @@ void testIsEmpty() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test public void testIterator() { T t1 = getT(); T t2 = getT(); @@ -181,7 +181,7 @@ public void testIterator() { assertThat(iterator.hasNext()).isFalse(); } - @ParameterizedRedisTest + @Test void testRemoveObject() { T t1 = getT(); T t2 = getT(); @@ -200,7 +200,7 @@ void testRemoveObject() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void removeAll() { T t1 = getT(); T t2 = getT(); @@ -223,7 +223,7 @@ void removeAll() { assertThat(collection).doesNotContain(t2, t3); } - // @ParameterizedRedisTest(expected = UnsupportedOperationException.class) + // @Test(expected = UnsupportedOperationException.class) @SuppressWarnings("unchecked") public void testRetainAll() { T t1 = getT(); @@ -240,7 +240,7 @@ public void testRetainAll() { assertThat(collection).contains(t2); } - @ParameterizedRedisTest + @Test void testSize() { assertThat(collection).isEmpty(); assertThat(collection.isEmpty()).isTrue(); @@ -252,7 +252,7 @@ void testSize() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test public void testToArray() { Object[] expectedArray = new Object[] { getT(), getT(), getT() }; List list = (List) Arrays.asList(expectedArray); @@ -264,7 +264,7 @@ public void testToArray() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test public void testToArrayWithGenerics() { Object[] expectedArray = new Object[] { getT(), getT(), getT() }; List list = (List) Arrays.asList(expectedArray); @@ -275,14 +275,14 @@ public void testToArrayWithGenerics() { assertThat(array).isEqualTo(expectedArray); } - @ParameterizedRedisTest + @Test void testToString() { String name = collection.toString(); collection.add(getT()); assertThat(collection.toString()).isEqualTo(name); } - @ParameterizedRedisTest + @Test void testGetKey() throws Exception { assertThat(collection.getKey()).isNotNull(); } diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisListIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisListIntegrationTests.java index 692a967c1f..152111c808 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisListIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisListIntegrationTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.redis.support.collections; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.*; import java.util.ArrayList; import java.util.Arrays; @@ -29,11 +27,12 @@ import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.connection.RedisListCommands; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration tests for RedisList @@ -66,7 +65,7 @@ public void setUp() throws Exception { this.list = (RedisList) this.collection; } - @ParameterizedRedisTest + @Test void testAddIndexObjectHead() { T t1 = getT(); @@ -81,7 +80,7 @@ void testAddIndexObjectHead() { assertThat(list.get(0)).isEqualTo(t3); } - @ParameterizedRedisTest + @Test void testAddIndexObjectTail() { T t1 = getT(); @@ -96,7 +95,7 @@ void testAddIndexObjectTail() { assertThat(list.get(2)).isEqualTo(t3); } - @ParameterizedRedisTest + @Test void testAddIndexObjectMiddle() { T t1 = getT(); @@ -110,7 +109,7 @@ void testAddIndexObjectMiddle() { assertThatIllegalArgumentException().isThrownBy(() -> list.add(1, t3)); } - @ParameterizedRedisTest + @Test void addAllIndexCollectionHead() { T t1 = getT(); @@ -132,7 +131,7 @@ void addAllIndexCollectionHead() { assertThat(list.get(1)).isEqualTo(t4); } - @ParameterizedRedisTest + @Test void addAllIndexCollectionTail() { T t1 = getT(); @@ -153,7 +152,7 @@ void addAllIndexCollectionTail() { assertThat(list.get(3)).isEqualTo(t4); } - @ParameterizedRedisTest + @Test void addAllIndexCollectionMiddle() { T t1 = getT(); @@ -170,7 +169,7 @@ void addAllIndexCollectionMiddle() { assertThatIllegalArgumentException().isThrownBy(() -> list.addAll(1, asList)); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void testIndexOfObject() { @@ -186,7 +185,7 @@ void testIndexOfObject() { assertThat(list.indexOf(t2)).isEqualTo(1); } - @ParameterizedRedisTest + @Test void testOffer() { T t1 = getT(); @@ -195,7 +194,7 @@ void testOffer() { assertThat(list.get(0)).isEqualTo(t1); } - @ParameterizedRedisTest + @Test void testPeek() { assertThat(list.peek()).isNull(); @@ -211,7 +210,7 @@ void testPeek() { assertThat(list.peek()).isNull(); } - @ParameterizedRedisTest + @Test void testElement() { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(list::element); @@ -225,12 +224,12 @@ void testElement() { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(list::element); } - @ParameterizedRedisTest + @Test void testPop() { testPoll(); } - @ParameterizedRedisTest + @Test void testPoll() { assertThat(list.poll()).isNull(); @@ -243,7 +242,7 @@ void testPoll() { assertThat(list.poll()).isNull(); } - @ParameterizedRedisTest + @Test void testPollTimeout() throws InterruptedException { T t1 = getT(); @@ -251,7 +250,7 @@ void testPollTimeout() throws InterruptedException { assertThat(list.poll(1, TimeUnit.MILLISECONDS)).isEqualTo(t1); } - @ParameterizedRedisTest + @Test void testRemove() { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(list::remove); @@ -264,7 +263,7 @@ void testRemove() { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(list::remove); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("LMOVE") @SuppressWarnings("unchecked") void testMoveFirstTo() { @@ -286,7 +285,7 @@ void testMoveFirstTo() { assertThat(target).hasSize(3).containsSequence(t2, t1, t3); } - @ParameterizedRedisTest // GH-2039 + @Test // GH-2039 @EnabledOnCommand("LMOVE") @SuppressWarnings("unchecked") void testMoveLastTo() { @@ -308,7 +307,7 @@ void testMoveLastTo() { assertThat(target).hasSize(3).containsSequence(t2, t3, t1); } - @ParameterizedRedisTest + @Test void testRange() { T t1 = getT(); @@ -324,12 +323,12 @@ void testRange() { assertThat(list.range(1, 1).get(0)).isEqualTo(t2); } - @ParameterizedRedisTest + @Test void testRemoveIndex() { assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> list.remove(0)); } - @ParameterizedRedisTest + @Test void testSet() { T t1 = getT(); @@ -342,7 +341,7 @@ void testSet() { assertThat(list.get(0)).isEqualTo(t2); } - @ParameterizedRedisTest + @Test void testTrim() { T t1 = getT(); @@ -361,7 +360,7 @@ void testTrim() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testCappedCollection() { RedisList cappedList = new DefaultRedisList(template.boundListOps(collection.getKey() + ":capped"), 1); @@ -383,7 +382,7 @@ void testCappedCollection() { assertThat(cappedList.get(0)).isEqualTo(first); } - @ParameterizedRedisTest + @Test void testAddFirst() { T t1 = getT(); @@ -399,7 +398,7 @@ void testAddFirst() { assertThat(iterator.next()).isEqualTo(t1); } - @ParameterizedRedisTest + @Test void testAddLast() { T t1 = getT(); @@ -415,7 +414,7 @@ void testAddLast() { assertThat(iterator.next()).isEqualTo(t3); } - @ParameterizedRedisTest + @Test void testDescendingIterator() { T t1 = getT(); @@ -433,7 +432,7 @@ void testDescendingIterator() { assertThat(iterator.next()).isEqualTo(t1); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 void testListIteratorAddNextPreviousIsCorrect() { T t1 = getT(); @@ -461,7 +460,7 @@ void testListIteratorAddNextPreviousIsCorrect() { assertThat(listIterator.hasPrevious()).isTrue(); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 public void testListIteratorSetIsCorrect() { T t1 = getT(); @@ -488,7 +487,7 @@ public void testListIteratorSetIsCorrect() { assertThat(this.list).containsExactly(t1, t2, t3, t4, t5); } - @ParameterizedRedisTest + @Test void testDrainToCollectionWithMaxElements() { T t1 = getT(); @@ -507,7 +506,7 @@ void testDrainToCollectionWithMaxElements() { assertThat(c).hasSize(2).contains(t1, t2); } - @ParameterizedRedisTest + @Test void testDrainToCollection() { T t1 = getT(); @@ -526,7 +525,7 @@ void testDrainToCollection() { assertThat(c).hasSize(3).contains(t1, t2, t3); } - @ParameterizedRedisTest + @Test void testGetFirst() { T t1 = getT(); @@ -538,27 +537,27 @@ void testGetFirst() { assertThat(list.getFirst()).isEqualTo(t1); } - @ParameterizedRedisTest + @Test void testLast() { testAdd(); } - @ParameterizedRedisTest + @Test void testOfferFirst() { testAddFirst(); } - @ParameterizedRedisTest + @Test void testOfferLast() { testAddLast(); } - @ParameterizedRedisTest + @Test void testPeekFirst() { testPeek(); } - @ParameterizedRedisTest + @Test void testPeekLast() { T t1 = getT(); @@ -571,12 +570,12 @@ void testPeekLast() { assertThat(list).hasSize(2); } - @ParameterizedRedisTest + @Test void testPollFirst() { testPoll(); } - @ParameterizedRedisTest + @Test void testPollLast() { T t1 = getT(); @@ -591,7 +590,7 @@ void testPollLast() { assertThat(list).hasSize(1).contains(t1); } - @ParameterizedRedisTest + @Test void testPollLastTimeout() throws InterruptedException { T t1 = getT(); @@ -606,42 +605,42 @@ void testPollLastTimeout() throws InterruptedException { assertThat(list).hasSize(1).contains(t1); } - @ParameterizedRedisTest + @Test void testPut() { testOffer(); } - @ParameterizedRedisTest + @Test void testPutFirst() { testAdd(); } - @ParameterizedRedisTest + @Test void testPutLast() { testPut(); } - @ParameterizedRedisTest + @Test void testRemainingCapacity() { assertThat(list.remainingCapacity()).isEqualTo(Integer.MAX_VALUE); } - @ParameterizedRedisTest + @Test void testRemoveFirst() { testPop(); } - @ParameterizedRedisTest + @Test void testRemoveFirstOccurrence() { testRemove(); } - @ParameterizedRedisTest + @Test void testRemoveLast() { testPollLast(); } - @ParameterizedRedisTest + @Test void testRmoveLastOccurrence() { T t1 = getT(); @@ -656,22 +655,22 @@ void testRmoveLastOccurrence() { assertThat(list).hasSize(3).containsExactly(t1, t2, t1); } - @ParameterizedRedisTest + @Test void testTake() { testPoll(); } - @ParameterizedRedisTest + @Test void testTakeFirst() { testTake(); } - @ParameterizedRedisTest + @Test void testTakeLast() { testPollLast(); } - @ParameterizedRedisTest // DATAREDIS-1196 + @Test // DATAREDIS-1196 @EnabledOnCommand("LPOS") void lastIndexOf() { @@ -687,7 +686,7 @@ void lastIndexOf() { assertThat(list.lastIndexOf(t1)).isEqualTo(2); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 void testReversed() { T elementOne = getT(); @@ -707,7 +706,7 @@ void testReversed() { assertThat(reversedList.reversed()).isEqualTo(this.list); } - @ParameterizedRedisTest // // GH-2602 + @Test // // GH-2602 public void testReversedListIterator() { T elementOne = getT(); @@ -749,7 +748,7 @@ public void testReversedListIterator() { assertThat(reorderedList).containsExactly(elementOne, elementTwo, elementFour); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 void testReversedWithAddFirst() { T elementOne = getT(); @@ -769,7 +768,7 @@ void testReversedWithAddFirst() { assertThat(reorderedList).containsExactly(elementOne, elementTwo, elementThree); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 void testReversedWithAddLast() { T elementZero = getT(); @@ -791,7 +790,7 @@ void testReversedWithAddLast() { assertThat(reorderedList).containsExactly(elementZero, elementOne, elementTwo); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 void testReversedWithRemoveFirst() { T elementOne = getT(); @@ -811,7 +810,7 @@ void testReversedWithRemoveFirst() { assertThat(reorderedList).containsExactly(elementOne, elementTwo); } - @ParameterizedRedisTest // GH-2602 + @Test // GH-2602 void testReversedWithRemoveLast() { T elementOne = getT(); diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisMapIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisMapIntegrationTests.java index 6532cdfdc5..71ebdf950a 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisMapIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisMapIntegrationTests.java @@ -35,6 +35,8 @@ import org.assertj.core.api.Assumptions; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.DoubleAsStringObjectFactory; @@ -49,8 +51,6 @@ import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.MethodSource; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test for Redis Map. @@ -100,7 +100,7 @@ protected RedisStore copyStore(RedisStore store) { return new DefaultRedisMap(store.getKey(), store.getOperations()); } - @ParameterizedRedisTest + @Test void testClear() { map.clear(); assertThat(map.size()).isEqualTo(0); @@ -110,7 +110,7 @@ void testClear() { assertThat(map.size()).isEqualTo(0); } - @ParameterizedRedisTest + @Test void testContainsKey() { K k1 = getKey(); K k2 = getKey(); @@ -123,14 +123,14 @@ void testContainsKey() { assertThat(map.containsKey(k2)).isTrue(); } - @ParameterizedRedisTest + @Test void testContainsValue() { V v1 = getValue(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> map.containsValue(v1)); } - @ParameterizedRedisTest + @Test void testEquals() { RedisStore clone = copyStore(map); assertThat(map).isEqualTo(clone); @@ -138,7 +138,7 @@ void testEquals() { assertThat(map).isEqualTo(map); } - @ParameterizedRedisTest + @Test void testNotEquals() { RedisOperations ops = map.getOperations(); RedisStore newInstance = new DefaultRedisMap<>(ops. boundHashOps(map.getKey() + ":new")); @@ -146,7 +146,7 @@ void testNotEquals() { assertThat(newInstance.equals(map)).isFalse(); } - @ParameterizedRedisTest + @Test void testGet() { K k1 = getKey(); V v1 = getValue(); @@ -156,23 +156,23 @@ void testGet() { assertThat(map.get(k1)).isEqualTo(v1); } - @ParameterizedRedisTest + @Test void testGetKey() { assertThat(map.getKey()).isNotNull(); } - @ParameterizedRedisTest + @Test public void testGetOperations() { assertThat(map.getOperations()).isEqualTo(template); } - @ParameterizedRedisTest + @Test void testHashCode() { assertThat(map.hashCode()).isNotEqualTo(map.getKey().hashCode()); assertThat(copyStore(map).hashCode()).isEqualTo(map.hashCode()); } - @ParameterizedRedisTest + @Test void testIncrementNotNumber() { assumeThat(!(valueFactory instanceof LongAsStringObjectFactory)).isTrue(); K k1 = getKey(); @@ -188,7 +188,7 @@ void testIncrementNotNumber() { } } - @ParameterizedRedisTest + @Test void testIncrement() { assumeThat(valueFactory instanceof LongAsStringObjectFactory).isTrue(); K k1 = getKey(); @@ -197,7 +197,7 @@ void testIncrement() { assertThat(map.increment(k1, 10)).isEqualTo(Long.valueOf(Long.valueOf((String) v1) + 10)); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpire() { @@ -216,7 +216,7 @@ void testExpire() { assertThat(ops.persist()).satisfies(ExpireChanges::allOk); } - @ParameterizedRedisTest // GH-3054 + @Test // GH-3054 @EnabledOnCommand("HEXPIRE") void testExpireAt() { @@ -235,7 +235,7 @@ void testExpireAt() { assertThat(ops.persist()).satisfies(ExpireChanges::allOk); } - @ParameterizedRedisTest + @Test void testIncrementDouble() { assumeThat(valueFactory instanceof DoubleAsStringObjectFactory).isTrue(); K k1 = getKey(); @@ -245,7 +245,7 @@ void testIncrementDouble() { assertThat(twoDForm.format(map.increment(k1, 3.4))).isEqualTo(twoDForm.format(Double.valueOf((String) v1) + 3.4)); } - @ParameterizedRedisTest + @Test void testIsEmpty() { map.clear(); assertThat(map.isEmpty()).isTrue(); @@ -256,7 +256,7 @@ void testIsEmpty() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testKeySet() { map.clear(); assertThat(map.keySet().isEmpty()).isTrue(); @@ -273,7 +273,7 @@ void testKeySet() { assertThat(keySet.size()).isEqualTo(3); } - @ParameterizedRedisTest + @Test void testPut() { K k1 = getKey(); K k2 = getKey(); @@ -287,7 +287,7 @@ void testPut() { assertThat(map.get(k2)).isEqualTo(v2); } - @ParameterizedRedisTest + @Test void testPutAll() { Map m = new LinkedHashMap<>(); @@ -309,7 +309,7 @@ void testPutAll() { assertThat(map.get(k2)).isEqualTo(v2); } - @ParameterizedRedisTest + @Test void testRemove() { K k1 = getKey(); K k2 = getKey(); @@ -332,7 +332,7 @@ void testRemove() { assertThat(map.get(k2)).isNull(); } - @ParameterizedRedisTest + @Test void testSize() { assertThat(map.size()).isEqualTo(0); map.put(getKey(), getValue()); @@ -348,7 +348,7 @@ void testSize() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testValues() { V v1 = getValue(); V v2 = getValue(); @@ -368,7 +368,7 @@ void testValues() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testEntrySet() { Set> entries = map.entrySet(); @@ -400,7 +400,7 @@ void testEntrySet() { assertThat(values).doesNotContain(v2); } - @ParameterizedRedisTest + @Test void testPutIfAbsent() { K k1 = getKey(); @@ -420,7 +420,7 @@ void testPutIfAbsent() { assertThat(map.get(k2)).isEqualTo(v2); } - @ParameterizedRedisTest + @Test void testConcurrentRemove() { K k1 = getKey(); @@ -435,12 +435,12 @@ void testConcurrentRemove() { assertThat(map.get(k1)).isNull(); } - @ParameterizedRedisTest + @Test void testRemoveNullValue() { assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> map.remove(getKey(), null)); } - @ParameterizedRedisTest + @Test void testConcurrentReplaceTwoArgs() { K k1 = getKey(); @@ -457,17 +457,17 @@ void testConcurrentReplaceTwoArgs() { assertThat(map.get(k1)).isEqualTo(v2); } - @ParameterizedRedisTest + @Test void testReplaceNullOldValue() { assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> map.replace(getKey(), null, getValue())); } - @ParameterizedRedisTest + @Test void testReplaceNullNewValue() { assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> map.replace(getKey(), getValue(), null)); } - @ParameterizedRedisTest + @Test void testConcurrentReplaceOneArg() { K k1 = getKey(); @@ -481,12 +481,12 @@ void testConcurrentReplaceOneArg() { assertThat(map.get(k1)).isEqualTo(v2); } - @ParameterizedRedisTest + @Test void testReplaceNullValue() { assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> map.replace(getKey(), null)); } - @ParameterizedRedisTest // DATAREDIS-314 + @Test // DATAREDIS-314 public void testScanWorksCorrectly() throws IOException { K k1 = getKey(); @@ -507,7 +507,7 @@ public void testScanWorksCorrectly() throws IOException { cursor.close(); } - @ParameterizedRedisTest // GH-2048 + @Test // GH-2048 @EnabledOnCommand("HRANDFIELD") public void randomKeyFromHash() { @@ -523,7 +523,7 @@ public void randomKeyFromHash() { assertThat(map.randomKey()).isIn(k1, k2); } - @ParameterizedRedisTest // GH-2048 + @Test // GH-2048 @EnabledOnCommand("HRANDFIELD") public void randomEntryFromHash() { diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisSetIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisSetIntegrationTests.java index 8319ee373a..81bccacd7d 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisSetIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisSetIntegrationTests.java @@ -26,13 +26,13 @@ import java.util.Set; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.core.BoundSetOperations; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; import org.springframework.util.ObjectUtils; /** @@ -69,10 +69,10 @@ private RedisSet createSetFor(String key) { return new DefaultRedisSet<>((BoundSetOperations) set.getOperations().boundSetOps(key)); } - @ParameterizedRedisTest // GH-2037 + @Test // GH-2037 @EnabledOnCommand("SMISMEMBER") void testContainsAll() { - + T t1 = getT(); T t2 = getT(); T t3 = getT(); @@ -85,7 +85,7 @@ void testContainsAll() { assertThat(set.containsAll(Collections.emptyList())).isTrue(); } - @ParameterizedRedisTest + @Test void testDiff() { RedisSet diffSet1 = createSetFor("test:set:diff1"); RedisSet diffSet2 = createSetFor("test:set:diff2"); @@ -106,7 +106,7 @@ void testDiff() { assertThat(diff).contains(t1); } - @ParameterizedRedisTest + @Test void testDiffAndStore() { RedisSet diffSet1 = createSetFor("test:set:diff1"); RedisSet diffSet2 = createSetFor("test:set:diff2"); @@ -132,7 +132,7 @@ void testDiffAndStore() { assertThat(diff.getKey()).isEqualTo(resultName); } - @ParameterizedRedisTest + @Test void testIntersect() { RedisSet intSet1 = createSetFor("test:set:int1"); RedisSet intSet2 = createSetFor("test:set:int2"); @@ -182,7 +182,7 @@ public void testIntersectAndStore() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testUnion() { RedisSet unionSet1 = createSetFor("test:set:union1"); RedisSet unionSet2 = createSetFor("test:set:union2"); @@ -205,7 +205,7 @@ void testUnion() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testUnionAndStore() { RedisSet unionSet1 = createSetFor("test:set:union1"); RedisSet unionSet2 = createSetFor("test:set:union2"); @@ -229,7 +229,7 @@ void testUnionAndStore() { assertThat(union.getKey()).isEqualTo(resultName); } - @ParameterizedRedisTest + @Test public void testIterator() { T t1 = getT(); T t2 = getT(); @@ -258,7 +258,7 @@ public void testIterator() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test public void testToArray() { Object[] expectedArray = new Object[] { getT(), getT(), getT() }; List list = (List) Arrays.asList(expectedArray); @@ -283,7 +283,7 @@ public void testToArray() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test public void testToArrayWithGenerics() { Object[] expectedArray = new Object[] { getT(), getT(), getT() }; List list = (List) Arrays.asList(expectedArray); @@ -308,7 +308,7 @@ public void testToArrayWithGenerics() { // DATAREDIS-314 @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testScanWorksCorrectly() throws IOException { Object[] expectedArray = new Object[] { getT(), getT(), getT() }; @@ -321,7 +321,7 @@ void testScanWorksCorrectly() throws IOException { cursor.close(); } - @ParameterizedRedisTest // GH-2049 + @Test // GH-2049 void randMemberReturnsSomething() { Object[] valuesArray = new Object[]{getT(), getT(), getT()}; diff --git a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java index 9f443dc7ff..541989ebd9 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java +++ b/src/test/java/org/springframework/data/redis/support/collections/AbstractRedisZSetTestIntegration.java @@ -29,6 +29,8 @@ import org.assertj.core.data.Offset; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + import org.springframework.data.domain.Range; import org.springframework.data.redis.DoubleAsStringObjectFactory; import org.springframework.data.redis.DoubleObjectFactory; @@ -42,7 +44,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ZSetOperations.TypedTuple; import org.springframework.data.redis.test.condition.EnabledOnCommand; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; /** * Integration test for Redis ZSet. @@ -76,7 +77,7 @@ public void setUp() throws Exception { zSet = (RedisZSet) collection; } - @ParameterizedRedisTest + @Test void testAddWithScore() { T t1 = getT(); T t2 = getT(); @@ -93,7 +94,7 @@ void testAddWithScore() { assertThat(iterator.hasNext()).isFalse(); } - @ParameterizedRedisTest + @Test public void testAdd() { T t1 = getT(); T t2 = getT(); @@ -110,7 +111,7 @@ public void testAdd() { assertThat(zSet.score(t3)).isEqualTo(d); } - @ParameterizedRedisTest + @Test void testFirst() { T t1 = getT(); T t2 = getT(); @@ -124,7 +125,7 @@ void testFirst() { assertThat(zSet.first()).isEqualTo(t1); } - @ParameterizedRedisTest // GH-2038 + @Test // GH-2038 @EnabledOnCommand("ZPOPMIN") void testPopFirst() { @@ -140,7 +141,7 @@ void testPopFirst() { assertThat(zSet).hasSize(2); } - @ParameterizedRedisTest // GH-2038 + @Test // GH-2038 @EnabledOnCommand("ZPOPMIN") void testPopFirstWithTimeout() { @@ -156,12 +157,12 @@ void testPopFirstWithTimeout() { assertThat(zSet).hasSize(2); } - @ParameterizedRedisTest + @Test void testFirstException() { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> zSet.first()); } - @ParameterizedRedisTest + @Test void testLast() { T t1 = getT(); @@ -176,7 +177,7 @@ void testLast() { assertThat(zSet.last()).isEqualTo(t3); } - @ParameterizedRedisTest + @Test @EnabledOnCommand("ZPOPMAX") void testPopLast() { @@ -192,7 +193,7 @@ void testPopLast() { assertThat(zSet).hasSize(2); } - @ParameterizedRedisTest + @Test @EnabledOnCommand("ZPOPMAX") void testPopLastWithTimeout() { @@ -208,12 +209,12 @@ void testPopLastWithTimeout() { assertThat(zSet).hasSize(2); } - @ParameterizedRedisTest + @Test void testLastException() { assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> zSet.last()); } - @ParameterizedRedisTest + @Test void testRank() { T t1 = getT(); T t2 = getT(); @@ -230,7 +231,7 @@ void testRank() { // assertNull(); } - @ParameterizedRedisTest + @Test void testReverseRank() { T t1 = getT(); T t2 = getT(); @@ -246,7 +247,7 @@ void testReverseRank() { assertThat(zSet.rank(getT())).isNull(); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void testLexCountUnbounded() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -263,7 +264,7 @@ void testLexCountUnbounded() { assertThat(zSet.lexCount(Range.unbounded())).isEqualTo(Long.valueOf(3)); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void testLexCountBounded() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -280,7 +281,7 @@ void testLexCountBounded() { assertThat(zSet.lexCount(Range.rightUnbounded(Range.Bound.exclusive(t1.toString())))).isEqualTo(Long.valueOf(2)); } - @ParameterizedRedisTest + @Test void testScore() { T t1 = getT(); T t2 = getT(); @@ -296,7 +297,7 @@ void testScore() { assertThat(zSet.score(t3)).isEqualTo(Double.valueOf(5)); } - @ParameterizedRedisTest + @Test void testDefaultScore() { assertThat(zSet.getDefaultScore()).isCloseTo(1, Offset.offset(0d)); } @@ -306,7 +307,7 @@ private RedisZSet createZSetFor(String key) { return new DefaultRedisZSet<>((BoundZSetOperations) zSet.getOperations().boundZSetOps(key)); } - @ParameterizedRedisTest + @Test void testRange() { T t1 = getT(); T t2 = getT(); @@ -323,7 +324,7 @@ void testRange() { assertThat(iterator.next()).isEqualTo(t3); } - @ParameterizedRedisTest + @Test void testRangeWithScores() { T t1 = getT(); @@ -347,7 +348,7 @@ void testRangeWithScores() { assertThat(tuple2.getScore()).isEqualTo(Double.valueOf(3)); } - @ParameterizedRedisTest + @Test void testReverseRange() { T t1 = getT(); T t2 = getT(); @@ -364,7 +365,7 @@ void testReverseRange() { assertThat(iterator.next()).isEqualTo(t1); } - @ParameterizedRedisTest + @Test void testReverseRangeWithScores() { T t1 = getT(); @@ -388,7 +389,7 @@ void testReverseRangeWithScores() { assertThat(tuple2.getScore()).isEqualTo(Double.valueOf(1)); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexUnbounded() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -408,7 +409,7 @@ void testRangeByLexUnbounded() { assertThat(tuple).isEqualTo(t1); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexBounded() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -428,7 +429,7 @@ void testRangeByLexBounded() { assertThat(tuple).isEqualTo(t2); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexUnboundedWithLimit() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -448,7 +449,7 @@ void testRangeByLexUnboundedWithLimit() { assertThat(tuple).isEqualTo(t2); } - @ParameterizedRedisTest // DATAREDIS-407 + @Test // DATAREDIS-407 void testRangeByLexBoundedWithLimit() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, LongAsStringObjectFactory.class, @@ -467,7 +468,7 @@ void testRangeByLexBoundedWithLimit() { assertThat(tuples).hasSize(2).containsSequence(t2, t3); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void testReverseRangeByLexBoundedWithLimit() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -486,7 +487,7 @@ void testReverseRangeByLexBoundedWithLimit() { assertThat(tuples).hasSize(2).containsSequence(t2, t1); } - @ParameterizedRedisTest // DATAREDIS-729 + @Test // DATAREDIS-729 void testReverseRangeByScore() { T t1 = getT(); @@ -504,7 +505,7 @@ void testReverseRangeByScore() { assertThat(iterator.next()).isEqualTo(t2); } - @ParameterizedRedisTest + @Test void testReverseRangeByScoreWithScores() { T t1 = getT(); @@ -529,7 +530,7 @@ void testReverseRangeByScoreWithScores() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testRangeByScore() { T t1 = getT(); T t2 = getT(); @@ -548,7 +549,7 @@ void testRangeByScore() { assertThat(iterator.next()).isEqualTo(t3); } - @ParameterizedRedisTest + @Test void testRangeByScoreWithScores() { T t1 = getT(); @@ -572,7 +573,7 @@ void testRangeByScoreWithScores() { assertThat(tuple2.getScore()).isEqualTo(Double.valueOf(3)); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 void testRangeAndStoreByLex() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -590,7 +591,7 @@ void testRangeAndStoreByLex() { assertThat(tuples).hasSize(2).containsSequence(t2, t3); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 void testRangeAndStoreRevByLex() { assumeThat(factory).isOfAnyClassIn(DoubleObjectFactory.class, DoubleAsStringObjectFactory.class, @@ -609,7 +610,7 @@ void testRangeAndStoreRevByLex() { assertThat(tuples).hasSize(2).containsSequence(t1, t2); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 @Disabled("https://github.com/spring-projects/spring-data-redis/issues/2441") void testRangeAndStoreByScore() { @@ -625,7 +626,7 @@ void testRangeAndStoreByScore() { assertThat(tuples).hasSize(2).containsSequence(t2, t3); } - @ParameterizedRedisTest // GH-2345 + @Test // GH-2345 @Disabled("https://github.com/spring-projects/spring-data-redis/issues/2441") void testRangeAndStoreRevByScore() { @@ -642,7 +643,7 @@ void testRangeAndStoreRevByScore() { assertThat(tuples).hasSize(2).containsSequence(t2, t3); } - @ParameterizedRedisTest + @Test void testRemove() { T t1 = getT(); T t2 = getT(); @@ -662,7 +663,7 @@ void testRemove() { assertThat(iterator.next()).isEqualTo(t4); } - @ParameterizedRedisTest + @Test void testRemoveByScore() { T t1 = getT(); T t2 = getT(); @@ -683,7 +684,7 @@ void testRemoveByScore() { assertThat(iterator.next()).isEqualTo(t4); } - @ParameterizedRedisTest // GH-2041 + @Test // GH-2041 @EnabledOnCommand("ZDIFF") void testDifference() { @@ -708,7 +709,7 @@ void testDifference() { assertThat(zSet.diffWithScores(Arrays.asList(set1, set2))).containsOnly(new DefaultTypedTuple<>(t1, 1d)); } - @ParameterizedRedisTest // GH-2041 + @Test // GH-2041 void testDifferenceAndStore() { RedisZSet set1 = createZSetFor("test:zset:set1"); @@ -734,7 +735,7 @@ void testDifferenceAndStore() { assertThat(diff).containsOnly(t1); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZINTER") void testIntersect() { @@ -760,7 +761,7 @@ void testIntersect() { .containsOnly(new DefaultTypedTuple<>(t2, 6d)); } - @ParameterizedRedisTest + @Test void testIntersectAndStore() { RedisZSet interSet1 = createZSetFor("test:zset:inter1"); @@ -789,7 +790,7 @@ void testIntersectAndStore() { assertThat(inter.getKey()).isEqualTo(resultName); } - @ParameterizedRedisTest // GH-2042 + @Test // GH-2042 @EnabledOnCommand("ZUNION") void testUnion() { @@ -814,7 +815,7 @@ void testUnion() { } @SuppressWarnings("unchecked") - @ParameterizedRedisTest + @Test void testUnionAndStore() { RedisZSet unionSet1 = createZSetFor("test:zset:union1"); @@ -844,7 +845,7 @@ void testUnionAndStore() { assertThat(union.score(t4)).isEqualTo(Double.valueOf(5)); } - @ParameterizedRedisTest + @Test public void testIterator() { T t1 = getT(); T t2 = getT(); @@ -865,7 +866,7 @@ public void testIterator() { assertThat(iterator.hasNext()).isFalse(); } - @ParameterizedRedisTest + @Test public void testToArray() { T t1 = getT(); T t2 = getT(); @@ -881,7 +882,7 @@ public void testToArray() { assertThat(array).isEqualTo(new Object[] { t1, t2, t3, t4 }); } - @ParameterizedRedisTest + @Test public void testToArrayWithGenerics() { T t1 = getT(); T t2 = getT(); @@ -897,7 +898,7 @@ public void testToArrayWithGenerics() { assertThat(array).isEqualTo(new Object[] { t1, t2, t3, t4 }); } - @ParameterizedRedisTest // DATAREDIS-314 + @Test // DATAREDIS-314 void testScanWorksCorrectly() throws IOException { T t1 = getT(); @@ -919,7 +920,7 @@ void testScanWorksCorrectly() throws IOException { } - @ParameterizedRedisTest // GH-1794 + @Test // GH-1794 void testZAddIfAbsentWorks() { T t1 = getT(); @@ -928,7 +929,7 @@ void testZAddIfAbsentWorks() { assertThat(zSet.addIfAbsent(t1, 1)).isFalse(); } - @ParameterizedRedisTest // GH-2049 + @Test // GH-2049 @EnabledOnCommand("ZRANDMEMBER") void randMemberReturnsSomething() { diff --git a/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java b/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java index 8b9063497f..858587c33a 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java +++ b/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java @@ -34,7 +34,7 @@ import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Costin Leau @@ -57,7 +57,7 @@ public static Collection testParams() { ObjectFactory rawFactory = new RawObjectFactory(); JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate stringTemplate = new StringRedisTemplate(jedisConnFactory); RedisTemplate personTemplate = new RedisTemplate<>(); @@ -88,7 +88,7 @@ public static Collection testParams() { // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate stringTemplateLtc = new StringRedisTemplate(lettuceConnFactory); RedisTemplate personTemplateLtc = new RedisTemplate<>(); diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisCollectionFactoryBeanTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisCollectionFactoryBeanTests.java index ecff984147..8fa06118e1 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisCollectionFactoryBeanTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisCollectionFactoryBeanTests.java @@ -29,7 +29,7 @@ import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.support.collections.RedisCollectionFactoryBean.CollectionType; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration tests for {@link RedisCollectionFactoryBean}. @@ -46,7 +46,7 @@ public class RedisCollectionFactoryBeanTests { RedisCollectionFactoryBeanTests() { JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); this.template = new StringRedisTemplate(jedisConnFactory); } diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisListIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisListIntegrationTests.java index bceca49729..2422d0e708 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisListIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisListIntegrationTests.java @@ -15,6 +15,8 @@ */ package org.springframework.data.redis.support.collections; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.core.RedisTemplate; @@ -24,6 +26,7 @@ * @author Costin Leau * @author John Blum */ +@ParameterizedClass public class RedisListIntegrationTests extends AbstractRedisListIntegrationTests { /** diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisMapIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisMapIntegrationTests.java index b54c1ba7ec..e512a68939 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisMapIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisMapIntegrationTests.java @@ -18,6 +18,8 @@ import java.util.Arrays; import java.util.Collection; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.DoubleAsStringObjectFactory; import org.springframework.data.redis.LongAsStringObjectFactory; import org.springframework.data.redis.ObjectFactory; @@ -35,7 +37,7 @@ import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; -import org.springframework.data.redis.test.extension.RedisStanalone; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * Integration test for RedisMap. @@ -46,6 +48,7 @@ * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass public class RedisMapIntegrationTests extends AbstractRedisMapIntegrationTests { @SuppressWarnings("rawtypes") @@ -78,7 +81,7 @@ public static Collection testParams() { ObjectFactory rawFactory = new RawObjectFactory(); JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate genericTemplate = new RedisTemplate(); genericTemplate.setConnectionFactory(jedisConnFactory); @@ -104,7 +107,7 @@ public static Collection testParams() { // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class, false); + .getConnectionFactory(RedisStandalone.class, false); RedisTemplate genericTemplateLettuce = new RedisTemplate(); genericTemplateLettuce.setConnectionFactory(lettuceConnFactory); diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesIntegrationTests.java index be3e627a28..9d9f9b277d 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesIntegrationTests.java @@ -27,6 +27,9 @@ import java.util.Properties; import java.util.Set; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.DoubleAsStringObjectFactory; import org.springframework.data.redis.LongAsStringObjectFactory; import org.springframework.data.redis.ObjectFactory; @@ -41,8 +44,7 @@ import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.test.XstreamOxmSerializerSingleton; -import org.springframework.data.redis.test.extension.RedisStanalone; -import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; +import org.springframework.data.redis.test.extension.RedisStandalone; /** * @author Costin Leau @@ -50,6 +52,7 @@ * @author Christoph Strobl * @author Mark Paluch */ +@ParameterizedClass public class RedisPropertiesIntegrationTests extends RedisMapIntegrationTests { private Properties defaults = new Properties(); @@ -77,12 +80,12 @@ protected RedisStore copyStore(RedisStore store) { return new RedisProperties(store.getKey(), store.getOperations()); } - @ParameterizedRedisTest + @Test public void testGetOperations() { assertThat(map.getOperations() instanceof StringRedisTemplate).isTrue(); } - @ParameterizedRedisTest + @Test void testPropertiesLoad() throws Exception { InputStream stream = getClass() .getResourceAsStream("/org/springframework/data/redis/support/collections/props.properties"); @@ -103,7 +106,7 @@ void testPropertiesLoad() throws Exception { assertThat(props.size()).isEqualTo(size + 3); } - @ParameterizedRedisTest + @Test void testPropertiesSave() throws Exception { props.setProperty("x", "y"); props.setProperty("a", "b"); @@ -112,7 +115,7 @@ void testPropertiesSave() throws Exception { props.store(writer, "no-comment"); } - @ParameterizedRedisTest + @Test void testGetProperty() throws Exception { String property = props.getProperty("a"); assertThat(property).isNull(); @@ -120,19 +123,19 @@ void testGetProperty() throws Exception { assertThat(props.getProperty("a")).isEqualTo("x"); } - @ParameterizedRedisTest + @Test void testGetPropertyDefault() throws Exception { assertThat(props.getProperty("a", "x")).isEqualTo("x"); } - @ParameterizedRedisTest + @Test void testSetProperty() throws Exception { assertThat(props.getProperty("a")).isNull(); defaults.setProperty("a", "x"); assertThat(props.getProperty("a")).isEqualTo("x"); } - @ParameterizedRedisTest + @Test void testPropertiesList() throws Exception { defaults.setProperty("a", "b"); props.setProperty("x", "y"); @@ -140,7 +143,7 @@ void testPropertiesList() throws Exception { props.list(new PrintWriter(wr)); } - @ParameterizedRedisTest + @Test void testPropertyNames() throws Exception { String key1 = "foo"; String key2 = "x"; @@ -161,13 +164,13 @@ void testPropertyNames() throws Exception { assertThat(names.hasMoreElements()).isFalse(); } - @ParameterizedRedisTest + @Test void testDefaultInit() throws Exception { RedisProperties redisProperties = new RedisProperties("foo", template); redisProperties.propertyNames(); } - @ParameterizedRedisTest + @Test void testStringPropertyNames() throws Exception { String key1 = "foo"; String key2 = "x"; @@ -199,7 +202,7 @@ public static Collection testParams() { ObjectFactory doubleFactory = new DoubleAsStringObjectFactory(); JedisConnectionFactory jedisConnFactory = JedisConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class); + .getConnectionFactory(RedisStandalone.class); RedisTemplate genericTemplate = new StringRedisTemplate(jedisConnFactory); @@ -217,7 +220,7 @@ public static Collection testParams() { // Lettuce LettuceConnectionFactory lettuceConnFactory = LettuceConnectionFactoryExtension - .getConnectionFactory(RedisStanalone.class, false); + .getConnectionFactory(RedisStandalone.class, false); RedisTemplate genericTemplateLtc = new StringRedisTemplate(lettuceConnFactory); RedisTemplate xGenericTemplateLtc = new RedisTemplate<>(); diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisSetIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisSetIntegrationTests.java index 6a0228d346..f9981dd554 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisSetIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisSetIntegrationTests.java @@ -15,6 +15,8 @@ */ package org.springframework.data.redis.support.collections; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.core.RedisTemplate; @@ -23,6 +25,7 @@ * * @author Costin Leau */ +@ParameterizedClass public class RedisSetIntegrationTests extends AbstractRedisSetIntegrationTests { /** diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisZSetIntegrationTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisZSetIntegrationTests.java index d508e0af78..d1ffa32f3d 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisZSetIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisZSetIntegrationTests.java @@ -15,6 +15,8 @@ */ package org.springframework.data.redis.support.collections; +import org.junit.jupiter.params.ParameterizedClass; + import org.springframework.data.redis.ObjectFactory; import org.springframework.data.redis.core.RedisTemplate; @@ -23,6 +25,7 @@ * * @author Costin Leau */ +@ParameterizedClass public class RedisZSetIntegrationTests extends AbstractRedisZSetTestIntegration { /** diff --git a/src/test/java/org/springframework/data/redis/test/RedisTestExtensionSupport.java b/src/test/java/org/springframework/data/redis/test/RedisTestExtensionSupport.java new file mode 100644 index 0000000000..1f9121a535 --- /dev/null +++ b/src/test/java/org/springframework/data/redis/test/RedisTestExtensionSupport.java @@ -0,0 +1,38 @@ +/* + * Copyright 2025 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.redis.test; + +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * Support class for Redis test extensions. + * + * @author Mark Paluch + */ +public abstract class RedisTestExtensionSupport { + + /** + * Returns the session {@link ExtensionContext.Store} from the given {@link ExtensionContext} and + * {@link ExtensionContext.Namespace} + * + * @param context + * @param namespace + * @return + */ + protected ExtensionContext.Store getSessionStore(ExtensionContext context, ExtensionContext.Namespace namespace) { + return context.getRoot().getStore(ExtensionContext.StoreScope.LAUNCHER_SESSION, namespace); + } +} diff --git a/src/test/java/org/springframework/data/redis/test/condition/EnabledOnCommandCondition.java b/src/test/java/org/springframework/data/redis/test/condition/EnabledOnCommandCondition.java index 1844acbb8a..8d92fb5552 100644 --- a/src/test/java/org/springframework/data/redis/test/condition/EnabledOnCommandCondition.java +++ b/src/test/java/org/springframework/data/redis/test/condition/EnabledOnCommandCondition.java @@ -25,6 +25,8 @@ import org.junit.jupiter.api.extension.ExecutionCondition; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.platform.commons.util.AnnotationUtils; + +import org.springframework.data.redis.test.RedisTestExtensionSupport; import org.springframework.data.redis.test.extension.LettuceExtension; /** @@ -34,7 +36,7 @@ * @author Mark Paluch * @author Christoph Strobl */ -class EnabledOnCommandCondition implements ExecutionCondition { +class EnabledOnCommandCondition extends RedisTestExtensionSupport implements ExecutionCondition { private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled("@EnabledOnCommand is not present"); private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(RedisConditions.class); @@ -53,7 +55,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con String command = optional.get().value(); - ExtensionContext.Store store = context.getRoot().getStore(NAMESPACE); + ExtensionContext.Store store = getSessionStore(context, NAMESPACE); RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> { try (StatefulRedisConnection connection = lettuceExtension.resolve(context, StatefulRedisConnection.class)) { diff --git a/src/test/java/org/springframework/data/redis/test/condition/EnabledOnRedisVersionCondition.java b/src/test/java/org/springframework/data/redis/test/condition/EnabledOnRedisVersionCondition.java index 5aec897431..30c93484f1 100644 --- a/src/test/java/org/springframework/data/redis/test/condition/EnabledOnRedisVersionCondition.java +++ b/src/test/java/org/springframework/data/redis/test/condition/EnabledOnRedisVersionCondition.java @@ -25,6 +25,8 @@ import org.junit.jupiter.api.extension.ExecutionCondition; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.platform.commons.util.AnnotationUtils; + +import org.springframework.data.redis.test.RedisTestExtensionSupport; import org.springframework.data.redis.test.extension.LettuceExtension; /** @@ -33,7 +35,7 @@ * @author Mark Paluch return ENABLED_BY_DEFAULT; * @see EnabledOnRedisVersionCondition */ -class EnabledOnRedisVersionCondition implements ExecutionCondition { +class EnabledOnRedisVersionCondition extends RedisTestExtensionSupport implements ExecutionCondition { private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled("@EnabledOnVersion is not present"); private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(RedisConditions.class); @@ -53,7 +55,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con String requiredVersion = optional.get().value(); - ExtensionContext.Store store = context.getRoot().getStore(NAMESPACE); + ExtensionContext.Store store = getSessionStore(context, NAMESPACE); RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> { try (StatefulRedisConnection connection = lettuceExtension.resolve(context, StatefulRedisConnection.class)) { diff --git a/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java b/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java index cdf9225e8b..3e455aa650 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java +++ b/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.Set; -import java.util.function.Function; import java.util.function.Supplier; import org.junit.jupiter.api.extension.BeforeEachCallback; @@ -38,6 +37,7 @@ import org.springframework.core.ResolvableType; import org.springframework.data.redis.SettingsUtils; +import org.springframework.data.redis.test.RedisTestExtensionSupport; import org.springframework.data.util.Lazy; /** @@ -45,7 +45,7 @@ * callbacks. The following resource types are supported by this extension: * * {@link Jedis} (singleton) - * {@link JediCluster} (singleton) + * {@link JedisCluster} (singleton) * * * @@ -69,7 +69,7 @@ * @see ParameterResolver * @see BeforeEachCallback */ -public class JedisExtension implements ParameterResolver { +public class JedisExtension extends RedisTestExtensionSupport implements ParameterResolver { private final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(JedisExtension.class); @@ -80,31 +80,16 @@ public class JedisExtension implements ParameterResolver { JedisClusterSupplier.INSTANCE); @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { return SUPPORTED_INJECTABLE_TYPES.contains(parameterContext.getParameter().getType()); } - /** - * Attempt to resolve the {@code requestedResourceType}. - * - * @param extensionContext - * @param requestedResourceType - * @param - * @return - */ - public T resolve(ExtensionContext extensionContext, Class requestedResourceType) { - - ExtensionContext.Store store = getStore(extensionContext); - - return (T) store.getOrComputeIfAbsent(requestedResourceType, it -> findSupplier(requestedResourceType).get()); - } - @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { - ExtensionContext.Store store = getStore(extensionContext); + ExtensionContext.Store store = getStore(context); Parameter parameter = parameterContext.getParameter(); Type parameterizedType = parameter.getParameterizedType(); @@ -133,21 +118,8 @@ private Object doGetInstance(Type parameterizedType) { return findSupplier(parameterizedType).get(); } - private ExtensionContext.Store getStore(ExtensionContext extensionContext) { - return extensionContext.getStore(NAMESPACE); - } - - static class ResourceFunction { - - final ResolvableType dependsOn; - final ResolvableType provides; - final Function function; - - public ResourceFunction(ResolvableType dependsOn, ResolvableType provides, Function, ?> function) { - this.dependsOn = dependsOn; - this.provides = provides; - this.function = (Function) function; - } + private ExtensionContext.Store getStore(ExtensionContext context) { + return getSessionStore(context, NAMESPACE); } enum JedisSupplier implements Supplier { @@ -155,6 +127,7 @@ enum JedisSupplier implements Supplier { INSTANCE; final Lazy lazy = Lazy.of(() -> { + Jedis client = new Jedis(SettingsUtils.getHost(), SettingsUtils.getPort()); ShutdownQueue.INSTANCE.register(client); @@ -172,6 +145,7 @@ enum JedisClusterSupplier implements Supplier { INSTANCE; final Lazy lazy = Lazy.of(() -> { + JedisCluster client = new JedisCluster(new HostAndPort(SettingsUtils.getHost(), SettingsUtils.getClusterPort())); ShutdownQueue.INSTANCE.register(client); diff --git a/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java b/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java index 949a0fba7c..d4c14158f5 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java +++ b/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java @@ -53,6 +53,7 @@ import org.junit.jupiter.api.extension.ParameterResolver; import org.springframework.core.ResolvableType; import org.springframework.data.redis.SettingsUtils; +import org.springframework.data.redis.test.RedisTestExtensionSupport; import org.springframework.data.util.Lazy; /** @@ -91,7 +92,8 @@ * @see AfterEachCallback * @see AfterAllCallback */ -public class LettuceExtension implements ParameterResolver, AfterAllCallback, AfterEachCallback { +public class LettuceExtension extends RedisTestExtensionSupport + implements ParameterResolver, AfterAllCallback, AfterEachCallback { private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(LettuceExtension.class); @@ -113,7 +115,7 @@ public class LettuceExtension implements ParameterResolver, AfterAllCallback, Af .singletonList(RedisCommandsFunction.INSTANCE); @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { return SUPPORTED_INJECTABLE_TYPES.contains(parameterContext.getParameter().getType()); } @@ -121,23 +123,23 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon /** * Attempt to resolve the {@code requestedResourceType}. * - * @param extensionContext + * @param context * @param requestedResourceType * @param * @return */ - public T resolve(ExtensionContext extensionContext, Class requestedResourceType) { + public T resolve(ExtensionContext context, Class requestedResourceType) { - ExtensionContext.Store store = getStore(extensionContext); + ExtensionContext.Store store = getStore(context); return (T) store.getOrComputeIfAbsent(requestedResourceType, it -> findSupplier(requestedResourceType).get()); } @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { - ExtensionContext.Store store = getStore(extensionContext); + ExtensionContext.Store store = getStore(context); Parameter parameter = parameterContext.getParameter(); Type parameterizedType = parameter.getParameterizedType(); @@ -200,8 +202,8 @@ private Object doGetInstance(Type parameterizedType) { .orElseGet(() -> findSupplier(parameterizedType).get()); } - private ExtensionContext.Store getStore(ExtensionContext extensionContext) { - return extensionContext.getStore(NAMESPACE); + private ExtensionContext.Store getStore(ExtensionContext context) { + return getSessionStore(context, NAMESPACE); } private static Optional findFunction(Type type) { diff --git a/src/test/java/org/springframework/data/redis/test/extension/RedisStanalone.java b/src/test/java/org/springframework/data/redis/test/extension/RedisStandalone.java similarity index 97% rename from src/test/java/org/springframework/data/redis/test/extension/RedisStanalone.java rename to src/test/java/org/springframework/data/redis/test/extension/RedisStandalone.java index e04679eb94..06a652fb12 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/RedisStanalone.java +++ b/src/test/java/org/springframework/data/redis/test/extension/RedisStandalone.java @@ -34,5 +34,5 @@ @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented -public @interface RedisStanalone { +public @interface RedisStandalone { } diff --git a/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java b/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java index f818e17e55..ca1debf4f7 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java +++ b/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java @@ -54,6 +54,10 @@ private static void close() { private final LinkedList closeables = new LinkedList<>(); + public static void register(ShutdownCloseable closeable) { + INSTANCE.closeables.add(closeable::close); + } + public static void register(Closeable closeable) { INSTANCE.closeables.add(closeable); } @@ -62,4 +66,9 @@ public static void register(AutoCloseable closeable) { INSTANCE.closeables.add(() -> IOUtils.closeQuietly(closeable)); } + public interface ShutdownCloseable { + + void close(); + } + } diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodArgumentsProvider.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodArgumentsProvider.java deleted file mode 100644 index 896192fc83..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodArgumentsProvider.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static java.lang.String.*; -import static org.junit.jupiter.params.provider.Arguments.*; - -import java.io.Closeable; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.stream.Stream; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ExtensionContext.Namespace; -import org.junit.jupiter.api.extension.ExtensionContext.Store; -import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.support.AnnotationConsumer; -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.CollectionUtils; -import org.junit.platform.commons.util.Preconditions; -import org.junit.platform.commons.util.ReflectionUtils; -import org.junit.platform.commons.util.StringUtils; -import org.springframework.data.redis.ConnectionFactoryTracker.Managed; - -/** - * Copy of {@code org.junit.jupiter.params.provider.MethodArgumentsProvider}. - */ -class MethodArgumentsProvider implements ArgumentsProvider, AnnotationConsumer { - - private static final Namespace NAMESPACE = Namespace.create(MethodArgumentsProvider.class); - - private String[] methodNames = new String[0]; - - @Override - public void accept(MethodSource annotation) { - this.methodNames = annotation.value(); - } - - @Override - public Stream provideArguments(ExtensionContext context) { - - Store store = context.getRoot().getStore(NAMESPACE); - Object testInstance = context.getTestInstance().orElse(null); - - return Arrays.stream(this.methodNames).map(factoryMethodName -> getMethod(context, factoryMethodName)) - .map(method -> (CloseablePararmeters) store.getOrComputeIfAbsent(new SourceKey(method, testInstance), - key -> new CloseablePararmeters(ReflectionUtils.invokeMethod(method, testInstance), context))) - .map(CloseablePararmeters::parameters).flatMap(CollectionUtils::toStream) - .map(MethodArgumentsProvider::toArguments); - } - - private Method getMethod(ExtensionContext context, String factoryMethodName) { - - if (StringUtils.isNotBlank(factoryMethodName)) { - if (factoryMethodName.contains("#")) { - return getMethodByFullyQualifiedName(factoryMethodName); - } else { - return ReflectionUtils.getRequiredMethod(context.getRequiredTestClass(), factoryMethodName); - } - } - return ReflectionUtils.getRequiredMethod(context.getRequiredTestClass(), context.getRequiredTestMethod().getName()); - } - - private Method getMethodByFullyQualifiedName(String fullyQualifiedMethodName) { - - String[] methodParts = ReflectionUtils.parseFullyQualifiedMethodName(fullyQualifiedMethodName); - String className = methodParts[0]; - String methodName = methodParts[1]; - String methodParameters = methodParts[2]; - - Preconditions.condition(StringUtils.isBlank(methodParameters), - () -> format("factory method [%s] must not declare formal parameters", fullyQualifiedMethodName)); - - return ReflectionUtils.getRequiredMethod(loadRequiredClass(className), methodName); - } - - private Class> loadRequiredClass(String className) { - return ReflectionUtils.tryToLoadClass(className) - .getOrThrow(cause -> new JUnitException(format("Could not load class [%s]", className), cause)); - } - - private static Arguments toArguments(Object item) { - - // Nothing to do except cast. - if (item instanceof Arguments arguments) { - return arguments; - } - - // Pass all multidimensional arrays "as is", in contrast to Object[]. - // See https://github.com/junit-team/junit5/issues/1665 - if (ReflectionUtils.isMultidimensionalArray(item)) { - return arguments(item); - } - - // Special treatment for one-dimensional reference arrays. - // See https://github.com/junit-team/junit5/issues/1665 - if (item instanceof Object[] array) { - return arguments(array); - } - - // Pass everything else "as is". - return arguments(item); - } - - /** - * Key type for a method associated with a test instance. - * - * @param method - * @param instance - */ - record SourceKey(Method method, Object instance) { - } - - /** - * Holder for parameters that can be closed using JUnit's built-in cleanup mechanism. - * - * @param parameters - * @param context - */ - record CloseablePararmeters(Object parameters, Object context) implements Store.CloseableResource { - - @Override - public void close() { - close0(parameters); - } - - private void close0(Object object) { - - if (object instanceof Managed) { - return; - } - - if (object instanceof CloseableResource closeableResource) { - try { - closeableResource.close(); - return; - } catch (Throwable cause) { - throw new RuntimeException(cause); - } - } - - if (object instanceof Closeable closeable) { - try { - closeable.close(); - return; - } catch (Throwable cause) { - throw new RuntimeException(cause); - } - } - - if (object instanceof Arguments arguments) { - close0(arguments.get()); - } - - if (object instanceof Object[] array) { - Arrays.asList(array).forEach(this::close0); - } - - if (object instanceof Iterable> iterableObject) { - iterableObject.forEach(this::close0); - } - } - } -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodSource.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodSource.java deleted file mode 100644 index 38e4477242..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodSource.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.params.provider.ArgumentsSource; - -/** - * {@code @MethodSource} is an {@link ArgumentsSource} which provides access to values returned from - * {@linkplain #value() factory methods} of the class in which this annotation is declared or from static factory - * methods in external classes referenced by fully qualified method name. - * - * This variant can be used only on type level. - * - * Copy of {@code org.junit.jupiter.params.provider.MethodSource}. - */ -@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@ArgumentsSource(MethodArgumentsProvider.class) -public @interface MethodSource { - - /** - * The names of factory methods within the test class or in external classes to use as sources for arguments. - * - * Factory methods in external classes must be referenced by fully qualified method name — for example, - * {@code com.example.StringsProviders#blankStrings}. - * - * If no factory method names are declared, a method within the test class that has the same name as the test method - * will be used as the factory method by default. - * - * For further information, see the {@linkplain MethodSource class-level Javadoc}. - */ - String[] value() default ""; - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java deleted file mode 100644 index efdef385d3..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.TestTemplate; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ExtensionContext; - -/** - * {@code @ParameterizedRedisTest} is used to signal that the annotated method is a parameterized test method - * within a potentially parametrized test class. - * - * Such methods must not be {@code private} or {@code static}. - * Argument Providers and Sources - * - * Test classes defining {@code @ParameterizedRedisTest} methods must specify at least one - * {@link org.junit.jupiter.params.provider.ArgumentsProvider ArgumentsProvider} via - * {@link org.junit.jupiter.params.provider.ArgumentsSource @ArgumentsSource} or a corresponding composed annotation - * (e.g., {@code @ValueSource}, {@code @CsvSource}, etc.). The provider is responsible for providing a - * {@link java.util.stream.Stream Stream} of {@link org.junit.jupiter.params.provider.Arguments Arguments} that will be - * used to invoke the parameterized test method. - * Method Parameter List - * - * A {@code @ParameterizedRedisTest} method may declare parameters that are resolved from the class-level - * {@link org.junit.jupiter.params.provider.ArgumentsSource}. Additional parameters that exceed the parameter index by - * the class argument source can be resolved by additional {@link org.junit.jupiter.api.extension.ParameterResolver - * ParameterResolvers} (e.g., {@code TestInfo}, {@code TestReporter}, etc). Specifically, a parameterized test method - * must declare formal parameters according to the following rules. - * - * Zero or more indexed arguments must be declared first. - * Zero or more aggregators must be declared next. - * Zero or more arguments supplied by other {@code ParameterResolver} implementations must be declared last. - * - * - * In this context, an indexed argument is an argument for a given index in the {@code Arguments} provided by - * an {@code ArgumentsProvider} that is passed as an argument to the parameterized method at the same index in the - * method's formal parameter list. An aggregator is any parameter of type - * {@link org.junit.jupiter.params.aggregator.ArgumentsAccessor ArgumentsAccessor} or any parameter annotated with - * {@link org.junit.jupiter.params.aggregator.AggregateWith @AggregateWith}. - * - * Constructor Parameter List - * - * A class defining {@code @ParameterizedRedisTest} may declare a constructor accepting arguments. Constructor arguments - * are resolved from the same class-level {@link org.junit.jupiter.params.provider.ArgumentsSource} as method arguments. - * Therefore, constructor arguments follow the same index/aggregator semantics as method arguments. - * Test Class Lifecycle - * - * Using parameterized tests requires instance creation per test method ({@code TestInstance(PER_METHOD)} to ensure that - * both, test method and test instance share the same arguments. This limitation is driven by the execution tree as test - * argument sources are activated per test method. See - * {@link org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider#provideTestTemplateInvocationContexts(ExtensionContext)}. - * - * Adaption of {@code org.junit.jupiter.params.ParameterizedTest}. - */ -@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@TestTemplate -@ExtendWith(ParameterizedRedisTestExtension.class) -public @interface ParameterizedRedisTest { - - /** - * Placeholder for the {@linkplain org.junit.jupiter.api.TestInfo#getDisplayName display name} of a - * {@code @ParameterizedTest} method: {displayName} - * - * @see #name - */ - String DISPLAY_NAME_PLACEHOLDER = "{displayName}"; - - /** - * Placeholder for the current invocation index of a {@code @ParameterizedTest} method (1-based): {index} - * - * @see #name - */ - String INDEX_PLACEHOLDER = "{index}"; - - /** - * Placeholder for the complete, comma-separated arguments list of the current invocation of a - * {@code @ParameterizedTest} method: {arguments} - * - * @see #name - */ - String ARGUMENTS_PLACEHOLDER = "{arguments}"; - - /** - * Placeholder for the complete, comma-separated named arguments list of the current invocation of a - * {@code @ParameterizedTest} method: {argumentsWithNames} - * - * @see #name - */ - String ARGUMENTS_WITH_NAMES_PLACEHOLDER = "{argumentsWithNames}"; - - /** - * Default display name pattern for the current invocation of a {@code @ParameterizedTest} method: {@value} - * - * Note that the default pattern does not include the {@linkplain #DISPLAY_NAME_PLACEHOLDER display name} of - * the {@code @ParameterizedTest} method. - * - * @see #name - * @see #DISPLAY_NAME_PLACEHOLDER - * @see #INDEX_PLACEHOLDER - * @see #ARGUMENTS_WITH_NAMES_PLACEHOLDER - */ - String DEFAULT_DISPLAY_NAME = "[" + INDEX_PLACEHOLDER + "] " + ARGUMENTS_WITH_NAMES_PLACEHOLDER; - - /** - * The display name to be used for individual invocations of the parameterized test; never blank or consisting solely - * of whitespace. - * - * Defaults to {@link #DEFAULT_DISPLAY_NAME}. - * Supported placeholders - * - * {@link #DISPLAY_NAME_PLACEHOLDER} - * {@link #INDEX_PLACEHOLDER} - * {@link #ARGUMENTS_PLACEHOLDER} - * {0}, {1}, etc.: an individual argument (0-based) - * - * - * For the latter, you may use {@link java.text.MessageFormat} patterns to customize formatting. Please note that the - * original arguments are passed when formatting, regardless of any implicit or explicit argument conversions. - * - * @see java.text.MessageFormat - */ - String name() default DEFAULT_DISPLAY_NAME; - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java deleted file mode 100644 index 0e295527ed..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static org.junit.platform.commons.util.AnnotationUtils.*; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Stream; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ExtensionContext.Namespace; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; -import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.provider.ArgumentsSource; -import org.junit.jupiter.params.support.AnnotationConsumerInitializer; -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.ExceptionUtils; -import org.junit.platform.commons.util.Preconditions; -import org.junit.platform.commons.util.ReflectionUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestExtension}. - */ -class ParameterizedRedisTestExtension implements TestTemplateInvocationContextProvider { - - private static final String METHOD_CONTEXT_KEY = "method-context"; - private static final String CONSTRUCTOR_CONTEXT_KEY = "constructor-context"; - static final String ARGUMENT_MAX_LENGTH_KEY = "junit.jupiter.params.displayname.argument.maxlength"; - - @Override - public boolean supportsTestTemplate(ExtensionContext context) { - if (!context.getTestMethod().isPresent()) { - return false; - } - - Method testMethod = context.getTestMethod().get(); - if (!isAnnotated(testMethod, ParameterizedRedisTest.class)) { - return false; - } - - Constructor> declaredConstructor = ReflectionUtils.getDeclaredConstructor(context.getRequiredTestClass()); - ParameterizedTestContext methodContext = new ParameterizedTestContext(testMethod); - ParameterizedTestContext constructorContext = new ParameterizedTestContext(declaredConstructor); - - Preconditions.condition(methodContext.hasPotentiallyValidSignature(), () -> - ("@ParameterizedRedisTest method [%s] declares formal parameters in an invalid order: " - + "argument aggregators must be declared after any indexed arguments " - + "and before any arguments resolved by another ParameterResolver.") - .formatted(testMethod.toGenericString())); - - getStore(context).put(METHOD_CONTEXT_KEY, methodContext); - getStore(context).put(CONSTRUCTOR_CONTEXT_KEY, constructorContext); - - return true; - } - - @Override - public Stream provideTestTemplateInvocationContexts( - ExtensionContext extensionContext) { - - Method templateMethod = extensionContext.getRequiredTestMethod(); - String displayName = extensionContext.getDisplayName(); - ParameterizedTestContext methodContext = getStore(extensionContext)// - .get(METHOD_CONTEXT_KEY, ParameterizedTestContext.class); - - ParameterizedTestContext constructorContext = getStore(extensionContext)// - .get(CONSTRUCTOR_CONTEXT_KEY, ParameterizedTestContext.class); - int argumentMaxLength = extensionContext.getConfigurationParameter(ARGUMENT_MAX_LENGTH_KEY, Integer::parseInt) - .orElse(512); - ParameterizedTestNameFormatter formatter = createNameFormatter(templateMethod, methodContext, displayName, - argumentMaxLength); - AtomicLong invocationCount = new AtomicLong(0); - - List> hierarchy = new ArrayList<>(); - Class> type = extensionContext.getRequiredTestClass(); - while (type != Object.class) { - hierarchy.add(type); - type = type.getSuperclass(); - } - - // @formatter:off - return hierarchy.stream().flatMap(it -> findRepeatableAnnotations(it, ArgumentsSource.class).stream() - .map(ArgumentsSource::value).map(this::instantiateArgumentsProvider) - .map(provider -> AnnotationConsumerInitializer.initialize(it, provider))) - .flatMap(provider -> arguments(provider, extensionContext)).map(Arguments::get) - .map(arguments -> consumedArguments(arguments, methodContext)) - .map(arguments -> createInvocationContext(formatter, constructorContext, methodContext, arguments)) - .peek(invocationContext -> invocationCount.incrementAndGet()) - .onClose(() -> Preconditions.condition(invocationCount.get() > 0, - "Configuration error: You must configure at least one set of arguments for this @ParameterizedRedisTest class")); - // @formatter:on - } - - @SuppressWarnings("ConstantConditions") - private ArgumentsProvider instantiateArgumentsProvider(Class extends ArgumentsProvider> clazz) { - try { - return ReflectionUtils.newInstance(clazz); - } catch (Exception ex) { - if (ex instanceof NoSuchMethodException) { - throw new JUnitException(("Failed to find a no-argument constructor for ArgumentsProvider [%s];" - + " Please ensure that a no-argument constructor exists and that the class is either" - + " a top-level class or a static nested class").formatted(clazz.getName()), ex); - } - throw ex; - } - } - - private ExtensionContext.Store getStore(ExtensionContext context) { - return context.getStore(Namespace.create(ParameterizedRedisTestExtension.class, context.getRequiredTestMethod())); - } - - private TestTemplateInvocationContext createInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - return new ParameterizedTestInvocationContext(formatter, constructorContext, methodContext, arguments); - } - - private ParameterizedTestNameFormatter createNameFormatter(Method templateMethod, - ParameterizedTestContext methodContext, String displayName, int argumentMaxLength) { - - ParameterizedRedisTest parameterizedTest = findAnnotation(templateMethod, ParameterizedRedisTest.class).get(); - - String pattern = Preconditions.notBlank(parameterizedTest.name().trim(), () -> - "Configuration error: @ParameterizedRedisTest on method [%s] must be declared with a non-empty name" - .formatted(templateMethod)); - - return new ParameterizedTestNameFormatter(pattern, displayName, methodContext, argumentMaxLength); - } - - protected static Stream extends Arguments> arguments(ArgumentsProvider provider, ExtensionContext context) { - try { - return provider.provideArguments(context); - } catch (Exception ex) { - throw ExceptionUtils.throwAsUncheckedException(ex); - } - } - - private Object[] consumedArguments(Object[] arguments, ParameterizedTestContext methodContext) { - return arguments; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java deleted file mode 100644 index 6d1dd069f1..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static org.junit.platform.commons.util.AnnotationUtils.*; -import static org.springframework.data.redis.test.extension.parametrized.ParameterizedTestContext.ResolverType.*; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.params.aggregator.AggregateWith; -import org.junit.jupiter.params.aggregator.ArgumentsAccessor; -import org.junit.jupiter.params.aggregator.ArgumentsAggregator; -import org.junit.jupiter.params.aggregator.DefaultArgumentsAccessor; -import org.junit.jupiter.params.converter.ArgumentConverter; -import org.junit.jupiter.params.converter.ConvertWith; -import org.junit.jupiter.params.converter.DefaultArgumentConverter; -import org.junit.jupiter.params.support.AnnotationConsumerInitializer; -import org.junit.platform.commons.support.ReflectionSupport; -import org.junit.platform.commons.util.AnnotationUtils; -import org.junit.platform.commons.util.ReflectionUtils; -import org.junit.platform.commons.util.StringUtils; - -/** - * Encapsulates access to the parameters of a parameterized test method and caches the converters and aggregators used - * to resolve them. - * - * Copy of {@code org.junit.jupiter.params.ParameterizedTestContext}. - */ -class ParameterizedTestContext { - - private final Parameter[] parameters; - private final Resolver[] resolvers; - private final List resolverTypes; - - ParameterizedTestContext(Executable testMethod) { - this.parameters = testMethod.getParameters(); - this.resolvers = new Resolver[this.parameters.length]; - this.resolverTypes = new ArrayList<>(this.parameters.length); - for (Parameter parameter : this.parameters) { - this.resolverTypes.add(isAggregator(parameter) ? AGGREGATOR : CONVERTER); - } - } - - /** - * Determine if the supplied {@link Parameter} is an aggregator (i.e., of type {@link ArgumentsAccessor} or annotated - * with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - private static boolean isAggregator(Parameter parameter) { - return ArgumentsAccessor.class.isAssignableFrom(parameter.getType()) || isAnnotated(parameter, AggregateWith.class); - } - - /** - * Determine if the {@link Method} represented by this context has a potentially valid signature (i.e., - * formal parameter declarations) with regard to aggregators. - * - * This method takes a best-effort approach at enforcing the following policy for parameterized test methods that - * accept aggregators as arguments. - * - * zero or more indexed arguments come first. - * zero or more aggregators come next. - * zero or more arguments supplied by other {@code ParameterResolver} implementations come last. - * - * - * @return {@code true} if the method has a potentially valid signature - */ - boolean hasPotentiallyValidSignature() { - int indexOfPreviousAggregator = -1; - for (int i = 0; i < getParameterCount(); i++) { - if (isAggregator(i)) { - if ((indexOfPreviousAggregator != -1) && (i != indexOfPreviousAggregator + 1)) { - return false; - } - indexOfPreviousAggregator = i; - } - } - return true; - } - - /** - * Get the number of parameters of the {@link Method} represented by this context. - */ - int getParameterCount() { - return parameters.length; - } - - /** - * Get the name of the {@link Parameter} with the supplied index, if it is present and declared before the - * aggregators. - * - * @return an {@code Optional} containing the name of the parameter - */ - Optional getParameterName(int parameterIndex) { - if (parameterIndex >= getParameterCount()) { - return Optional.empty(); - } - Parameter parameter = this.parameters[parameterIndex]; - if (!parameter.isNamePresent()) { - return Optional.empty(); - } - if (hasAggregator() && parameterIndex >= indexOfFirstAggregator()) { - return Optional.empty(); - } - return Optional.of(parameter.getName()); - } - - /** - * Determine if the {@link Method} represented by this context declares at least one {@link Parameter} that is an - * {@linkplain #isAggregator aggregator}. - * - * @return {@code true} if the method has an aggregator - */ - boolean hasAggregator() { - return resolverTypes.contains(AGGREGATOR); - } - - /** - * Determine if the {@link Parameter} with the supplied index is an aggregator (i.e., of type - * {@link ArgumentsAccessor} or annotated with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - boolean isAggregator(int parameterIndex) { - return resolverTypes.size() > parameterIndex && resolverTypes.get(parameterIndex) == AGGREGATOR; - } - - /** - * Find the index of the first {@linkplain #isAggregator aggregator} {@link Parameter} in the {@link Method} - * represented by this context. - * - * @return the index of the first aggregator, or {@code -1} if not found - */ - int indexOfFirstAggregator() { - return resolverTypes.indexOf(AGGREGATOR); - } - - /** - * Resolve the parameter for the supplied context using the supplied arguments. - */ - Object resolve(ParameterContext parameterContext, Object[] arguments) { - return getResolver(parameterContext).resolve(parameterContext, arguments); - } - - private Resolver getResolver(ParameterContext parameterContext) { - int index = parameterContext.getIndex(); - if (resolvers[index] == null) { - resolvers[index] = resolverTypes.get(index).createResolver(parameterContext); - } - return resolvers[index]; - } - - enum ResolverType { - - CONVERTER { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), ConvertWith.class) - .map(ConvertWith::value).map(clazz -> (ArgumentConverter) ReflectionUtils.newInstance(clazz)) - .map(converter -> AnnotationConsumerInitializer.initialize(parameterContext.getParameter(), converter)) - .map(Converter::new).orElse(Converter.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentConverter", ex, parameterContext); - } - } - }, - - AGGREGATOR { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), AggregateWith.class) - .map(AggregateWith::value).map(clazz -> (ArgumentsAggregator) ReflectionSupport.newInstance(clazz)) - .map(Aggregator::new).orElse(Aggregator.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentsAggregator", ex, parameterContext); - } - } - }; - - abstract Resolver createResolver(ParameterContext parameterContext); - - } - - interface Resolver { - - Object resolve(ParameterContext parameterContext, Object[] arguments); - - } - - static class Converter implements Resolver { - - private static final Converter DEFAULT = new Converter(DefaultArgumentConverter.INSTANCE); - - private final ArgumentConverter argumentConverter; - - Converter(ArgumentConverter argumentConverter) { - this.argumentConverter = argumentConverter; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - Object argument = arguments[parameterContext.getIndex()]; - try { - return this.argumentConverter.convert(argument, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error converting parameter", ex, parameterContext); - } - } - - } - - static class Aggregator implements Resolver { - - private static final Aggregator DEFAULT = new Aggregator((accessor, context) -> accessor); - - private final ArgumentsAggregator argumentsAggregator; - - Aggregator(ArgumentsAggregator argumentsAggregator) { - this.argumentsAggregator = argumentsAggregator; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - ArgumentsAccessor accessor = new DefaultArgumentsAccessor(parameterContext, 1, arguments); - try { - return this.argumentsAggregator.aggregateArguments(accessor, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error aggregating arguments for parameter", ex, parameterContext); - } - } - - } - - private static ParameterResolutionException parameterResolutionException(String message, Exception cause, - ParameterContext parameterContext) { - String fullMessage = message + " at index " + parameterContext.getIndex(); - if (StringUtils.isNotBlank(cause.getMessage())) { - fullMessage += ": " + cause.getMessage(); - } - return new ParameterResolutionException(fullMessage, cause); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java deleted file mode 100644 index 658cd29b20..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.extension.Extension; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestInvocationContext}. - */ -class ParameterizedTestInvocationContext implements TestTemplateInvocationContext { - - private final ParameterizedTestNameFormatter formatter; - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - this.formatter = formatter; - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public String getDisplayName(int invocationIndex) { - return this.formatter.format(invocationIndex, this.arguments); - } - - @Override - public List getAdditionalExtensions() { - return Collections.singletonList( - new ParameterizedTestParameterResolver(this.constructorContext, this.methodContext, this.arguments)); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java deleted file mode 100644 index 7c02a0171f..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static java.util.stream.Collectors.joining; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_WITH_NAMES_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.DISPLAY_NAME_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.INDEX_PLACEHOLDER; - -import java.text.Format; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.stream.IntStream; - -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.StringUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestNameFormatter}. - */ -class ParameterizedTestNameFormatter { - - private static final char ELLIPSIS = '\u2026'; - - private final String pattern; - private final String displayName; - private final ParameterizedTestContext methodContext; - private final int argumentMaxLength; - - ParameterizedTestNameFormatter(String pattern, String displayName, ParameterizedTestContext methodContext, - int argumentMaxLength) { - this.pattern = pattern; - this.displayName = displayName; - this.methodContext = methodContext; - this.argumentMaxLength = argumentMaxLength; - } - - String format(int invocationIndex, Object... arguments) { - try { - return formatSafely(invocationIndex, arguments); - } catch (Exception ex) { - throw new JUnitException("The display name pattern defined for the parameterized test is invalid;" - + " See nested exception for further details.", ex); - } - } - - private String formatSafely(int invocationIndex, Object[] arguments) { - String pattern = prepareMessageFormatPattern(invocationIndex, arguments); - MessageFormat format = new MessageFormat(pattern); - Object[] humanReadableArguments = makeReadable(format, arguments); - return format.format(humanReadableArguments); - } - - private String prepareMessageFormatPattern(int invocationIndex, Object[] arguments) { - String result = pattern// - .replace(DISPLAY_NAME_PLACEHOLDER, this.displayName)// - .replace(INDEX_PLACEHOLDER, String.valueOf(invocationIndex)); - - if (result.contains(ARGUMENTS_WITH_NAMES_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_WITH_NAMES_PLACEHOLDER, argumentsWithNamesPattern(arguments)); - } - - if (result.contains(ARGUMENTS_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_PLACEHOLDER, argumentsPattern(arguments)); - } - - return result; - } - - private String argumentsWithNamesPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> methodContext.getParameterName(index).map(name -> name + "=").orElse("") + "{" + index + "}") // - .collect(joining(", ")); - } - - private String argumentsPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> "{" + index + "}") // - .collect(joining(", ")); - } - - private Object[] makeReadable(MessageFormat format, Object[] arguments) { - Format[] formats = format.getFormatsByArgumentIndex(); - Object[] result = Arrays.copyOf(arguments, Math.min(arguments.length, formats.length), Object[].class); - for (int i = 0; i < result.length; i++) { - if (formats[i] == null) { - result[i] = truncateIfExceedsMaxLength(StringUtils.nullSafeToString(arguments[i])); - } - } - return result; - } - - private String truncateIfExceedsMaxLength(String argument) { - if (argument.length() > argumentMaxLength) { - return argument.substring(0, argumentMaxLength - 1) + ELLIPSIS; - } - return argument; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java deleted file mode 100644 index adcff56f32..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.api.extension.ParameterResolver; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestParameterResolver}. - */ -class ParameterizedTestParameterResolver implements ParameterResolver { - - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestParameterResolver(ParameterizedTestContext constructorContext, - ParameterizedTestContext methodContext, Object[] arguments) { - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { - - Executable declaringExecutable = parameterContext.getDeclaringExecutable(); - int parameterIndex = parameterContext.getIndex(); - ParameterizedTestContext testContext; - - if (declaringExecutable instanceof Constructor) { - testContext = this.constructorContext; - } else { - - Method testMethod = extensionContext.getTestMethod().orElse(null); - - // Not a parameterized method? - if (parameterContext.getDeclaringExecutable() instanceof Method && !declaringExecutable.equals(testMethod)) { - return false; - } - testContext = this.methodContext; - } - - // Current parameter is an aggregator? - if (testContext.isAggregator(parameterIndex)) { - return true; - } - - // Ensure that the current parameter is declared before aggregators. - // Otherwise, a different ParameterResolver should handle it. - if (testContext.hasAggregator()) { - return parameterIndex < testContext.indexOfFirstAggregator(); - } - - // Else fallback to behavior for parameterized test methods without aggregators. - return parameterIndex < this.arguments.length; - } - - @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - - if (parameterContext.getDeclaringExecutable() instanceof Constructor) { - return this.constructorContext.resolve(parameterContext, this.arguments); - } - - return this.methodContext.resolve(parameterContext, this.arguments); - } - -}
@@ -69,7 +69,7 @@ * @see ParameterResolver * @see BeforeEachCallback */ -public class JedisExtension implements ParameterResolver { +public class JedisExtension extends RedisTestExtensionSupport implements ParameterResolver { private final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(JedisExtension.class); @@ -80,31 +80,16 @@ public class JedisExtension implements ParameterResolver { JedisClusterSupplier.INSTANCE); @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { return SUPPORTED_INJECTABLE_TYPES.contains(parameterContext.getParameter().getType()); } - /** - * Attempt to resolve the {@code requestedResourceType}. - * - * @param extensionContext - * @param requestedResourceType - * @param - * @return - */ - public T resolve(ExtensionContext extensionContext, Class requestedResourceType) { - - ExtensionContext.Store store = getStore(extensionContext); - - return (T) store.getOrComputeIfAbsent(requestedResourceType, it -> findSupplier(requestedResourceType).get()); - } - @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { - ExtensionContext.Store store = getStore(extensionContext); + ExtensionContext.Store store = getStore(context); Parameter parameter = parameterContext.getParameter(); Type parameterizedType = parameter.getParameterizedType(); @@ -133,21 +118,8 @@ private Object doGetInstance(Type parameterizedType) { return findSupplier(parameterizedType).get(); } - private ExtensionContext.Store getStore(ExtensionContext extensionContext) { - return extensionContext.getStore(NAMESPACE); - } - - static class ResourceFunction { - - final ResolvableType dependsOn; - final ResolvableType provides; - final Function function; - - public ResourceFunction(ResolvableType dependsOn, ResolvableType provides, Function, ?> function) { - this.dependsOn = dependsOn; - this.provides = provides; - this.function = (Function) function; - } + private ExtensionContext.Store getStore(ExtensionContext context) { + return getSessionStore(context, NAMESPACE); } enum JedisSupplier implements Supplier { @@ -155,6 +127,7 @@ enum JedisSupplier implements Supplier { INSTANCE; final Lazy lazy = Lazy.of(() -> { + Jedis client = new Jedis(SettingsUtils.getHost(), SettingsUtils.getPort()); ShutdownQueue.INSTANCE.register(client); @@ -172,6 +145,7 @@ enum JedisClusterSupplier implements Supplier { INSTANCE; final Lazy lazy = Lazy.of(() -> { + JedisCluster client = new JedisCluster(new HostAndPort(SettingsUtils.getHost(), SettingsUtils.getClusterPort())); ShutdownQueue.INSTANCE.register(client); diff --git a/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java b/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java index 949a0fba7c..d4c14158f5 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java +++ b/src/test/java/org/springframework/data/redis/test/extension/LettuceExtension.java @@ -53,6 +53,7 @@ import org.junit.jupiter.api.extension.ParameterResolver; import org.springframework.core.ResolvableType; import org.springframework.data.redis.SettingsUtils; +import org.springframework.data.redis.test.RedisTestExtensionSupport; import org.springframework.data.util.Lazy; /** @@ -91,7 +92,8 @@ * @see AfterEachCallback * @see AfterAllCallback */ -public class LettuceExtension implements ParameterResolver, AfterAllCallback, AfterEachCallback { +public class LettuceExtension extends RedisTestExtensionSupport + implements ParameterResolver, AfterAllCallback, AfterEachCallback { private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(LettuceExtension.class); @@ -113,7 +115,7 @@ public class LettuceExtension implements ParameterResolver, AfterAllCallback, Af .singletonList(RedisCommandsFunction.INSTANCE); @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { return SUPPORTED_INJECTABLE_TYPES.contains(parameterContext.getParameter().getType()); } @@ -121,23 +123,23 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon /** * Attempt to resolve the {@code requestedResourceType}. * - * @param extensionContext + * @param context * @param requestedResourceType * @param * @return */ - public T resolve(ExtensionContext extensionContext, Class requestedResourceType) { + public T resolve(ExtensionContext context, Class requestedResourceType) { - ExtensionContext.Store store = getStore(extensionContext); + ExtensionContext.Store store = getStore(context); return (T) store.getOrComputeIfAbsent(requestedResourceType, it -> findSupplier(requestedResourceType).get()); } @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException { - ExtensionContext.Store store = getStore(extensionContext); + ExtensionContext.Store store = getStore(context); Parameter parameter = parameterContext.getParameter(); Type parameterizedType = parameter.getParameterizedType(); @@ -200,8 +202,8 @@ private Object doGetInstance(Type parameterizedType) { .orElseGet(() -> findSupplier(parameterizedType).get()); } - private ExtensionContext.Store getStore(ExtensionContext extensionContext) { - return extensionContext.getStore(NAMESPACE); + private ExtensionContext.Store getStore(ExtensionContext context) { + return getSessionStore(context, NAMESPACE); } private static Optional findFunction(Type type) { diff --git a/src/test/java/org/springframework/data/redis/test/extension/RedisStanalone.java b/src/test/java/org/springframework/data/redis/test/extension/RedisStandalone.java similarity index 97% rename from src/test/java/org/springframework/data/redis/test/extension/RedisStanalone.java rename to src/test/java/org/springframework/data/redis/test/extension/RedisStandalone.java index e04679eb94..06a652fb12 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/RedisStanalone.java +++ b/src/test/java/org/springframework/data/redis/test/extension/RedisStandalone.java @@ -34,5 +34,5 @@ @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented -public @interface RedisStanalone { +public @interface RedisStandalone { } diff --git a/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java b/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java index f818e17e55..ca1debf4f7 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java +++ b/src/test/java/org/springframework/data/redis/test/extension/ShutdownQueue.java @@ -54,6 +54,10 @@ private static void close() { private final LinkedList closeables = new LinkedList<>(); + public static void register(ShutdownCloseable closeable) { + INSTANCE.closeables.add(closeable::close); + } + public static void register(Closeable closeable) { INSTANCE.closeables.add(closeable); } @@ -62,4 +66,9 @@ public static void register(AutoCloseable closeable) { INSTANCE.closeables.add(() -> IOUtils.closeQuietly(closeable)); } + public interface ShutdownCloseable { + + void close(); + } + } diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodArgumentsProvider.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodArgumentsProvider.java deleted file mode 100644 index 896192fc83..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodArgumentsProvider.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static java.lang.String.*; -import static org.junit.jupiter.params.provider.Arguments.*; - -import java.io.Closeable; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.stream.Stream; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ExtensionContext.Namespace; -import org.junit.jupiter.api.extension.ExtensionContext.Store; -import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.support.AnnotationConsumer; -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.CollectionUtils; -import org.junit.platform.commons.util.Preconditions; -import org.junit.platform.commons.util.ReflectionUtils; -import org.junit.platform.commons.util.StringUtils; -import org.springframework.data.redis.ConnectionFactoryTracker.Managed; - -/** - * Copy of {@code org.junit.jupiter.params.provider.MethodArgumentsProvider}. - */ -class MethodArgumentsProvider implements ArgumentsProvider, AnnotationConsumer { - - private static final Namespace NAMESPACE = Namespace.create(MethodArgumentsProvider.class); - - private String[] methodNames = new String[0]; - - @Override - public void accept(MethodSource annotation) { - this.methodNames = annotation.value(); - } - - @Override - public Stream provideArguments(ExtensionContext context) { - - Store store = context.getRoot().getStore(NAMESPACE); - Object testInstance = context.getTestInstance().orElse(null); - - return Arrays.stream(this.methodNames).map(factoryMethodName -> getMethod(context, factoryMethodName)) - .map(method -> (CloseablePararmeters) store.getOrComputeIfAbsent(new SourceKey(method, testInstance), - key -> new CloseablePararmeters(ReflectionUtils.invokeMethod(method, testInstance), context))) - .map(CloseablePararmeters::parameters).flatMap(CollectionUtils::toStream) - .map(MethodArgumentsProvider::toArguments); - } - - private Method getMethod(ExtensionContext context, String factoryMethodName) { - - if (StringUtils.isNotBlank(factoryMethodName)) { - if (factoryMethodName.contains("#")) { - return getMethodByFullyQualifiedName(factoryMethodName); - } else { - return ReflectionUtils.getRequiredMethod(context.getRequiredTestClass(), factoryMethodName); - } - } - return ReflectionUtils.getRequiredMethod(context.getRequiredTestClass(), context.getRequiredTestMethod().getName()); - } - - private Method getMethodByFullyQualifiedName(String fullyQualifiedMethodName) { - - String[] methodParts = ReflectionUtils.parseFullyQualifiedMethodName(fullyQualifiedMethodName); - String className = methodParts[0]; - String methodName = methodParts[1]; - String methodParameters = methodParts[2]; - - Preconditions.condition(StringUtils.isBlank(methodParameters), - () -> format("factory method [%s] must not declare formal parameters", fullyQualifiedMethodName)); - - return ReflectionUtils.getRequiredMethod(loadRequiredClass(className), methodName); - } - - private Class> loadRequiredClass(String className) { - return ReflectionUtils.tryToLoadClass(className) - .getOrThrow(cause -> new JUnitException(format("Could not load class [%s]", className), cause)); - } - - private static Arguments toArguments(Object item) { - - // Nothing to do except cast. - if (item instanceof Arguments arguments) { - return arguments; - } - - // Pass all multidimensional arrays "as is", in contrast to Object[]. - // See https://github.com/junit-team/junit5/issues/1665 - if (ReflectionUtils.isMultidimensionalArray(item)) { - return arguments(item); - } - - // Special treatment for one-dimensional reference arrays. - // See https://github.com/junit-team/junit5/issues/1665 - if (item instanceof Object[] array) { - return arguments(array); - } - - // Pass everything else "as is". - return arguments(item); - } - - /** - * Key type for a method associated with a test instance. - * - * @param method - * @param instance - */ - record SourceKey(Method method, Object instance) { - } - - /** - * Holder for parameters that can be closed using JUnit's built-in cleanup mechanism. - * - * @param parameters - * @param context - */ - record CloseablePararmeters(Object parameters, Object context) implements Store.CloseableResource { - - @Override - public void close() { - close0(parameters); - } - - private void close0(Object object) { - - if (object instanceof Managed) { - return; - } - - if (object instanceof CloseableResource closeableResource) { - try { - closeableResource.close(); - return; - } catch (Throwable cause) { - throw new RuntimeException(cause); - } - } - - if (object instanceof Closeable closeable) { - try { - closeable.close(); - return; - } catch (Throwable cause) { - throw new RuntimeException(cause); - } - } - - if (object instanceof Arguments arguments) { - close0(arguments.get()); - } - - if (object instanceof Object[] array) { - Arrays.asList(array).forEach(this::close0); - } - - if (object instanceof Iterable> iterableObject) { - iterableObject.forEach(this::close0); - } - } - } -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodSource.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodSource.java deleted file mode 100644 index 38e4477242..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/MethodSource.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.params.provider.ArgumentsSource; - -/** - * {@code @MethodSource} is an {@link ArgumentsSource} which provides access to values returned from - * {@linkplain #value() factory methods} of the class in which this annotation is declared or from static factory - * methods in external classes referenced by fully qualified method name. - * - * This variant can be used only on type level. - * - * Copy of {@code org.junit.jupiter.params.provider.MethodSource}. - */ -@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@ArgumentsSource(MethodArgumentsProvider.class) -public @interface MethodSource { - - /** - * The names of factory methods within the test class or in external classes to use as sources for arguments. - * - * Factory methods in external classes must be referenced by fully qualified method name — for example, - * {@code com.example.StringsProviders#blankStrings}. - * - * If no factory method names are declared, a method within the test class that has the same name as the test method - * will be used as the factory method by default. - * - * For further information, see the {@linkplain MethodSource class-level Javadoc}. - */ - String[] value() default ""; - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java deleted file mode 100644 index efdef385d3..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.TestTemplate; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ExtensionContext; - -/** - * {@code @ParameterizedRedisTest} is used to signal that the annotated method is a parameterized test method - * within a potentially parametrized test class. - * - * Such methods must not be {@code private} or {@code static}. - * Argument Providers and Sources - * - * Test classes defining {@code @ParameterizedRedisTest} methods must specify at least one - * {@link org.junit.jupiter.params.provider.ArgumentsProvider ArgumentsProvider} via - * {@link org.junit.jupiter.params.provider.ArgumentsSource @ArgumentsSource} or a corresponding composed annotation - * (e.g., {@code @ValueSource}, {@code @CsvSource}, etc.). The provider is responsible for providing a - * {@link java.util.stream.Stream Stream} of {@link org.junit.jupiter.params.provider.Arguments Arguments} that will be - * used to invoke the parameterized test method. - * Method Parameter List - * - * A {@code @ParameterizedRedisTest} method may declare parameters that are resolved from the class-level - * {@link org.junit.jupiter.params.provider.ArgumentsSource}. Additional parameters that exceed the parameter index by - * the class argument source can be resolved by additional {@link org.junit.jupiter.api.extension.ParameterResolver - * ParameterResolvers} (e.g., {@code TestInfo}, {@code TestReporter}, etc). Specifically, a parameterized test method - * must declare formal parameters according to the following rules. - * - * Zero or more indexed arguments must be declared first. - * Zero or more aggregators must be declared next. - * Zero or more arguments supplied by other {@code ParameterResolver} implementations must be declared last. - * - * - * In this context, an indexed argument is an argument for a given index in the {@code Arguments} provided by - * an {@code ArgumentsProvider} that is passed as an argument to the parameterized method at the same index in the - * method's formal parameter list. An aggregator is any parameter of type - * {@link org.junit.jupiter.params.aggregator.ArgumentsAccessor ArgumentsAccessor} or any parameter annotated with - * {@link org.junit.jupiter.params.aggregator.AggregateWith @AggregateWith}. - * - * Constructor Parameter List - * - * A class defining {@code @ParameterizedRedisTest} may declare a constructor accepting arguments. Constructor arguments - * are resolved from the same class-level {@link org.junit.jupiter.params.provider.ArgumentsSource} as method arguments. - * Therefore, constructor arguments follow the same index/aggregator semantics as method arguments. - * Test Class Lifecycle - * - * Using parameterized tests requires instance creation per test method ({@code TestInstance(PER_METHOD)} to ensure that - * both, test method and test instance share the same arguments. This limitation is driven by the execution tree as test - * argument sources are activated per test method. See - * {@link org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider#provideTestTemplateInvocationContexts(ExtensionContext)}. - * - * Adaption of {@code org.junit.jupiter.params.ParameterizedTest}. - */ -@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@TestTemplate -@ExtendWith(ParameterizedRedisTestExtension.class) -public @interface ParameterizedRedisTest { - - /** - * Placeholder for the {@linkplain org.junit.jupiter.api.TestInfo#getDisplayName display name} of a - * {@code @ParameterizedTest} method: {displayName} - * - * @see #name - */ - String DISPLAY_NAME_PLACEHOLDER = "{displayName}"; - - /** - * Placeholder for the current invocation index of a {@code @ParameterizedTest} method (1-based): {index} - * - * @see #name - */ - String INDEX_PLACEHOLDER = "{index}"; - - /** - * Placeholder for the complete, comma-separated arguments list of the current invocation of a - * {@code @ParameterizedTest} method: {arguments} - * - * @see #name - */ - String ARGUMENTS_PLACEHOLDER = "{arguments}"; - - /** - * Placeholder for the complete, comma-separated named arguments list of the current invocation of a - * {@code @ParameterizedTest} method: {argumentsWithNames} - * - * @see #name - */ - String ARGUMENTS_WITH_NAMES_PLACEHOLDER = "{argumentsWithNames}"; - - /** - * Default display name pattern for the current invocation of a {@code @ParameterizedTest} method: {@value} - * - * Note that the default pattern does not include the {@linkplain #DISPLAY_NAME_PLACEHOLDER display name} of - * the {@code @ParameterizedTest} method. - * - * @see #name - * @see #DISPLAY_NAME_PLACEHOLDER - * @see #INDEX_PLACEHOLDER - * @see #ARGUMENTS_WITH_NAMES_PLACEHOLDER - */ - String DEFAULT_DISPLAY_NAME = "[" + INDEX_PLACEHOLDER + "] " + ARGUMENTS_WITH_NAMES_PLACEHOLDER; - - /** - * The display name to be used for individual invocations of the parameterized test; never blank or consisting solely - * of whitespace. - * - * Defaults to {@link #DEFAULT_DISPLAY_NAME}. - * Supported placeholders - * - * {@link #DISPLAY_NAME_PLACEHOLDER} - * {@link #INDEX_PLACEHOLDER} - * {@link #ARGUMENTS_PLACEHOLDER} - * {0}, {1}, etc.: an individual argument (0-based) - * - * - * For the latter, you may use {@link java.text.MessageFormat} patterns to customize formatting. Please note that the - * original arguments are passed when formatting, regardless of any implicit or explicit argument conversions. - * - * @see java.text.MessageFormat - */ - String name() default DEFAULT_DISPLAY_NAME; - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java deleted file mode 100644 index 0e295527ed..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static org.junit.platform.commons.util.AnnotationUtils.*; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Stream; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ExtensionContext.Namespace; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; -import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.provider.ArgumentsSource; -import org.junit.jupiter.params.support.AnnotationConsumerInitializer; -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.ExceptionUtils; -import org.junit.platform.commons.util.Preconditions; -import org.junit.platform.commons.util.ReflectionUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestExtension}. - */ -class ParameterizedRedisTestExtension implements TestTemplateInvocationContextProvider { - - private static final String METHOD_CONTEXT_KEY = "method-context"; - private static final String CONSTRUCTOR_CONTEXT_KEY = "constructor-context"; - static final String ARGUMENT_MAX_LENGTH_KEY = "junit.jupiter.params.displayname.argument.maxlength"; - - @Override - public boolean supportsTestTemplate(ExtensionContext context) { - if (!context.getTestMethod().isPresent()) { - return false; - } - - Method testMethod = context.getTestMethod().get(); - if (!isAnnotated(testMethod, ParameterizedRedisTest.class)) { - return false; - } - - Constructor> declaredConstructor = ReflectionUtils.getDeclaredConstructor(context.getRequiredTestClass()); - ParameterizedTestContext methodContext = new ParameterizedTestContext(testMethod); - ParameterizedTestContext constructorContext = new ParameterizedTestContext(declaredConstructor); - - Preconditions.condition(methodContext.hasPotentiallyValidSignature(), () -> - ("@ParameterizedRedisTest method [%s] declares formal parameters in an invalid order: " - + "argument aggregators must be declared after any indexed arguments " - + "and before any arguments resolved by another ParameterResolver.") - .formatted(testMethod.toGenericString())); - - getStore(context).put(METHOD_CONTEXT_KEY, methodContext); - getStore(context).put(CONSTRUCTOR_CONTEXT_KEY, constructorContext); - - return true; - } - - @Override - public Stream provideTestTemplateInvocationContexts( - ExtensionContext extensionContext) { - - Method templateMethod = extensionContext.getRequiredTestMethod(); - String displayName = extensionContext.getDisplayName(); - ParameterizedTestContext methodContext = getStore(extensionContext)// - .get(METHOD_CONTEXT_KEY, ParameterizedTestContext.class); - - ParameterizedTestContext constructorContext = getStore(extensionContext)// - .get(CONSTRUCTOR_CONTEXT_KEY, ParameterizedTestContext.class); - int argumentMaxLength = extensionContext.getConfigurationParameter(ARGUMENT_MAX_LENGTH_KEY, Integer::parseInt) - .orElse(512); - ParameterizedTestNameFormatter formatter = createNameFormatter(templateMethod, methodContext, displayName, - argumentMaxLength); - AtomicLong invocationCount = new AtomicLong(0); - - List> hierarchy = new ArrayList<>(); - Class> type = extensionContext.getRequiredTestClass(); - while (type != Object.class) { - hierarchy.add(type); - type = type.getSuperclass(); - } - - // @formatter:off - return hierarchy.stream().flatMap(it -> findRepeatableAnnotations(it, ArgumentsSource.class).stream() - .map(ArgumentsSource::value).map(this::instantiateArgumentsProvider) - .map(provider -> AnnotationConsumerInitializer.initialize(it, provider))) - .flatMap(provider -> arguments(provider, extensionContext)).map(Arguments::get) - .map(arguments -> consumedArguments(arguments, methodContext)) - .map(arguments -> createInvocationContext(formatter, constructorContext, methodContext, arguments)) - .peek(invocationContext -> invocationCount.incrementAndGet()) - .onClose(() -> Preconditions.condition(invocationCount.get() > 0, - "Configuration error: You must configure at least one set of arguments for this @ParameterizedRedisTest class")); - // @formatter:on - } - - @SuppressWarnings("ConstantConditions") - private ArgumentsProvider instantiateArgumentsProvider(Class extends ArgumentsProvider> clazz) { - try { - return ReflectionUtils.newInstance(clazz); - } catch (Exception ex) { - if (ex instanceof NoSuchMethodException) { - throw new JUnitException(("Failed to find a no-argument constructor for ArgumentsProvider [%s];" - + " Please ensure that a no-argument constructor exists and that the class is either" - + " a top-level class or a static nested class").formatted(clazz.getName()), ex); - } - throw ex; - } - } - - private ExtensionContext.Store getStore(ExtensionContext context) { - return context.getStore(Namespace.create(ParameterizedRedisTestExtension.class, context.getRequiredTestMethod())); - } - - private TestTemplateInvocationContext createInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - return new ParameterizedTestInvocationContext(formatter, constructorContext, methodContext, arguments); - } - - private ParameterizedTestNameFormatter createNameFormatter(Method templateMethod, - ParameterizedTestContext methodContext, String displayName, int argumentMaxLength) { - - ParameterizedRedisTest parameterizedTest = findAnnotation(templateMethod, ParameterizedRedisTest.class).get(); - - String pattern = Preconditions.notBlank(parameterizedTest.name().trim(), () -> - "Configuration error: @ParameterizedRedisTest on method [%s] must be declared with a non-empty name" - .formatted(templateMethod)); - - return new ParameterizedTestNameFormatter(pattern, displayName, methodContext, argumentMaxLength); - } - - protected static Stream extends Arguments> arguments(ArgumentsProvider provider, ExtensionContext context) { - try { - return provider.provideArguments(context); - } catch (Exception ex) { - throw ExceptionUtils.throwAsUncheckedException(ex); - } - } - - private Object[] consumedArguments(Object[] arguments, ParameterizedTestContext methodContext) { - return arguments; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java deleted file mode 100644 index 6d1dd069f1..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static org.junit.platform.commons.util.AnnotationUtils.*; -import static org.springframework.data.redis.test.extension.parametrized.ParameterizedTestContext.ResolverType.*; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.params.aggregator.AggregateWith; -import org.junit.jupiter.params.aggregator.ArgumentsAccessor; -import org.junit.jupiter.params.aggregator.ArgumentsAggregator; -import org.junit.jupiter.params.aggregator.DefaultArgumentsAccessor; -import org.junit.jupiter.params.converter.ArgumentConverter; -import org.junit.jupiter.params.converter.ConvertWith; -import org.junit.jupiter.params.converter.DefaultArgumentConverter; -import org.junit.jupiter.params.support.AnnotationConsumerInitializer; -import org.junit.platform.commons.support.ReflectionSupport; -import org.junit.platform.commons.util.AnnotationUtils; -import org.junit.platform.commons.util.ReflectionUtils; -import org.junit.platform.commons.util.StringUtils; - -/** - * Encapsulates access to the parameters of a parameterized test method and caches the converters and aggregators used - * to resolve them. - * - * Copy of {@code org.junit.jupiter.params.ParameterizedTestContext}. - */ -class ParameterizedTestContext { - - private final Parameter[] parameters; - private final Resolver[] resolvers; - private final List resolverTypes; - - ParameterizedTestContext(Executable testMethod) { - this.parameters = testMethod.getParameters(); - this.resolvers = new Resolver[this.parameters.length]; - this.resolverTypes = new ArrayList<>(this.parameters.length); - for (Parameter parameter : this.parameters) { - this.resolverTypes.add(isAggregator(parameter) ? AGGREGATOR : CONVERTER); - } - } - - /** - * Determine if the supplied {@link Parameter} is an aggregator (i.e., of type {@link ArgumentsAccessor} or annotated - * with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - private static boolean isAggregator(Parameter parameter) { - return ArgumentsAccessor.class.isAssignableFrom(parameter.getType()) || isAnnotated(parameter, AggregateWith.class); - } - - /** - * Determine if the {@link Method} represented by this context has a potentially valid signature (i.e., - * formal parameter declarations) with regard to aggregators. - * - * This method takes a best-effort approach at enforcing the following policy for parameterized test methods that - * accept aggregators as arguments. - * - * zero or more indexed arguments come first. - * zero or more aggregators come next. - * zero or more arguments supplied by other {@code ParameterResolver} implementations come last. - * - * - * @return {@code true} if the method has a potentially valid signature - */ - boolean hasPotentiallyValidSignature() { - int indexOfPreviousAggregator = -1; - for (int i = 0; i < getParameterCount(); i++) { - if (isAggregator(i)) { - if ((indexOfPreviousAggregator != -1) && (i != indexOfPreviousAggregator + 1)) { - return false; - } - indexOfPreviousAggregator = i; - } - } - return true; - } - - /** - * Get the number of parameters of the {@link Method} represented by this context. - */ - int getParameterCount() { - return parameters.length; - } - - /** - * Get the name of the {@link Parameter} with the supplied index, if it is present and declared before the - * aggregators. - * - * @return an {@code Optional} containing the name of the parameter - */ - Optional getParameterName(int parameterIndex) { - if (parameterIndex >= getParameterCount()) { - return Optional.empty(); - } - Parameter parameter = this.parameters[parameterIndex]; - if (!parameter.isNamePresent()) { - return Optional.empty(); - } - if (hasAggregator() && parameterIndex >= indexOfFirstAggregator()) { - return Optional.empty(); - } - return Optional.of(parameter.getName()); - } - - /** - * Determine if the {@link Method} represented by this context declares at least one {@link Parameter} that is an - * {@linkplain #isAggregator aggregator}. - * - * @return {@code true} if the method has an aggregator - */ - boolean hasAggregator() { - return resolverTypes.contains(AGGREGATOR); - } - - /** - * Determine if the {@link Parameter} with the supplied index is an aggregator (i.e., of type - * {@link ArgumentsAccessor} or annotated with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - boolean isAggregator(int parameterIndex) { - return resolverTypes.size() > parameterIndex && resolverTypes.get(parameterIndex) == AGGREGATOR; - } - - /** - * Find the index of the first {@linkplain #isAggregator aggregator} {@link Parameter} in the {@link Method} - * represented by this context. - * - * @return the index of the first aggregator, or {@code -1} if not found - */ - int indexOfFirstAggregator() { - return resolverTypes.indexOf(AGGREGATOR); - } - - /** - * Resolve the parameter for the supplied context using the supplied arguments. - */ - Object resolve(ParameterContext parameterContext, Object[] arguments) { - return getResolver(parameterContext).resolve(parameterContext, arguments); - } - - private Resolver getResolver(ParameterContext parameterContext) { - int index = parameterContext.getIndex(); - if (resolvers[index] == null) { - resolvers[index] = resolverTypes.get(index).createResolver(parameterContext); - } - return resolvers[index]; - } - - enum ResolverType { - - CONVERTER { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), ConvertWith.class) - .map(ConvertWith::value).map(clazz -> (ArgumentConverter) ReflectionUtils.newInstance(clazz)) - .map(converter -> AnnotationConsumerInitializer.initialize(parameterContext.getParameter(), converter)) - .map(Converter::new).orElse(Converter.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentConverter", ex, parameterContext); - } - } - }, - - AGGREGATOR { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), AggregateWith.class) - .map(AggregateWith::value).map(clazz -> (ArgumentsAggregator) ReflectionSupport.newInstance(clazz)) - .map(Aggregator::new).orElse(Aggregator.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentsAggregator", ex, parameterContext); - } - } - }; - - abstract Resolver createResolver(ParameterContext parameterContext); - - } - - interface Resolver { - - Object resolve(ParameterContext parameterContext, Object[] arguments); - - } - - static class Converter implements Resolver { - - private static final Converter DEFAULT = new Converter(DefaultArgumentConverter.INSTANCE); - - private final ArgumentConverter argumentConverter; - - Converter(ArgumentConverter argumentConverter) { - this.argumentConverter = argumentConverter; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - Object argument = arguments[parameterContext.getIndex()]; - try { - return this.argumentConverter.convert(argument, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error converting parameter", ex, parameterContext); - } - } - - } - - static class Aggregator implements Resolver { - - private static final Aggregator DEFAULT = new Aggregator((accessor, context) -> accessor); - - private final ArgumentsAggregator argumentsAggregator; - - Aggregator(ArgumentsAggregator argumentsAggregator) { - this.argumentsAggregator = argumentsAggregator; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - ArgumentsAccessor accessor = new DefaultArgumentsAccessor(parameterContext, 1, arguments); - try { - return this.argumentsAggregator.aggregateArguments(accessor, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error aggregating arguments for parameter", ex, parameterContext); - } - } - - } - - private static ParameterResolutionException parameterResolutionException(String message, Exception cause, - ParameterContext parameterContext) { - String fullMessage = message + " at index " + parameterContext.getIndex(); - if (StringUtils.isNotBlank(cause.getMessage())) { - fullMessage += ": " + cause.getMessage(); - } - return new ParameterResolutionException(fullMessage, cause); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java deleted file mode 100644 index 658cd29b20..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.extension.Extension; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestInvocationContext}. - */ -class ParameterizedTestInvocationContext implements TestTemplateInvocationContext { - - private final ParameterizedTestNameFormatter formatter; - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - this.formatter = formatter; - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public String getDisplayName(int invocationIndex) { - return this.formatter.format(invocationIndex, this.arguments); - } - - @Override - public List getAdditionalExtensions() { - return Collections.singletonList( - new ParameterizedTestParameterResolver(this.constructorContext, this.methodContext, this.arguments)); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java deleted file mode 100644 index 7c02a0171f..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static java.util.stream.Collectors.joining; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_WITH_NAMES_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.DISPLAY_NAME_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.INDEX_PLACEHOLDER; - -import java.text.Format; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.stream.IntStream; - -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.StringUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestNameFormatter}. - */ -class ParameterizedTestNameFormatter { - - private static final char ELLIPSIS = '\u2026'; - - private final String pattern; - private final String displayName; - private final ParameterizedTestContext methodContext; - private final int argumentMaxLength; - - ParameterizedTestNameFormatter(String pattern, String displayName, ParameterizedTestContext methodContext, - int argumentMaxLength) { - this.pattern = pattern; - this.displayName = displayName; - this.methodContext = methodContext; - this.argumentMaxLength = argumentMaxLength; - } - - String format(int invocationIndex, Object... arguments) { - try { - return formatSafely(invocationIndex, arguments); - } catch (Exception ex) { - throw new JUnitException("The display name pattern defined for the parameterized test is invalid;" - + " See nested exception for further details.", ex); - } - } - - private String formatSafely(int invocationIndex, Object[] arguments) { - String pattern = prepareMessageFormatPattern(invocationIndex, arguments); - MessageFormat format = new MessageFormat(pattern); - Object[] humanReadableArguments = makeReadable(format, arguments); - return format.format(humanReadableArguments); - } - - private String prepareMessageFormatPattern(int invocationIndex, Object[] arguments) { - String result = pattern// - .replace(DISPLAY_NAME_PLACEHOLDER, this.displayName)// - .replace(INDEX_PLACEHOLDER, String.valueOf(invocationIndex)); - - if (result.contains(ARGUMENTS_WITH_NAMES_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_WITH_NAMES_PLACEHOLDER, argumentsWithNamesPattern(arguments)); - } - - if (result.contains(ARGUMENTS_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_PLACEHOLDER, argumentsPattern(arguments)); - } - - return result; - } - - private String argumentsWithNamesPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> methodContext.getParameterName(index).map(name -> name + "=").orElse("") + "{" + index + "}") // - .collect(joining(", ")); - } - - private String argumentsPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> "{" + index + "}") // - .collect(joining(", ")); - } - - private Object[] makeReadable(MessageFormat format, Object[] arguments) { - Format[] formats = format.getFormatsByArgumentIndex(); - Object[] result = Arrays.copyOf(arguments, Math.min(arguments.length, formats.length), Object[].class); - for (int i = 0; i < result.length; i++) { - if (formats[i] == null) { - result[i] = truncateIfExceedsMaxLength(StringUtils.nullSafeToString(arguments[i])); - } - } - return result; - } - - private String truncateIfExceedsMaxLength(String argument) { - if (argument.length() > argumentMaxLength) { - return argument.substring(0, argumentMaxLength - 1) + ELLIPSIS; - } - return argument; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java deleted file mode 100644 index adcff56f32..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.api.extension.ParameterResolver; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestParameterResolver}. - */ -class ParameterizedTestParameterResolver implements ParameterResolver { - - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestParameterResolver(ParameterizedTestContext constructorContext, - ParameterizedTestContext methodContext, Object[] arguments) { - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { - - Executable declaringExecutable = parameterContext.getDeclaringExecutable(); - int parameterIndex = parameterContext.getIndex(); - ParameterizedTestContext testContext; - - if (declaringExecutable instanceof Constructor) { - testContext = this.constructorContext; - } else { - - Method testMethod = extensionContext.getTestMethod().orElse(null); - - // Not a parameterized method? - if (parameterContext.getDeclaringExecutable() instanceof Method && !declaringExecutable.equals(testMethod)) { - return false; - } - testContext = this.methodContext; - } - - // Current parameter is an aggregator? - if (testContext.isAggregator(parameterIndex)) { - return true; - } - - // Ensure that the current parameter is declared before aggregators. - // Otherwise, a different ParameterResolver should handle it. - if (testContext.hasAggregator()) { - return parameterIndex < testContext.indexOfFirstAggregator(); - } - - // Else fallback to behavior for parameterized test methods without aggregators. - return parameterIndex < this.arguments.length; - } - - @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - - if (parameterContext.getDeclaringExecutable() instanceof Constructor) { - return this.constructorContext.resolve(parameterContext, this.arguments); - } - - return this.methodContext.resolve(parameterContext, this.arguments); - } - -}
- * This variant can be used only on type level. - *
- * Copy of {@code org.junit.jupiter.params.provider.MethodSource}. - */ -@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@ArgumentsSource(MethodArgumentsProvider.class) -public @interface MethodSource { - - /** - * The names of factory methods within the test class or in external classes to use as sources for arguments. - *
- * Factory methods in external classes must be referenced by fully qualified method name — for example, - * {@code com.example.StringsProviders#blankStrings}. - *
- * If no factory method names are declared, a method within the test class that has the same name as the test method - * will be used as the factory method by default. - *
- * For further information, see the {@linkplain MethodSource class-level Javadoc}. - */ - String[] value() default ""; - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java deleted file mode 100644 index efdef385d3..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.TestTemplate; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ExtensionContext; - -/** - * {@code @ParameterizedRedisTest} is used to signal that the annotated method is a parameterized test method - * within a potentially parametrized test class. - *
- * Such methods must not be {@code private} or {@code static}. - *
- * Test classes defining {@code @ParameterizedRedisTest} methods must specify at least one - * {@link org.junit.jupiter.params.provider.ArgumentsProvider ArgumentsProvider} via - * {@link org.junit.jupiter.params.provider.ArgumentsSource @ArgumentsSource} or a corresponding composed annotation - * (e.g., {@code @ValueSource}, {@code @CsvSource}, etc.). The provider is responsible for providing a - * {@link java.util.stream.Stream Stream} of {@link org.junit.jupiter.params.provider.Arguments Arguments} that will be - * used to invoke the parameterized test method. - *
- * A {@code @ParameterizedRedisTest} method may declare parameters that are resolved from the class-level - * {@link org.junit.jupiter.params.provider.ArgumentsSource}. Additional parameters that exceed the parameter index by - * the class argument source can be resolved by additional {@link org.junit.jupiter.api.extension.ParameterResolver - * ParameterResolvers} (e.g., {@code TestInfo}, {@code TestReporter}, etc). Specifically, a parameterized test method - * must declare formal parameters according to the following rules. - *
- * In this context, an indexed argument is an argument for a given index in the {@code Arguments} provided by - * an {@code ArgumentsProvider} that is passed as an argument to the parameterized method at the same index in the - * method's formal parameter list. An aggregator is any parameter of type - * {@link org.junit.jupiter.params.aggregator.ArgumentsAccessor ArgumentsAccessor} or any parameter annotated with - * {@link org.junit.jupiter.params.aggregator.AggregateWith @AggregateWith}. - *
- *
- * A class defining {@code @ParameterizedRedisTest} may declare a constructor accepting arguments. Constructor arguments - * are resolved from the same class-level {@link org.junit.jupiter.params.provider.ArgumentsSource} as method arguments. - * Therefore, constructor arguments follow the same index/aggregator semantics as method arguments. - *
- * Using parameterized tests requires instance creation per test method ({@code TestInstance(PER_METHOD)} to ensure that - * both, test method and test instance share the same arguments. This limitation is driven by the execution tree as test - * argument sources are activated per test method. See - * {@link org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider#provideTestTemplateInvocationContexts(ExtensionContext)}. - *
- * Adaption of {@code org.junit.jupiter.params.ParameterizedTest}. - */ -@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@TestTemplate -@ExtendWith(ParameterizedRedisTestExtension.class) -public @interface ParameterizedRedisTest { - - /** - * Placeholder for the {@linkplain org.junit.jupiter.api.TestInfo#getDisplayName display name} of a - * {@code @ParameterizedTest} method: {displayName} - * - * @see #name - */ - String DISPLAY_NAME_PLACEHOLDER = "{displayName}"; - - /** - * Placeholder for the current invocation index of a {@code @ParameterizedTest} method (1-based): {index} - * - * @see #name - */ - String INDEX_PLACEHOLDER = "{index}"; - - /** - * Placeholder for the complete, comma-separated arguments list of the current invocation of a - * {@code @ParameterizedTest} method: {arguments} - * - * @see #name - */ - String ARGUMENTS_PLACEHOLDER = "{arguments}"; - - /** - * Placeholder for the complete, comma-separated named arguments list of the current invocation of a - * {@code @ParameterizedTest} method: {argumentsWithNames} - * - * @see #name - */ - String ARGUMENTS_WITH_NAMES_PLACEHOLDER = "{argumentsWithNames}"; - - /** - * Default display name pattern for the current invocation of a {@code @ParameterizedTest} method: {@value} - *
{displayName}
{index}
{arguments}
{argumentsWithNames}
- * Note that the default pattern does not include the {@linkplain #DISPLAY_NAME_PLACEHOLDER display name} of - * the {@code @ParameterizedTest} method. - * - * @see #name - * @see #DISPLAY_NAME_PLACEHOLDER - * @see #INDEX_PLACEHOLDER - * @see #ARGUMENTS_WITH_NAMES_PLACEHOLDER - */ - String DEFAULT_DISPLAY_NAME = "[" + INDEX_PLACEHOLDER + "] " + ARGUMENTS_WITH_NAMES_PLACEHOLDER; - - /** - * The display name to be used for individual invocations of the parameterized test; never blank or consisting solely - * of whitespace. - *
- * Defaults to {@link #DEFAULT_DISPLAY_NAME}. - *
{0}
{1}
- * For the latter, you may use {@link java.text.MessageFormat} patterns to customize formatting. Please note that the - * original arguments are passed when formatting, regardless of any implicit or explicit argument conversions. - * - * @see java.text.MessageFormat - */ - String name() default DEFAULT_DISPLAY_NAME; - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java deleted file mode 100644 index 0e295527ed..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedRedisTestExtension.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static org.junit.platform.commons.util.AnnotationUtils.*; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Stream; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ExtensionContext.Namespace; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; -import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.provider.ArgumentsSource; -import org.junit.jupiter.params.support.AnnotationConsumerInitializer; -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.ExceptionUtils; -import org.junit.platform.commons.util.Preconditions; -import org.junit.platform.commons.util.ReflectionUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestExtension}. - */ -class ParameterizedRedisTestExtension implements TestTemplateInvocationContextProvider { - - private static final String METHOD_CONTEXT_KEY = "method-context"; - private static final String CONSTRUCTOR_CONTEXT_KEY = "constructor-context"; - static final String ARGUMENT_MAX_LENGTH_KEY = "junit.jupiter.params.displayname.argument.maxlength"; - - @Override - public boolean supportsTestTemplate(ExtensionContext context) { - if (!context.getTestMethod().isPresent()) { - return false; - } - - Method testMethod = context.getTestMethod().get(); - if (!isAnnotated(testMethod, ParameterizedRedisTest.class)) { - return false; - } - - Constructor> declaredConstructor = ReflectionUtils.getDeclaredConstructor(context.getRequiredTestClass()); - ParameterizedTestContext methodContext = new ParameterizedTestContext(testMethod); - ParameterizedTestContext constructorContext = new ParameterizedTestContext(declaredConstructor); - - Preconditions.condition(methodContext.hasPotentiallyValidSignature(), () -> - ("@ParameterizedRedisTest method [%s] declares formal parameters in an invalid order: " - + "argument aggregators must be declared after any indexed arguments " - + "and before any arguments resolved by another ParameterResolver.") - .formatted(testMethod.toGenericString())); - - getStore(context).put(METHOD_CONTEXT_KEY, methodContext); - getStore(context).put(CONSTRUCTOR_CONTEXT_KEY, constructorContext); - - return true; - } - - @Override - public Stream provideTestTemplateInvocationContexts( - ExtensionContext extensionContext) { - - Method templateMethod = extensionContext.getRequiredTestMethod(); - String displayName = extensionContext.getDisplayName(); - ParameterizedTestContext methodContext = getStore(extensionContext)// - .get(METHOD_CONTEXT_KEY, ParameterizedTestContext.class); - - ParameterizedTestContext constructorContext = getStore(extensionContext)// - .get(CONSTRUCTOR_CONTEXT_KEY, ParameterizedTestContext.class); - int argumentMaxLength = extensionContext.getConfigurationParameter(ARGUMENT_MAX_LENGTH_KEY, Integer::parseInt) - .orElse(512); - ParameterizedTestNameFormatter formatter = createNameFormatter(templateMethod, methodContext, displayName, - argumentMaxLength); - AtomicLong invocationCount = new AtomicLong(0); - - List> hierarchy = new ArrayList<>(); - Class> type = extensionContext.getRequiredTestClass(); - while (type != Object.class) { - hierarchy.add(type); - type = type.getSuperclass(); - } - - // @formatter:off - return hierarchy.stream().flatMap(it -> findRepeatableAnnotations(it, ArgumentsSource.class).stream() - .map(ArgumentsSource::value).map(this::instantiateArgumentsProvider) - .map(provider -> AnnotationConsumerInitializer.initialize(it, provider))) - .flatMap(provider -> arguments(provider, extensionContext)).map(Arguments::get) - .map(arguments -> consumedArguments(arguments, methodContext)) - .map(arguments -> createInvocationContext(formatter, constructorContext, methodContext, arguments)) - .peek(invocationContext -> invocationCount.incrementAndGet()) - .onClose(() -> Preconditions.condition(invocationCount.get() > 0, - "Configuration error: You must configure at least one set of arguments for this @ParameterizedRedisTest class")); - // @formatter:on - } - - @SuppressWarnings("ConstantConditions") - private ArgumentsProvider instantiateArgumentsProvider(Class extends ArgumentsProvider> clazz) { - try { - return ReflectionUtils.newInstance(clazz); - } catch (Exception ex) { - if (ex instanceof NoSuchMethodException) { - throw new JUnitException(("Failed to find a no-argument constructor for ArgumentsProvider [%s];" - + " Please ensure that a no-argument constructor exists and that the class is either" - + " a top-level class or a static nested class").formatted(clazz.getName()), ex); - } - throw ex; - } - } - - private ExtensionContext.Store getStore(ExtensionContext context) { - return context.getStore(Namespace.create(ParameterizedRedisTestExtension.class, context.getRequiredTestMethod())); - } - - private TestTemplateInvocationContext createInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - return new ParameterizedTestInvocationContext(formatter, constructorContext, methodContext, arguments); - } - - private ParameterizedTestNameFormatter createNameFormatter(Method templateMethod, - ParameterizedTestContext methodContext, String displayName, int argumentMaxLength) { - - ParameterizedRedisTest parameterizedTest = findAnnotation(templateMethod, ParameterizedRedisTest.class).get(); - - String pattern = Preconditions.notBlank(parameterizedTest.name().trim(), () -> - "Configuration error: @ParameterizedRedisTest on method [%s] must be declared with a non-empty name" - .formatted(templateMethod)); - - return new ParameterizedTestNameFormatter(pattern, displayName, methodContext, argumentMaxLength); - } - - protected static Stream extends Arguments> arguments(ArgumentsProvider provider, ExtensionContext context) { - try { - return provider.provideArguments(context); - } catch (Exception ex) { - throw ExceptionUtils.throwAsUncheckedException(ex); - } - } - - private Object[] consumedArguments(Object[] arguments, ParameterizedTestContext methodContext) { - return arguments; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java deleted file mode 100644 index 6d1dd069f1..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestContext.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static org.junit.platform.commons.util.AnnotationUtils.*; -import static org.springframework.data.redis.test.extension.parametrized.ParameterizedTestContext.ResolverType.*; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.params.aggregator.AggregateWith; -import org.junit.jupiter.params.aggregator.ArgumentsAccessor; -import org.junit.jupiter.params.aggregator.ArgumentsAggregator; -import org.junit.jupiter.params.aggregator.DefaultArgumentsAccessor; -import org.junit.jupiter.params.converter.ArgumentConverter; -import org.junit.jupiter.params.converter.ConvertWith; -import org.junit.jupiter.params.converter.DefaultArgumentConverter; -import org.junit.jupiter.params.support.AnnotationConsumerInitializer; -import org.junit.platform.commons.support.ReflectionSupport; -import org.junit.platform.commons.util.AnnotationUtils; -import org.junit.platform.commons.util.ReflectionUtils; -import org.junit.platform.commons.util.StringUtils; - -/** - * Encapsulates access to the parameters of a parameterized test method and caches the converters and aggregators used - * to resolve them. - * - * Copy of {@code org.junit.jupiter.params.ParameterizedTestContext}. - */ -class ParameterizedTestContext { - - private final Parameter[] parameters; - private final Resolver[] resolvers; - private final List resolverTypes; - - ParameterizedTestContext(Executable testMethod) { - this.parameters = testMethod.getParameters(); - this.resolvers = new Resolver[this.parameters.length]; - this.resolverTypes = new ArrayList<>(this.parameters.length); - for (Parameter parameter : this.parameters) { - this.resolverTypes.add(isAggregator(parameter) ? AGGREGATOR : CONVERTER); - } - } - - /** - * Determine if the supplied {@link Parameter} is an aggregator (i.e., of type {@link ArgumentsAccessor} or annotated - * with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - private static boolean isAggregator(Parameter parameter) { - return ArgumentsAccessor.class.isAssignableFrom(parameter.getType()) || isAnnotated(parameter, AggregateWith.class); - } - - /** - * Determine if the {@link Method} represented by this context has a potentially valid signature (i.e., - * formal parameter declarations) with regard to aggregators. - * - * This method takes a best-effort approach at enforcing the following policy for parameterized test methods that - * accept aggregators as arguments. - * - * zero or more indexed arguments come first. - * zero or more aggregators come next. - * zero or more arguments supplied by other {@code ParameterResolver} implementations come last. - * - * - * @return {@code true} if the method has a potentially valid signature - */ - boolean hasPotentiallyValidSignature() { - int indexOfPreviousAggregator = -1; - for (int i = 0; i < getParameterCount(); i++) { - if (isAggregator(i)) { - if ((indexOfPreviousAggregator != -1) && (i != indexOfPreviousAggregator + 1)) { - return false; - } - indexOfPreviousAggregator = i; - } - } - return true; - } - - /** - * Get the number of parameters of the {@link Method} represented by this context. - */ - int getParameterCount() { - return parameters.length; - } - - /** - * Get the name of the {@link Parameter} with the supplied index, if it is present and declared before the - * aggregators. - * - * @return an {@code Optional} containing the name of the parameter - */ - Optional getParameterName(int parameterIndex) { - if (parameterIndex >= getParameterCount()) { - return Optional.empty(); - } - Parameter parameter = this.parameters[parameterIndex]; - if (!parameter.isNamePresent()) { - return Optional.empty(); - } - if (hasAggregator() && parameterIndex >= indexOfFirstAggregator()) { - return Optional.empty(); - } - return Optional.of(parameter.getName()); - } - - /** - * Determine if the {@link Method} represented by this context declares at least one {@link Parameter} that is an - * {@linkplain #isAggregator aggregator}. - * - * @return {@code true} if the method has an aggregator - */ - boolean hasAggregator() { - return resolverTypes.contains(AGGREGATOR); - } - - /** - * Determine if the {@link Parameter} with the supplied index is an aggregator (i.e., of type - * {@link ArgumentsAccessor} or annotated with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - boolean isAggregator(int parameterIndex) { - return resolverTypes.size() > parameterIndex && resolverTypes.get(parameterIndex) == AGGREGATOR; - } - - /** - * Find the index of the first {@linkplain #isAggregator aggregator} {@link Parameter} in the {@link Method} - * represented by this context. - * - * @return the index of the first aggregator, or {@code -1} if not found - */ - int indexOfFirstAggregator() { - return resolverTypes.indexOf(AGGREGATOR); - } - - /** - * Resolve the parameter for the supplied context using the supplied arguments. - */ - Object resolve(ParameterContext parameterContext, Object[] arguments) { - return getResolver(parameterContext).resolve(parameterContext, arguments); - } - - private Resolver getResolver(ParameterContext parameterContext) { - int index = parameterContext.getIndex(); - if (resolvers[index] == null) { - resolvers[index] = resolverTypes.get(index).createResolver(parameterContext); - } - return resolvers[index]; - } - - enum ResolverType { - - CONVERTER { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), ConvertWith.class) - .map(ConvertWith::value).map(clazz -> (ArgumentConverter) ReflectionUtils.newInstance(clazz)) - .map(converter -> AnnotationConsumerInitializer.initialize(parameterContext.getParameter(), converter)) - .map(Converter::new).orElse(Converter.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentConverter", ex, parameterContext); - } - } - }, - - AGGREGATOR { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), AggregateWith.class) - .map(AggregateWith::value).map(clazz -> (ArgumentsAggregator) ReflectionSupport.newInstance(clazz)) - .map(Aggregator::new).orElse(Aggregator.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentsAggregator", ex, parameterContext); - } - } - }; - - abstract Resolver createResolver(ParameterContext parameterContext); - - } - - interface Resolver { - - Object resolve(ParameterContext parameterContext, Object[] arguments); - - } - - static class Converter implements Resolver { - - private static final Converter DEFAULT = new Converter(DefaultArgumentConverter.INSTANCE); - - private final ArgumentConverter argumentConverter; - - Converter(ArgumentConverter argumentConverter) { - this.argumentConverter = argumentConverter; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - Object argument = arguments[parameterContext.getIndex()]; - try { - return this.argumentConverter.convert(argument, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error converting parameter", ex, parameterContext); - } - } - - } - - static class Aggregator implements Resolver { - - private static final Aggregator DEFAULT = new Aggregator((accessor, context) -> accessor); - - private final ArgumentsAggregator argumentsAggregator; - - Aggregator(ArgumentsAggregator argumentsAggregator) { - this.argumentsAggregator = argumentsAggregator; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - ArgumentsAccessor accessor = new DefaultArgumentsAccessor(parameterContext, 1, arguments); - try { - return this.argumentsAggregator.aggregateArguments(accessor, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error aggregating arguments for parameter", ex, parameterContext); - } - } - - } - - private static ParameterResolutionException parameterResolutionException(String message, Exception cause, - ParameterContext parameterContext) { - String fullMessage = message + " at index " + parameterContext.getIndex(); - if (StringUtils.isNotBlank(cause.getMessage())) { - fullMessage += ": " + cause.getMessage(); - } - return new ParameterResolutionException(fullMessage, cause); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java deleted file mode 100644 index 658cd29b20..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.extension.Extension; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestInvocationContext}. - */ -class ParameterizedTestInvocationContext implements TestTemplateInvocationContext { - - private final ParameterizedTestNameFormatter formatter; - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - this.formatter = formatter; - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public String getDisplayName(int invocationIndex) { - return this.formatter.format(invocationIndex, this.arguments); - } - - @Override - public List getAdditionalExtensions() { - return Collections.singletonList( - new ParameterizedTestParameterResolver(this.constructorContext, this.methodContext, this.arguments)); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java deleted file mode 100644 index 7c02a0171f..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static java.util.stream.Collectors.joining; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_WITH_NAMES_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.DISPLAY_NAME_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.INDEX_PLACEHOLDER; - -import java.text.Format; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.stream.IntStream; - -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.StringUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestNameFormatter}. - */ -class ParameterizedTestNameFormatter { - - private static final char ELLIPSIS = '\u2026'; - - private final String pattern; - private final String displayName; - private final ParameterizedTestContext methodContext; - private final int argumentMaxLength; - - ParameterizedTestNameFormatter(String pattern, String displayName, ParameterizedTestContext methodContext, - int argumentMaxLength) { - this.pattern = pattern; - this.displayName = displayName; - this.methodContext = methodContext; - this.argumentMaxLength = argumentMaxLength; - } - - String format(int invocationIndex, Object... arguments) { - try { - return formatSafely(invocationIndex, arguments); - } catch (Exception ex) { - throw new JUnitException("The display name pattern defined for the parameterized test is invalid;" - + " See nested exception for further details.", ex); - } - } - - private String formatSafely(int invocationIndex, Object[] arguments) { - String pattern = prepareMessageFormatPattern(invocationIndex, arguments); - MessageFormat format = new MessageFormat(pattern); - Object[] humanReadableArguments = makeReadable(format, arguments); - return format.format(humanReadableArguments); - } - - private String prepareMessageFormatPattern(int invocationIndex, Object[] arguments) { - String result = pattern// - .replace(DISPLAY_NAME_PLACEHOLDER, this.displayName)// - .replace(INDEX_PLACEHOLDER, String.valueOf(invocationIndex)); - - if (result.contains(ARGUMENTS_WITH_NAMES_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_WITH_NAMES_PLACEHOLDER, argumentsWithNamesPattern(arguments)); - } - - if (result.contains(ARGUMENTS_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_PLACEHOLDER, argumentsPattern(arguments)); - } - - return result; - } - - private String argumentsWithNamesPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> methodContext.getParameterName(index).map(name -> name + "=").orElse("") + "{" + index + "}") // - .collect(joining(", ")); - } - - private String argumentsPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> "{" + index + "}") // - .collect(joining(", ")); - } - - private Object[] makeReadable(MessageFormat format, Object[] arguments) { - Format[] formats = format.getFormatsByArgumentIndex(); - Object[] result = Arrays.copyOf(arguments, Math.min(arguments.length, formats.length), Object[].class); - for (int i = 0; i < result.length; i++) { - if (formats[i] == null) { - result[i] = truncateIfExceedsMaxLength(StringUtils.nullSafeToString(arguments[i])); - } - } - return result; - } - - private String truncateIfExceedsMaxLength(String argument) { - if (argument.length() > argumentMaxLength) { - return argument.substring(0, argumentMaxLength - 1) + ELLIPSIS; - } - return argument; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java deleted file mode 100644 index adcff56f32..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.api.extension.ParameterResolver; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestParameterResolver}. - */ -class ParameterizedTestParameterResolver implements ParameterResolver { - - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestParameterResolver(ParameterizedTestContext constructorContext, - ParameterizedTestContext methodContext, Object[] arguments) { - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { - - Executable declaringExecutable = parameterContext.getDeclaringExecutable(); - int parameterIndex = parameterContext.getIndex(); - ParameterizedTestContext testContext; - - if (declaringExecutable instanceof Constructor) { - testContext = this.constructorContext; - } else { - - Method testMethod = extensionContext.getTestMethod().orElse(null); - - // Not a parameterized method? - if (parameterContext.getDeclaringExecutable() instanceof Method && !declaringExecutable.equals(testMethod)) { - return false; - } - testContext = this.methodContext; - } - - // Current parameter is an aggregator? - if (testContext.isAggregator(parameterIndex)) { - return true; - } - - // Ensure that the current parameter is declared before aggregators. - // Otherwise, a different ParameterResolver should handle it. - if (testContext.hasAggregator()) { - return parameterIndex < testContext.indexOfFirstAggregator(); - } - - // Else fallback to behavior for parameterized test methods without aggregators. - return parameterIndex < this.arguments.length; - } - - @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - - if (parameterContext.getDeclaringExecutable() instanceof Constructor) { - return this.constructorContext.resolve(parameterContext, this.arguments); - } - - return this.methodContext.resolve(parameterContext, this.arguments); - } - -}
- * Copy of {@code org.junit.jupiter.params.ParameterizedTestContext}. - */ -class ParameterizedTestContext { - - private final Parameter[] parameters; - private final Resolver[] resolvers; - private final List resolverTypes; - - ParameterizedTestContext(Executable testMethod) { - this.parameters = testMethod.getParameters(); - this.resolvers = new Resolver[this.parameters.length]; - this.resolverTypes = new ArrayList<>(this.parameters.length); - for (Parameter parameter : this.parameters) { - this.resolverTypes.add(isAggregator(parameter) ? AGGREGATOR : CONVERTER); - } - } - - /** - * Determine if the supplied {@link Parameter} is an aggregator (i.e., of type {@link ArgumentsAccessor} or annotated - * with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - private static boolean isAggregator(Parameter parameter) { - return ArgumentsAccessor.class.isAssignableFrom(parameter.getType()) || isAnnotated(parameter, AggregateWith.class); - } - - /** - * Determine if the {@link Method} represented by this context has a potentially valid signature (i.e., - * formal parameter declarations) with regard to aggregators. - * - * This method takes a best-effort approach at enforcing the following policy for parameterized test methods that - * accept aggregators as arguments. - * - * zero or more indexed arguments come first. - * zero or more aggregators come next. - * zero or more arguments supplied by other {@code ParameterResolver} implementations come last. - * - * - * @return {@code true} if the method has a potentially valid signature - */ - boolean hasPotentiallyValidSignature() { - int indexOfPreviousAggregator = -1; - for (int i = 0; i < getParameterCount(); i++) { - if (isAggregator(i)) { - if ((indexOfPreviousAggregator != -1) && (i != indexOfPreviousAggregator + 1)) { - return false; - } - indexOfPreviousAggregator = i; - } - } - return true; - } - - /** - * Get the number of parameters of the {@link Method} represented by this context. - */ - int getParameterCount() { - return parameters.length; - } - - /** - * Get the name of the {@link Parameter} with the supplied index, if it is present and declared before the - * aggregators. - * - * @return an {@code Optional} containing the name of the parameter - */ - Optional getParameterName(int parameterIndex) { - if (parameterIndex >= getParameterCount()) { - return Optional.empty(); - } - Parameter parameter = this.parameters[parameterIndex]; - if (!parameter.isNamePresent()) { - return Optional.empty(); - } - if (hasAggregator() && parameterIndex >= indexOfFirstAggregator()) { - return Optional.empty(); - } - return Optional.of(parameter.getName()); - } - - /** - * Determine if the {@link Method} represented by this context declares at least one {@link Parameter} that is an - * {@linkplain #isAggregator aggregator}. - * - * @return {@code true} if the method has an aggregator - */ - boolean hasAggregator() { - return resolverTypes.contains(AGGREGATOR); - } - - /** - * Determine if the {@link Parameter} with the supplied index is an aggregator (i.e., of type - * {@link ArgumentsAccessor} or annotated with {@link AggregateWith}). - * - * @return {@code true} if the parameter is an aggregator - */ - boolean isAggregator(int parameterIndex) { - return resolverTypes.size() > parameterIndex && resolverTypes.get(parameterIndex) == AGGREGATOR; - } - - /** - * Find the index of the first {@linkplain #isAggregator aggregator} {@link Parameter} in the {@link Method} - * represented by this context. - * - * @return the index of the first aggregator, or {@code -1} if not found - */ - int indexOfFirstAggregator() { - return resolverTypes.indexOf(AGGREGATOR); - } - - /** - * Resolve the parameter for the supplied context using the supplied arguments. - */ - Object resolve(ParameterContext parameterContext, Object[] arguments) { - return getResolver(parameterContext).resolve(parameterContext, arguments); - } - - private Resolver getResolver(ParameterContext parameterContext) { - int index = parameterContext.getIndex(); - if (resolvers[index] == null) { - resolvers[index] = resolverTypes.get(index).createResolver(parameterContext); - } - return resolvers[index]; - } - - enum ResolverType { - - CONVERTER { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), ConvertWith.class) - .map(ConvertWith::value).map(clazz -> (ArgumentConverter) ReflectionUtils.newInstance(clazz)) - .map(converter -> AnnotationConsumerInitializer.initialize(parameterContext.getParameter(), converter)) - .map(Converter::new).orElse(Converter.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentConverter", ex, parameterContext); - } - } - }, - - AGGREGATOR { - @Override - Resolver createResolver(ParameterContext parameterContext) { - try { // @formatter:off - return AnnotationUtils.findAnnotation(parameterContext.getParameter(), AggregateWith.class) - .map(AggregateWith::value).map(clazz -> (ArgumentsAggregator) ReflectionSupport.newInstance(clazz)) - .map(Aggregator::new).orElse(Aggregator.DEFAULT); - } // @formatter:on - catch (Exception ex) { - throw parameterResolutionException("Error creating ArgumentsAggregator", ex, parameterContext); - } - } - }; - - abstract Resolver createResolver(ParameterContext parameterContext); - - } - - interface Resolver { - - Object resolve(ParameterContext parameterContext, Object[] arguments); - - } - - static class Converter implements Resolver { - - private static final Converter DEFAULT = new Converter(DefaultArgumentConverter.INSTANCE); - - private final ArgumentConverter argumentConverter; - - Converter(ArgumentConverter argumentConverter) { - this.argumentConverter = argumentConverter; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - Object argument = arguments[parameterContext.getIndex()]; - try { - return this.argumentConverter.convert(argument, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error converting parameter", ex, parameterContext); - } - } - - } - - static class Aggregator implements Resolver { - - private static final Aggregator DEFAULT = new Aggregator((accessor, context) -> accessor); - - private final ArgumentsAggregator argumentsAggregator; - - Aggregator(ArgumentsAggregator argumentsAggregator) { - this.argumentsAggregator = argumentsAggregator; - } - - @Override - public Object resolve(ParameterContext parameterContext, Object[] arguments) { - ArgumentsAccessor accessor = new DefaultArgumentsAccessor(parameterContext, 1, arguments); - try { - return this.argumentsAggregator.aggregateArguments(accessor, parameterContext); - } catch (Exception ex) { - throw parameterResolutionException("Error aggregating arguments for parameter", ex, parameterContext); - } - } - - } - - private static ParameterResolutionException parameterResolutionException(String message, Exception cause, - ParameterContext parameterContext) { - String fullMessage = message + " at index " + parameterContext.getIndex(); - if (StringUtils.isNotBlank(cause.getMessage())) { - fullMessage += ": " + cause.getMessage(); - } - return new ParameterResolutionException(fullMessage, cause); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java deleted file mode 100644 index 658cd29b20..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestInvocationContext.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.util.Collections; -import java.util.List; - -import org.junit.jupiter.api.extension.Extension; -import org.junit.jupiter.api.extension.TestTemplateInvocationContext; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestInvocationContext}. - */ -class ParameterizedTestInvocationContext implements TestTemplateInvocationContext { - - private final ParameterizedTestNameFormatter formatter; - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestInvocationContext(ParameterizedTestNameFormatter formatter, - ParameterizedTestContext constructorContext, ParameterizedTestContext methodContext, Object[] arguments) { - this.formatter = formatter; - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public String getDisplayName(int invocationIndex) { - return this.formatter.format(invocationIndex, this.arguments); - } - - @Override - public List getAdditionalExtensions() { - return Collections.singletonList( - new ParameterizedTestParameterResolver(this.constructorContext, this.methodContext, this.arguments)); - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java deleted file mode 100644 index 7c02a0171f..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestNameFormatter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import static java.util.stream.Collectors.joining; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.ARGUMENTS_WITH_NAMES_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.DISPLAY_NAME_PLACEHOLDER; -import static org.junit.jupiter.params.ParameterizedTest.INDEX_PLACEHOLDER; - -import java.text.Format; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.stream.IntStream; - -import org.junit.platform.commons.JUnitException; -import org.junit.platform.commons.util.StringUtils; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestNameFormatter}. - */ -class ParameterizedTestNameFormatter { - - private static final char ELLIPSIS = '\u2026'; - - private final String pattern; - private final String displayName; - private final ParameterizedTestContext methodContext; - private final int argumentMaxLength; - - ParameterizedTestNameFormatter(String pattern, String displayName, ParameterizedTestContext methodContext, - int argumentMaxLength) { - this.pattern = pattern; - this.displayName = displayName; - this.methodContext = methodContext; - this.argumentMaxLength = argumentMaxLength; - } - - String format(int invocationIndex, Object... arguments) { - try { - return formatSafely(invocationIndex, arguments); - } catch (Exception ex) { - throw new JUnitException("The display name pattern defined for the parameterized test is invalid;" - + " See nested exception for further details.", ex); - } - } - - private String formatSafely(int invocationIndex, Object[] arguments) { - String pattern = prepareMessageFormatPattern(invocationIndex, arguments); - MessageFormat format = new MessageFormat(pattern); - Object[] humanReadableArguments = makeReadable(format, arguments); - return format.format(humanReadableArguments); - } - - private String prepareMessageFormatPattern(int invocationIndex, Object[] arguments) { - String result = pattern// - .replace(DISPLAY_NAME_PLACEHOLDER, this.displayName)// - .replace(INDEX_PLACEHOLDER, String.valueOf(invocationIndex)); - - if (result.contains(ARGUMENTS_WITH_NAMES_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_WITH_NAMES_PLACEHOLDER, argumentsWithNamesPattern(arguments)); - } - - if (result.contains(ARGUMENTS_PLACEHOLDER)) { - result = result.replace(ARGUMENTS_PLACEHOLDER, argumentsPattern(arguments)); - } - - return result; - } - - private String argumentsWithNamesPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> methodContext.getParameterName(index).map(name -> name + "=").orElse("") + "{" + index + "}") // - .collect(joining(", ")); - } - - private String argumentsPattern(Object[] arguments) { - return IntStream.range(0, arguments.length) // - .mapToObj(index -> "{" + index + "}") // - .collect(joining(", ")); - } - - private Object[] makeReadable(MessageFormat format, Object[] arguments) { - Format[] formats = format.getFormatsByArgumentIndex(); - Object[] result = Arrays.copyOf(arguments, Math.min(arguments.length, formats.length), Object[].class); - for (int i = 0; i < result.length; i++) { - if (formats[i] == null) { - result[i] = truncateIfExceedsMaxLength(StringUtils.nullSafeToString(arguments[i])); - } - } - return result; - } - - private String truncateIfExceedsMaxLength(String argument) { - if (argument.length() > argumentMaxLength) { - return argument.substring(0, argumentMaxLength - 1) + ELLIPSIS; - } - return argument; - } - -} diff --git a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java b/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java deleted file mode 100644 index adcff56f32..0000000000 --- a/src/test/java/org/springframework/data/redis/test/extension/parametrized/ParameterizedTestParameterResolver.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2020-2025 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.redis.test.extension.parametrized; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; - -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.api.extension.ParameterContext; -import org.junit.jupiter.api.extension.ParameterResolutionException; -import org.junit.jupiter.api.extension.ParameterResolver; - -/** - * Copy of {@code org.junit.jupiter.params.ParameterizedTestParameterResolver}. - */ -class ParameterizedTestParameterResolver implements ParameterResolver { - - private final ParameterizedTestContext constructorContext; - private final ParameterizedTestContext methodContext; - private final Object[] arguments; - - ParameterizedTestParameterResolver(ParameterizedTestContext constructorContext, - ParameterizedTestContext methodContext, Object[] arguments) { - this.constructorContext = constructorContext; - this.methodContext = methodContext; - this.arguments = arguments; - } - - @Override - public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { - - Executable declaringExecutable = parameterContext.getDeclaringExecutable(); - int parameterIndex = parameterContext.getIndex(); - ParameterizedTestContext testContext; - - if (declaringExecutable instanceof Constructor) { - testContext = this.constructorContext; - } else { - - Method testMethod = extensionContext.getTestMethod().orElse(null); - - // Not a parameterized method? - if (parameterContext.getDeclaringExecutable() instanceof Method && !declaringExecutable.equals(testMethod)) { - return false; - } - testContext = this.methodContext; - } - - // Current parameter is an aggregator? - if (testContext.isAggregator(parameterIndex)) { - return true; - } - - // Ensure that the current parameter is declared before aggregators. - // Otherwise, a different ParameterResolver should handle it. - if (testContext.hasAggregator()) { - return parameterIndex < testContext.indexOfFirstAggregator(); - } - - // Else fallback to behavior for parameterized test methods without aggregators. - return parameterIndex < this.arguments.length; - } - - @Override - public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) - throws ParameterResolutionException { - - if (parameterContext.getDeclaringExecutable() instanceof Constructor) { - return this.constructorContext.resolve(parameterContext, this.arguments); - } - - return this.methodContext.resolve(parameterContext, this.arguments); - } - -}
- * This method takes a best-effort approach at enforcing the following policy for parameterized test methods that - * accept aggregators as arguments. - *