Merge pull request #189 from vsoskov/jedis
--- the exception is returned in the list with the not formatted and formatted values. Response.get throws the exception.
This commit is contained in:
@@ -118,4 +118,20 @@ public class PipeliningTest extends Assert {
|
||||
p.sync();
|
||||
assertNull(shouldNotExist.get());
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.Pipeline;
|
||||
import redis.clients.jedis.Response;
|
||||
import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.TransactionBlock;
|
||||
@@ -241,4 +242,39 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
string.get();
|
||||
t.exec();
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user