Skip to content

Commit

Permalink
Improve test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Sep 22, 2015
1 parent cfe525d commit c7f36f8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
10 changes: 3 additions & 7 deletions src/test/java/com/lambdaworks/redis/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,10 @@ public void listenerTestWithRemoval() throws Exception {
client.addListener(retainedListener);
client.removeListener(removedListener);

RedisAsyncConnection<String, String> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,10 +43,10 @@ public void closeReactiveConnection() throws Exception {
@Test
public void doNotFireCommandUntilObservation() throws Exception {
Observable<String> 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);
}
Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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
Expand All @@ -53,7 +45,6 @@ public void testSimpleUriWithoutDB() throws Exception {
RedisURI redisURI = sut.getRedisURI();

assertThat(redisURI.getDatabase()).isEqualTo(0);

}

@Test
Expand All @@ -66,7 +57,6 @@ public void testSimpleUriWithoutDB2() throws Exception {
RedisURI redisURI = sut.getRedisURI();

assertThat(redisURI.getDatabase()).isEqualTo(0);

}

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

/**
Expand Down Expand Up @@ -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
Expand All @@ -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());
}
}
}

0 comments on commit c7f36f8

Please sign in to comment.