Added bunch of missing commands and a test to check if Jedis is updated

This commit is contained in:
Jonathan Leibiusky
2010-09-14 12:08:56 -03:00
parent 9b202c3fb1
commit a8ffacd30a
7 changed files with 179 additions and 2 deletions

View File

@@ -219,4 +219,20 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
jedis.select(1);
assertEquals(0, jedis.dbSize());
}
@Test
public void persist() {
jedis.setex("foo", 60 * 60, "bar");
assertTrue(jedis.ttl("foo") > 0);
int status = jedis.persist("foo");
assertEquals(1, status);
assertEquals(-1, jedis.ttl("foo"));
}
@Test
public void echo() {
String result = jedis.echo("hello world");
assertEquals("hello world", result);
}
}

View File

@@ -16,8 +16,13 @@ public class ControlCommandsTest extends JedisCommandTestBase {
@Test
public void bgsave() {
String status = jedis.bgsave();
assertEquals("Background saving started", status);
try {
String status = jedis.bgsave();
assertEquals("Background saving started", status);
} catch (JedisException e) {
assertEquals("ERR background save already in progress", e
.getMessage());
}
}
@Test
@@ -72,4 +77,10 @@ public class ControlCommandsTest extends JedisCommandTestBase {
assertEquals("OK", status);
jedis.configSet("maxmemory", memory);
}
@Test
public void sync() {
jedis.sync();
}
}

View File

@@ -249,6 +249,25 @@ public class ListCommandsTest extends JedisCommandTestBase {
assertEquals(2, result.size());
assertEquals("foo", result.get(0));
assertEquals("bar", result.get(1));
}
@Test
public void lpushx() {
int status = jedis.lpushx("foo", "bar");
assertEquals(0, status);
jedis.lpush("foo", "a");
status = jedis.lpushx("foo", "b");
assertEquals(2, status);
}
@Test
public void rpushx() {
int status = jedis.rpushx("foo", "bar");
assertEquals(0, status);
jedis.lpush("foo", "a");
status = jedis.rpushx("foo", "b");
assertEquals(2, status);
}
}

View File

@@ -169,4 +169,10 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
assertEquals("This is a string", jedis.substr("s", 0, -1));
assertEquals(" string", jedis.substr("s", 9, 100000));
}
@Test
public void strlen() {
jedis.set("s", "This is a string");
assertEquals("This is a string".length(), jedis.strlen("s"));
}
}