Skip to content

Commit 93e6828

Browse files
committed
Fix RedisAvailableRule
Prior to this commit, `RedisAvailableRule.apply()` threw an `AssumptionViolatedException` when Redis was unavailable. That caused the execution of the current test class and all pending test methods to be stopped immediately. Instead, it now returns a `Statement` that throws the exception in case Redis us unavailable which will only skip the current test. Resolves #2782.
1 parent 78199dc commit 93e6828

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,21 +69,24 @@ public static void cleanUpConnectionFactoryIfAny() {
6969

7070

7171
public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
72-
RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class);
73-
if (redisAvailable != null) {
74-
if (connectionFactory != null) {
75-
try {
76-
connectionFactory.getConnection();
77-
}
78-
catch (Exception e) {
79-
Assume.assumeTrue("Skipping test due to Redis not being available on port: " + REDIS_PORT + ": " + e, false);
80-
72+
return new Statement(){
73+
@Override
74+
public void evaluate() throws Throwable {
75+
RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class);
76+
if (redisAvailable != null) {
77+
if (connectionFactory != null) {
78+
try {
79+
connectionFactory.getConnection();
80+
base.evaluate();
81+
}
82+
catch (Exception e) {
83+
Assume.assumeTrue("Skipping test due to Redis not being available on port: " + REDIS_PORT + ": " + e, false);
84+
85+
}
86+
}
8187
}
8288
}
83-
}
84-
85-
return base;
89+
};
8690
}
8791

8892
}
89-

0 commit comments

Comments
 (0)