Search in sources :

Example 46 with JedisDataException

use of redis.clients.jedis.exceptions.JedisDataException in project ignite by apache.

the class RedisProtocolStringSelfTest method testGetRange.

/**
 * @throws Exception If failed.
 */
public void testGetRange() throws Exception {
    try (Jedis jedis = pool.getResource()) {
        Assert.assertEquals("", jedis.getrange("getRangeKeyNonExisting", 0, 0));
        jcache().put("getRangeKey", "This is a string");
        Assert.assertEquals("This", jedis.getrange("getRangeKey", 0, 3));
        Assert.assertEquals("ing", jedis.getrange("getRangeKey", -3, -1));
        Assert.assertEquals("This is a string", jedis.getrange("getRangeKey", 0, -1));
        Assert.assertEquals("string", jedis.getrange("getRangeKey", 10, 100));
        jcache().put("setDataTypeKey", new HashSet<String>(Arrays.asList("1", "2")));
        try {
            jedis.getrange("setDataTypeKey", 0, 1);
            assert false : "Exception has to be thrown!";
        } catch (JedisDataException e) {
            assertTrue(e.getMessage().startsWith("WRONGTYPE"));
        }
    }
}
Also used : Jedis(redis.clients.jedis.Jedis) JedisDataException(redis.clients.jedis.exceptions.JedisDataException)

Aggregations

JedisDataException (redis.clients.jedis.exceptions.JedisDataException)46 Jedis (redis.clients.jedis.Jedis)27 Test (org.junit.Test)20 Pipeline (redis.clients.jedis.Pipeline)6 Transaction (redis.clients.jedis.Transaction)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)4 List (java.util.List)3 Set (java.util.Set)3 Logger (org.apache.log4j.Logger)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Response (redis.clients.jedis.Response)2 QueryRedisClusterDetailResponse (beans.response.QueryRedisClusterDetailResponse)1 ObjectInput (com.alibaba.dubbo.common.serialize.ObjectInput)1 ObjectOutput (com.alibaba.dubbo.common.serialize.ObjectOutput)1 Invocation (com.alibaba.dubbo.rpc.Invocation)1 RpcException (com.alibaba.dubbo.rpc.RpcException)1