Skip to content

Use JUnit 5.13 @ParametrizedClass #3175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-GH-3167-SNAPSHOT</version>

<name>Spring Data Redis</name>
<description>Spring Data module for Redis</description>
Expand All @@ -28,7 +28,6 @@
<multithreadedtc>1.01</multithreadedtc>
<netty>4.1.121.Final</netty>
<java-module-name>spring.data.redis</java-module-name>
<junit5>5.12.2</junit5>
</properties>

<scm>
Expand Down Expand Up @@ -154,6 +153,12 @@
<artifactId>commons-beanutils</artifactId>
<version>${beanutils}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Pool -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -55,12 +55,12 @@ private static Collection<RedisConnectionFactory> 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand All @@ -53,6 +54,7 @@
* @author Mark Paluch
* @author ChanYoung Joung
*/
@ParameterizedClass
@MethodSource("testParams")
public class DefaultRedisCacheWriterTests {

Expand All @@ -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)
Expand All @@ -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,
Expand All @@ -108,7 +111,7 @@ void putShouldAddExpiringEntry() {
});
}

@ParameterizedRedisTest // DATAREDIS-481
@Test // DATAREDIS-481
void putShouldOverwriteExistingEternalEntry() {

doWithConnection(connection -> connection.set(binaryCacheKey, "foo".getBytes()));
Expand All @@ -121,7 +124,7 @@ void putShouldOverwriteExistingEternalEntry() {
});
}

@ParameterizedRedisTest // DATAREDIS-481
@Test // DATAREDIS-481
void putShouldOverwriteExistingExpiringEntryAndResetTtl() {

doWithConnection(connection -> connection.set(binaryCacheKey, "foo".getBytes(),
Expand All @@ -136,7 +139,7 @@ void putShouldOverwriteExistingExpiringEntryAndResetTtl() {
});
}

@ParameterizedRedisTest // DATAREDIS-481, DATAREDIS-1082
@Test // DATAREDIS-481, DATAREDIS-1082
void getShouldReturnValue() {

doWithConnection(connection -> connection.set(binaryCacheKey, binaryCacheValue));
Expand All @@ -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 {

Expand All @@ -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 {

Expand All @@ -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 {

Expand All @@ -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)
Expand All @@ -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));
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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));
Expand All @@ -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 -> {
Expand All @@ -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);
Expand All @@ -307,7 +310,7 @@ void nonLockingCacheWriterShouldIgnoreExistingLock() {
});
}

@ParameterizedRedisTest // DATAREDIS-481
@Test // DATAREDIS-481
void lockingCacheWriterShouldIgnoreExistingLockOnDifferenceCache() {

((DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory)).lock(CACHE_NAME);
Expand All @@ -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)
Expand Down Expand Up @@ -362,7 +365,7 @@ void lockingCacheWriterShouldWaitForLockRelease() throws InterruptedException {
}
}

@ParameterizedRedisTest // DATAREDIS-481
@Test // DATAREDIS-481
void lockingCacheWriterShouldExitWhenInterruptedWaitForLockRelease() throws InterruptedException {

DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory);
Expand Down Expand Up @@ -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,
Expand All @@ -417,7 +420,7 @@ void lockingCacheWriterShouldUsePersistentLocks() {
});
}

@ParameterizedRedisTest // GH-2300
@Test // GH-2300
void lockingCacheWriterShouldApplyLockTtl() {

DefaultRedisCacheWriter writer = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory,
Expand All @@ -431,7 +434,7 @@ void lockingCacheWriterShouldApplyLockTtl() {
});
}

@ParameterizedRedisTest // DATAREDIS-1082
@Test // DATAREDIS-1082
void noOpStatisticsCollectorReturnsEmptyStatsInstance() {

DefaultRedisCacheWriter cw = (DefaultRedisCacheWriter) lockingRedisCacheWriter(connectionFactory);
Expand All @@ -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 {

Expand Down
Loading