use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class Pipeline method exec.
public Response<List<Object>> exec() {
if (currentMulti == null)
throw new JedisDataException("EXEC without MULTI");
client.exec();
Response<List<Object>> response = super.getResponse(currentMulti);
currentMulti.setResponseDependency(response);
currentMulti = null;
return response;
}
use of redis.clients.jedis.exceptions.JedisDataException in project jedis by xetorthio.
the class Pipeline method multi.
public Response<String> multi() {
if (currentMulti != null)
throw new JedisDataException("MULTI calls can not be nested");
client.multi();
// Expecting
Response<String> response = getResponse(BuilderFactory.STRING);
// OK
currentMulti = new MultiResponseBuilder();
return response;
}
use of redis.clients.jedis.exceptions.JedisDataException in project geode by apache.
the class AuthJUnitTest method testAuthAcceptRequests.
@Test
public void testAuthAcceptRequests() {
setupCacheWithPassword();
Exception ex = null;
try {
jedis.set("foo", "bar");
} catch (JedisDataException e) {
ex = e;
}
assertNotNull(ex);
String res = jedis.auth(PASSWORD);
assertEquals(res, "OK");
// No exception
jedis.set("foo", "bar");
}
use of redis.clients.jedis.exceptions.JedisDataException in project ignite by apache.
the class RedisProtocolSelfTest method testGet.
/**
* @throws Exception If failed.
*/
public void testGet() throws Exception {
try (Jedis jedis = pool.getResource()) {
jcache().put("getKey1", "getVal1");
Assert.assertEquals("getVal1", jedis.get("getKey1"));
Assert.assertNull(jedis.get("wrongKey"));
jcache().put("setDataTypeKey", new HashSet<String>(Arrays.asList("1", "2")));
try {
jedis.get("setDataTypeKey");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("WRONGTYPE"));
}
}
}
use of redis.clients.jedis.exceptions.JedisDataException in project ignite by apache.
the class RedisProtocolSelfTest method testIncrDecr.
/**
* @throws Exception If failed.
*/
public void testIncrDecr() throws Exception {
try (Jedis jedis = pool.getResource()) {
Assert.assertEquals(1, (long) jedis.incr("newKeyIncr"));
Assert.assertEquals(-1, (long) jedis.decr("newKeyDecr"));
Assert.assertEquals("1", jedis.get("newKeyIncr"));
Assert.assertEquals("-1", jedis.get("newKeyDecr"));
Assert.assertEquals(1, (long) jedis.incr("incrKey1"));
jedis.set("incrKey1", "10");
Assert.assertEquals(11L, (long) jedis.incr("incrKey1"));
jedis.set("decrKey1", "10");
Assert.assertEquals(9L, (long) jedis.decr("decrKey1"));
jedis.set("nonInt", "abc");
try {
jedis.incr("nonInt");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("ERR"));
}
try {
jedis.decr("nonInt");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("ERR"));
}
jedis.set("outOfRangeIncr1", "9223372036854775808");
try {
jedis.incr("outOfRangeIncr1");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("ERR"));
}
jedis.set("outOfRangeDecr1", "-9223372036854775809");
try {
jedis.decr("outOfRangeDecr1");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("ERR"));
}
jedis.set("outOfRangeInc2", String.valueOf(Long.MAX_VALUE));
try {
jedis.incr("outOfRangeInc2");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("ERR"));
}
jedis.set("outOfRangeDecr2", String.valueOf(Long.MIN_VALUE));
try {
jedis.decr("outOfRangeDecr2");
assert false : "Exception has to be thrown!";
} catch (JedisDataException e) {
assertTrue(e.getMessage().startsWith("ERR"));
}
}
}
Aggregations