add JedisDataException and JedisConnectionException

This commit is contained in:
Jonathan Leibiusky
2011-01-30 17:46:17 -03:00
parent b4ad7697b7
commit 2a4a43f4cd
31 changed files with 269 additions and 263 deletions

View File

@@ -5,93 +5,92 @@ import java.util.List;
import org.junit.Test;
import redis.clients.jedis.DebugParams;
import redis.clients.jedis.JedisException;
import redis.clients.jedis.JedisMonitor;
import redis.clients.jedis.exceptions.JedisDataException;
public class ControlCommandsTest extends JedisCommandTestBase {
@Test
public void save() {
String status = jedis.save();
assertEquals("OK", status);
String status = jedis.save();
assertEquals("OK", status);
}
@Test
public void bgsave() {
try {
String status = jedis.bgsave();
assertEquals("Background saving started", status);
} catch (JedisException e) {
assertTrue(
"ERR Background save already in progress"
.equalsIgnoreCase(e.getMessage()));
}
try {
String status = jedis.bgsave();
assertEquals("Background saving started", status);
} catch (JedisDataException e) {
assertTrue("ERR Background save already in progress"
.equalsIgnoreCase(e.getMessage()));
}
}
@Test
public void bgrewriteaof() {
String status = jedis.bgrewriteaof();
assertEquals("Background append only file rewriting started", status);
String status = jedis.bgrewriteaof();
assertEquals("Background append only file rewriting started", status);
}
@Test
public void lastsave() throws InterruptedException {
long before = jedis.lastsave();
String st = "";
while (!st.equals("OK")) {
try {
Thread.sleep(1000);
st = jedis.save();
} catch (JedisException e) {
long before = jedis.lastsave();
String st = "";
while (!st.equals("OK")) {
try {
Thread.sleep(1000);
st = jedis.save();
} catch (JedisDataException e) {
}
}
long after = jedis.lastsave();
assertTrue((after - before) > 0);
}
}
long after = jedis.lastsave();
assertTrue((after - before) > 0);
}
@Test
public void info() {
String info = jedis.info();
assertNotNull(info);
String info = jedis.info();
assertNotNull(info);
}
@Test
public void monitor() {
jedis.monitor(new JedisMonitor() {
@Override
public void onCommand(String command) {
assertTrue(command.contains("OK"));
client.disconnect();
}
});
jedis.monitor(new JedisMonitor() {
@Override
public void onCommand(String command) {
assertTrue(command.contains("OK"));
client.disconnect();
}
});
}
@Test
public void configGet() {
List<String> info = jedis.configGet("m*");
assertNotNull(info);
List<String> info = jedis.configGet("m*");
assertNotNull(info);
}
@Test
public void configSet() {
List<String> info = jedis.configGet("maxmemory");
String memory = info.get(1);
String status = jedis.configSet("maxmemory", "200");
assertEquals("OK", status);
jedis.configSet("maxmemory", memory);
List<String> info = jedis.configGet("maxmemory");
String memory = info.get(1);
String status = jedis.configSet("maxmemory", "200");
assertEquals("OK", status);
jedis.configSet("maxmemory", memory);
}
@Test
public void sync() {
jedis.sync();
jedis.sync();
}
@Test
public void debug() {
jedis.set("foo", "bar");
String resp = jedis.debug(DebugParams.OBJECT("foo"));
assertNotNull(resp);
resp = jedis.debug(DebugParams.RELOAD());
assertNotNull(resp);
String resp = jedis.debug(DebugParams.OBJECT("foo"));
assertNotNull(resp);
resp = jedis.debug(DebugParams.RELOAD());
assertNotNull(resp);
}
}