From 8ec4ab0355a88eb59a3c27d1e95342d8f686b9bc Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 10 Dec 2014 12:49:33 +0200 Subject: [PATCH] INT-3576: Fix NPE in the `RedisAvailableTests` JIRA: https://jira.spring.io/browse/INT-3576 --- .../redis/rules/RedisAvailableTests.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java index 2f8b6dcd59..03b32c02e9 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableTests.java @@ -13,8 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.redis.rules; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Rule; @@ -50,10 +52,17 @@ public class RedisAvailableTests { } protected void awaitContainerSubscribed(RedisMessageListenerContainer container) throws Exception { - RedisConnection connection = TestUtils.getPropertyValue(container, "subscriptionTask.connection", - RedisConnection.class); + RedisConnection connection = null; int n = 0; + while (n++ < 100 && + (connection = + TestUtils.getPropertyValue(container, "subscriptionTask.connection", RedisConnection .class)) == null) { + Thread.sleep(100); + } + assertNotNull("RedisMessageListenerContainer Failed to Connect", connection); + + n = 0; while (n++ < 100 && !connection.isSubscribed()) { Thread.sleep(100); }