use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class TransactionCommandsTest method execGetResponse.
@Test
public void execGetResponse() {
Transaction t = jedis.multi();
t.set("foo", "bar");
t.smembers("foo");
t.get("foo");
List<Response<?>> lr = t.execGetResponse();
try {
lr.get(1).get();
fail("We expect exception here!");
} catch (JedisDataException e) {
// that is fine we should be here
}
assertEquals("bar", lr.get(2).get());
}
use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class TransactionCommandsTest method transactionResponseWithError.
@Test
public void transactionResponseWithError() {
Transaction t = jedis.multi();
t.set("foo", "bar");
Response<Set<String>> error = t.smembers("foo");
Response<String> r = t.get("foo");
List<Object> l = t.exec();
assertEquals(JedisDataException.class, l.get(1).getClass());
try {
error.get();
fail("We expect exception here!");
} catch (JedisDataException e) {
// that is fine we should be here
}
assertEquals(r.get(), "bar");
}
use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class PipeliningTest method testCloseableWithMulti.
@Test
public void testCloseableWithMulti() throws IOException {
// we need to test with fresh instance of Jedis
Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
jedis2.auth("foobared");
Pipeline pipeline = jedis2.pipelined();
Response<String> retFuture1 = pipeline.set("a", "1");
Response<String> retFuture2 = pipeline.set("b", "2");
pipeline.multi();
pipeline.set("a", "a");
pipeline.set("b", "b");
pipeline.close();
try {
pipeline.exec();
fail("close should discard transaction");
} catch (JedisDataException e) {
assertTrue(e.getMessage().contains("EXEC without MULTI"));
// pass
}
// it shouldn't meet any exception
retFuture1.get();
retFuture2.get();
}
use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class PipeliningTest method piplineWithError.
@Test
public void piplineWithError() {
Pipeline p = jedis.pipelined();
p.set("foo", "bar");
Response<Set<String>> error = p.smembers("foo");
Response<String> r = p.get("foo");
p.sync();
try {
error.get();
fail();
} catch (JedisDataException e) {
// that is fine we should be here
}
assertEquals(r.get(), "bar");
}
use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class JedisSentinelTest method sentinelRemove.
@Test
public void sentinelRemove() {
Jedis j = new Jedis(sentinel.getHost(), sentinel.getPort());
try {
ensureMonitored(sentinel, REMOVE_MASTER_NAME, MASTER_IP, master.getPort(), 1);
String result = j.sentinelRemove(REMOVE_MASTER_NAME);
assertEquals("OK", result);
// not exist
try {
result = j.sentinelRemove(REMOVE_MASTER_NAME);
assertNotEquals("OK", result);
fail();
} catch (JedisDataException e) {
// pass
}
} finally {
j.close();
}
}
Aggregations