add brpoplpush

This commit is contained in:
Jonathan Leibiusky
2010-12-20 11:10:02 -03:00
parent c30359581e
commit 3f79d80396
6 changed files with 90 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
package redis.clients.jedis.tests.commands;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
@@ -578,4 +580,52 @@ public class ListCommandsTest extends JedisCommandTestBase {
assertEquals(-1, bstatus);
}
@Test
public void brpoplpush() {
(new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(100);
Jedis j = createJedis();
j.lpush("foo", "a");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
})).start();
String element = jedis.brpoplpush("foo", "bar", 0);
assertEquals("a", element);
assertEquals(1, jedis.llen("bar").longValue());
assertEquals("a", jedis.lrange("bar", 0, -1).get(0));
(new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(100);
Jedis j = createJedis();
j.lpush("foo", "a");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
})).start();
element = jedis.brpoplpush("foo".getBytes(), "bar".getBytes(), 0);
assertEquals("a", element);
assertEquals(1, jedis.llen("bar").longValue());
assertEquals("a", jedis.lrange("bar", 0, -1).get(0));
}
}