Fix JedisConnection execute does not return correct results
DATAREDIS-158
This commit is contained in:
@@ -150,7 +150,7 @@ public class JedisConnection implements RedisConnection {
|
||||
Collections.addAll(mArgs, args);
|
||||
}
|
||||
|
||||
Object result = ReflectionUtils.invokeMethod(SEND_COMMAND, client,
|
||||
ReflectionUtils.invokeMethod(SEND_COMMAND, client,
|
||||
Command.valueOf(command.trim().toUpperCase()), mArgs.toArray(new byte[mArgs.size()][]));
|
||||
if (isQueueing() || isPipelined()) {
|
||||
Object target = (isPipelined() ? pipeline : transaction);
|
||||
@@ -163,11 +163,9 @@ public class JedisConnection implements RedisConnection {
|
||||
return "Object";
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
client.getOne();
|
||||
}
|
||||
return result;
|
||||
return client.getOne();
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
public void testExpire() throws Exception {
|
||||
connection.set("exp", "true");
|
||||
assertTrue(connection.expire("exp", 1));
|
||||
assertFalse(exists("exp", 2000l));
|
||||
assertFalse(exists("exp", 3000l));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,7 +127,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
public void testSetEx() throws Exception {
|
||||
connection.setEx("expy", 1l, "yep");
|
||||
assertEquals("yep", connection.get("expy"));
|
||||
assertFalse(exists("expy", 2000l));
|
||||
assertFalse(exists("expy", 3000l));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -365,6 +365,12 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
connection.execute("ZadD", getClass() + "#foo\t0.90\titem");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
assertEquals("bar", stringSerializer.deserialize((byte[])connection.execute("GET", "foo")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiExec() throws Exception {
|
||||
connection.multi();
|
||||
|
||||
@@ -108,6 +108,13 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
|
||||
connection.closePipeline();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
actual.add(connection.execute("GET", "foo"));
|
||||
verifyResults(Arrays.asList(new Object[] { "bar" }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "runLongTests", value = "true")
|
||||
public void testExpire() throws Exception {
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jredis.protocol.BulkResponse;
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -330,4 +331,11 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
connection.lRange("testlist", 0, -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
BulkResponse response = (BulkResponse) connection.execute("GET", JredisUtils.decode("foo".getBytes()));
|
||||
assertEquals("bar", stringSerializer.deserialize(response.getBulkData()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.redis.connection.rjc;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Ignore;
|
||||
@@ -38,20 +39,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@ContextConfiguration
|
||||
public class RjcConnectionIntegrationTests extends AbstractConnectionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testMultiExec() throws Exception {
|
||||
byte[] key = "key".getBytes();
|
||||
byte[] value = "value".getBytes();
|
||||
|
||||
connection.multi();
|
||||
connection.set(key, value);
|
||||
assertNull(connection.get(key));
|
||||
List<Object> results = connection.exec();
|
||||
assertEquals(2, results.size());
|
||||
assertEquals("OK", (String) results.get(0));
|
||||
assertEquals(new String(value), new String(RjcUtils.encode((String) results.get(1))));
|
||||
}
|
||||
|
||||
@Ignore("nulls are encoded to empty strings")
|
||||
public void testNullKey() throws Exception {
|
||||
}
|
||||
@@ -107,4 +94,26 @@ public class RjcConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
@Ignore("DATAREDIS-148 Syntax error on RJC zUnionStore")
|
||||
public void testZUnionStoreAggWeights() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiExec() throws Exception {
|
||||
byte[] key = "key".getBytes();
|
||||
byte[] value = "value".getBytes();
|
||||
|
||||
connection.multi();
|
||||
connection.set(key, value);
|
||||
assertNull(connection.get(key));
|
||||
List<Object> results = connection.exec();
|
||||
assertEquals(2, results.size());
|
||||
assertEquals("OK", (String) results.get(0));
|
||||
assertEquals(new String(value), new String(RjcUtils.encode((String) results.get(1))));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
assertEquals(Arrays.asList(new Object[] { RjcUtils.decode("bar".getBytes()) }),
|
||||
(List) connection.execute("GET", RjcUtils.decode("foo".getBytes())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RjcConnectionPipelineIntegrationTests extends
|
||||
public void testPingPong() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-150 the results of tye improperly decoded")
|
||||
@Ignore("DATAREDIS-150 the results of type improperly decoded")
|
||||
public void testType() {
|
||||
}
|
||||
|
||||
@@ -202,6 +202,13 @@ public class RjcConnectionPipelineIntegrationTests extends
|
||||
"somethingelse" }) }), convertedResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
actual.add(connection.execute("GET", RjcUtils.decode("foo".getBytes())));
|
||||
verifyResults(Arrays.asList(new Object[] { "bar" }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "runLongTests", value = "true")
|
||||
public void testBRPopLPushTimeout() throws Exception {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.data.redis.connection.srp;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -26,6 +27,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import redis.client.RedisClientBase;
|
||||
import redis.reply.BulkReply;
|
||||
|
||||
/**
|
||||
* Integration test of {@link SrpConnection}
|
||||
@@ -107,7 +109,14 @@ public class SrpConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
super.testGetRangeSetRange();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
BulkReply reply = (BulkReply) connection.execute("GET", "foo");
|
||||
assertEquals("bar", stringSerializer.deserialize(reply.data()));
|
||||
}
|
||||
|
||||
private int getRedisVersion() {
|
||||
return RedisClientBase.parseVersion((String)connection.info().get("redis_version"));
|
||||
return RedisClientBase.parseVersion((String) connection.info().get("redis_version"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user