improve Atomic integration tests

This commit is contained in:
Costin Leau
2013-01-25 10:57:26 +02:00
parent e3946af60c
commit b9645d64d1
2 changed files with 7 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ public abstract class AtomicCountersParam {
JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory();
jedisConnFactory.setPort(SettingsUtils.getPort());
jedisConnFactory.setHostName(SettingsUtils.getHost());
jedisConnFactory.setUsePool(false);
jedisConnFactory.afterPropertiesSet();
// jredis factory

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
@@ -121,7 +122,9 @@ public class RedisAtomicTests {
@Test
public void testCompareSet() throws Exception {
final AtomicBoolean flag = new AtomicBoolean(false);
for (int i = 0; i < 500; i++) {
int NUM = 123;
final CountDownLatch latch = new CountDownLatch(NUM);
for (int i = 0; i < NUM; i++) {
new Thread(new Runnable() {
public void run() {
RedisAtomicInteger atomicInteger = new RedisAtomicInteger("key", factory);
@@ -132,9 +135,10 @@ public class RedisAtomicTests {
flag.set(true);
}
latch.countDown();
}
}).start();
}
latch.await();
}
}