diff --git a/src/test/java/com/lambdaworks/redis/ClientTest.java b/src/test/java/com/lambdaworks/redis/ClientTest.java index b628e40519..08bb0816c4 100644 --- a/src/test/java/com/lambdaworks/redis/ClientTest.java +++ b/src/test/java/com/lambdaworks/redis/ClientTest.java @@ -353,14 +353,10 @@ public void listenerTestWithRemoval() throws Exception { client.addListener(retainedListener); client.removeListener(removedListener); - RedisAsyncConnection connection = client.connectAsync(); - waitOrTimeout(new Condition() { + // that's the sut call + client.connectAsync(); - @Override - public boolean isSatisfied() { - return retainedListener.onConnected != null; - } - }, Timeout.timeout(seconds(2))); + waitOrTimeout(() -> retainedListener.onConnected != null, Timeout.timeout(seconds(2))); assertThat(retainedListener.onConnected).isNotNull(); diff --git a/src/test/java/com/lambdaworks/redis/ReactiveConnectionTest.java b/src/test/java/com/lambdaworks/redis/ReactiveConnectionTest.java index 196f442fda..bab16d1f06 100644 --- a/src/test/java/com/lambdaworks/redis/ReactiveConnectionTest.java +++ b/src/test/java/com/lambdaworks/redis/ReactiveConnectionTest.java @@ -6,6 +6,8 @@ import java.util.List; +import com.google.code.tempusfugit.temporal.WaitFor; +import com.lambdaworks.Wait; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -41,10 +43,10 @@ public void closeReactiveConnection() throws Exception { @Test public void doNotFireCommandUntilObservation() throws Exception { Observable set = reactive.set(key, value); - Delay.delay(seconds(1)); + Delay.delay(millis(200)); assertThat(redis.get(key)).isNull(); set.subscribe(); - Delay.delay(seconds(1)); + Wait.untilEquals(value, () -> redis.get(key)); assertThat(redis.get(key)).isEqualTo(value); } @@ -107,7 +109,7 @@ public void multiSubscribe() throws Exception { incr.subscribe(); incr.subscribe(); - Delay.delay(millis(500)); + Wait.untilEquals("4", () -> redis.get(key)); assertThat(redis.get(key)).isEqualTo("4"); } diff --git a/src/test/java/com/lambdaworks/redis/RedisClientFactoryBeanTest.java b/src/test/java/com/lambdaworks/redis/RedisClientFactoryBeanTest.java index 6fd4bde4a2..c8728f8b82 100644 --- a/src/test/java/com/lambdaworks/redis/RedisClientFactoryBeanTest.java +++ b/src/test/java/com/lambdaworks/redis/RedisClientFactoryBeanTest.java @@ -13,16 +13,9 @@ public class RedisClientFactoryBeanTest { private RedisClientFactoryBean sut = new RedisClientFactoryBean(); - /* - * This Test should not trigger a connection. - */ - @Before - public void before() throws Exception { - sut.setSingleton(false); - } - @After public void tearDown() throws Exception { + FastShutdown.shutdown(sut.getObject()); sut.destroy(); } @@ -40,7 +33,6 @@ public void testSimpleUri() throws Exception { assertThat(redisURI.getHost()).isEqualTo("localhost"); assertThat(redisURI.getPort()).isEqualTo(RedisURI.DEFAULT_REDIS_PORT); assertThat(new String(redisURI.getPassword())).isEqualTo("password"); - } @Test @@ -53,7 +45,6 @@ public void testSimpleUriWithoutDB() throws Exception { RedisURI redisURI = sut.getRedisURI(); assertThat(redisURI.getDatabase()).isEqualTo(0); - } @Test @@ -66,7 +57,6 @@ public void testSimpleUriWithoutDB2() throws Exception { RedisURI redisURI = sut.getRedisURI(); assertThat(redisURI.getDatabase()).isEqualTo(0); - } @Test diff --git a/src/test/java/com/lambdaworks/redis/commands/ServerCommandTest.java b/src/test/java/com/lambdaworks/redis/commands/ServerCommandTest.java index 45aa80fd97..52aa5fbeb3 100644 --- a/src/test/java/com/lambdaworks/redis/commands/ServerCommandTest.java +++ b/src/test/java/com/lambdaworks/redis/commands/ServerCommandTest.java @@ -53,7 +53,7 @@ public void clientGetSetname() throws Exception { @Test public void clientPause() throws Exception { - assertThat(redis.clientPause(1000)).isEqualTo("OK"); + assertThat(redis.clientPause(10)).isEqualTo("OK"); } @Test diff --git a/src/test/java/com/lambdaworks/redis/support/RedisClusterClientFactoryBeanTest.java b/src/test/java/com/lambdaworks/redis/support/RedisClusterClientFactoryBeanTest.java index 299ee6935a..be4ddd929e 100644 --- a/src/test/java/com/lambdaworks/redis/support/RedisClusterClientFactoryBeanTest.java +++ b/src/test/java/com/lambdaworks/redis/support/RedisClusterClientFactoryBeanTest.java @@ -1,11 +1,13 @@ package com.lambdaworks.redis.support; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; import java.net.URI; +import org.junit.After; import org.junit.Test; +import com.lambdaworks.redis.FastShutdown; import com.lambdaworks.redis.RedisURI; /** @@ -36,6 +38,8 @@ public void validUri() throws Exception { sut.afterPropertiesSet(); assertThat(sut.getRedisURI().getHost()).isEqualTo("host"); assertThat(sut.getRedisURI().getPassword()).isEqualTo("password".toCharArray()); + + FastShutdown.shutdown(sut.getObject()); } @Test @@ -47,5 +51,7 @@ public void validUriPasswordOverride() throws Exception { sut.afterPropertiesSet(); assertThat(sut.getRedisURI().getHost()).isEqualTo("host"); assertThat(sut.getRedisURI().getPassword()).isEqualTo("thepassword".toCharArray()); + + FastShutdown.shutdown(sut.getObject()); } -} \ No newline at end of file +}