Add connection integration tests
This commit is contained in:
@@ -113,7 +113,7 @@ public class RjcConnection implements RedisConnection {
|
||||
Assert.hasText(command, "a valid command needs to be specified");
|
||||
try {
|
||||
connection.sendCommand(Command.valueOf(command.trim().toUpperCase()),
|
||||
(ObjectUtils.isEmpty(args) ? new byte[0][] : args));
|
||||
(ObjectUtils.isEmpty(args) ? new byte[0][0] : args));
|
||||
if (!isPipelined()) {
|
||||
return connection.getAll();
|
||||
}
|
||||
|
||||
@@ -249,10 +249,11 @@ abstract class SrpUtils {
|
||||
arrays.add(ALPHA);
|
||||
}
|
||||
|
||||
if (sortKey != null) {
|
||||
arrays.add(STORE);
|
||||
arrays.add(sortKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (sortKey != null) {
|
||||
arrays.add(STORE);
|
||||
arrays.add(sortKey);
|
||||
}
|
||||
|
||||
return arrays.toArray();
|
||||
|
||||
@@ -380,6 +380,11 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
assertEquals("bar", stringSerializer.deserialize((byte[])connection.execute("GET", "foo")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteNoArgs() {
|
||||
assertEquals("PONG", stringSerializer.deserialize((byte[])connection.execute("PING")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiExec() throws Exception {
|
||||
connection.multi();
|
||||
@@ -391,6 +396,13 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
assertEquals("value", connection.get("key"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiAlreadyInTx() throws Exception {
|
||||
connection.multi();
|
||||
// Ensure it's OK to call multi twice
|
||||
testMultiExec();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiDiscard() throws Exception {
|
||||
connection.set("testitnow", "willdo");
|
||||
@@ -466,6 +478,18 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
Arrays.asList(new String[] { "2", "3", "5" }) }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSortStoreNullParams() {
|
||||
actual.add(connection.rPush("sortlist", "9"));
|
||||
actual.add(connection.rPush("sortlist", "3"));
|
||||
actual.add(connection.rPush("sortlist", "5"));
|
||||
actual.add(connection.sort("sortlist", null, "newlist"));
|
||||
actual.add(connection.lRange("newlist", 0, 9));
|
||||
verifyResults(
|
||||
Arrays.asList(new Object[] { 1l, 2l, 3l, 3l,
|
||||
Arrays.asList(new String[] { "3", "5", "9" }) }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDbSize() {
|
||||
connection.set("dbparam", "foo");
|
||||
@@ -1243,6 +1267,33 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLLen() {
|
||||
actual.add(connection.rPush("PopList", "hello"));
|
||||
actual.add(connection.rPush("PopList", "big"));
|
||||
actual.add(connection.rPush("PopList", "world"));
|
||||
actual.add(connection.rPush("PopList", "hello"));
|
||||
actual.add(connection.lLen("PopList"));
|
||||
verifyResults(
|
||||
Arrays.asList(new Object[] { 1l, 2l, 3l, 4l, 4l }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDel() {
|
||||
connection.set("testing","123");
|
||||
actual.add(connection.del("testing"));
|
||||
actual.add(connection.exists("testing"));
|
||||
verifyResults(Arrays.asList(new Object[] { 1l, false }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppend() {
|
||||
connection.set("a", "b");
|
||||
actual.add(connection.append("a", "c"));
|
||||
actual.add(connection.get("a"));
|
||||
verifyResults(Arrays.asList(new Object[] { 2l, "bc" }), actual);
|
||||
}
|
||||
|
||||
protected void verifyResults(List<Object> expected, List<Object> actual) {
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@@ -105,10 +105,25 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
|
||||
|
||||
@Test(expected = RedisPipelineException.class)
|
||||
public void exceptionExecuteNative() throws Exception {
|
||||
connection.execute("set", "foo");
|
||||
connection.execute("ZadD", getClass() + "#foo\t0.90\titem");
|
||||
getResults();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenPipelineTwice() {
|
||||
connection.openPipeline();
|
||||
// ensure things still proceed normally with an extra openPipeline
|
||||
testGetSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClosePipelineNotOpen() {
|
||||
getResults();
|
||||
List<Object> results = connection.closePipeline();
|
||||
assertTrue(results.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
@@ -116,6 +131,12 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
|
||||
verifyResults(Arrays.asList(new Object[] { "bar" }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteNoArgs() {
|
||||
actual.add(connection.execute("PING"));
|
||||
verifyResults(Arrays.asList(new Object[] { "PONG" }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "runLongTests", value = "true")
|
||||
public void testExpire() throws Exception {
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -75,4 +76,21 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
connection.hIncrBy(key, hkey, -2 * largeNumber);
|
||||
assertEquals(-largeNumber, Long.valueOf(connection.hGet(key, hkey)).longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateConnectionWithDb() {
|
||||
JedisConnectionFactory factory2 = new JedisConnectionFactory();
|
||||
factory2.setDatabase(1);
|
||||
factory2.afterPropertiesSet();
|
||||
// No way to really verify we are in the selected DB
|
||||
factory2.getConnection().ping();
|
||||
}
|
||||
|
||||
@Test(expected=InvalidDataAccessApiUsageException.class)
|
||||
public void testCreateConnectionWithDbFailure() {
|
||||
JedisConnectionFactory factory2 = new JedisConnectionFactory();
|
||||
factory2.setDatabase(77);
|
||||
factory2.afterPropertiesSet();
|
||||
factory2.getConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,10 @@ public class JedisConnectionPipelineIntegrationTests extends
|
||||
@Ignore("DATAREDIS-143 Pipeline tries to return Long instead of List<String> on sort with no params")
|
||||
public void testSortNullParams() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-143 Pipeline tries to return Long instead of List<String> on sort with no params")
|
||||
public void testSortStoreNullParams() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-143 Jedis ClassCastExceptions closing pipeline on certain ops")
|
||||
public void testMultiExec() {
|
||||
@@ -100,6 +104,11 @@ public class JedisConnectionPipelineIntegrationTests extends
|
||||
public void testBitSet() throws Exception {
|
||||
super.testBitSet();
|
||||
}
|
||||
|
||||
@Test(expected = RedisSystemException.class)
|
||||
public void testBitGet() {
|
||||
connection.getBit("foo", 1l);
|
||||
}
|
||||
|
||||
@Test(expected = RedisSystemException.class)
|
||||
public void testRandomKey() {
|
||||
|
||||
@@ -86,6 +86,10 @@ public class JedisConnectionTransactionIntegrationTests extends
|
||||
public void testBRPopLPushTimeout() {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void testOpenPipelineTwice() {
|
||||
}
|
||||
|
||||
// Unsupported Ops
|
||||
|
||||
@Test(expected = RedisSystemException.class)
|
||||
|
||||
@@ -99,6 +99,10 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
public void testInfo() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("Ping returns status response instead of value response")
|
||||
public void testExecuteNoArgs() {
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testBitSet() throws Exception {
|
||||
super.testBitSet();
|
||||
@@ -109,6 +113,11 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
super.testMultiExec();
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testMultiAlreadyInTx() throws Exception {
|
||||
super.testMultiAlreadyInTx();
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testMultiDiscard() throws Exception {
|
||||
super.testMultiDiscard();
|
||||
@@ -310,6 +319,18 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
Arrays.asList(new Object[] { Arrays.asList(new String[] { "2", "3", "5" }) }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSortStoreNullParams() {
|
||||
connection.rPush("sortlist", "9");
|
||||
connection.rPush("sortlist", "3");
|
||||
connection.rPush("sortlist", "5");
|
||||
actual.add(connection.sort("sortlist", null, "newlist"));
|
||||
actual.add(connection.lRange("newlist", 0, 9));
|
||||
verifyResults(
|
||||
Arrays.asList(new Object[] { 3l,
|
||||
Arrays.asList(new String[] { "3", "5", "9" }) }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLPop() {
|
||||
connection.rPush("PopList", "hello");
|
||||
@@ -380,6 +401,17 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
connection.lRange("testlist", 0, -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLLen() {
|
||||
connection.rPush("PopList", "hello");
|
||||
connection.rPush("PopList", "big");
|
||||
connection.rPush("PopList", "world");
|
||||
connection.rPush("PopList", "hello");
|
||||
actual.add(connection.lLen("PopList"));
|
||||
verifyResults(
|
||||
Arrays.asList(new Object[] { 4l }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
|
||||
@@ -86,6 +86,10 @@ public class LettuceConnectionTransactionIntegrationTests extends
|
||||
public void testBRPopLPushTimeout() {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void testOpenPipelineTwice() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceptionExecuteNative() throws Exception {
|
||||
connection.execute("ZadD", getClass() + "#foo\t0.90\titem");
|
||||
|
||||
@@ -83,6 +83,10 @@ public class RjcConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
public void testSortNullParams() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testSortStoreNullParams() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testGetRangeSetRange() {
|
||||
}
|
||||
@@ -91,6 +95,10 @@ public class RjcConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
public void testStrLen() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testAppend() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-120 Pattern matching currently broken")
|
||||
public void testPubSubWithPatterns() {
|
||||
}
|
||||
@@ -99,6 +107,10 @@ public class RjcConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
public void testZUnionStoreAggWeights() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-219 isQueueing always returns false")
|
||||
public void testMultiAlreadyInTx() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-221 database not reset on pooled connections")
|
||||
public void testSelect() {
|
||||
}
|
||||
@@ -124,4 +136,11 @@ public class RjcConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
assertEquals(Arrays.asList(new Object[] { RjcUtils.decode("bar".getBytes()) }),
|
||||
(List) connection.execute("GET", RjcUtils.decode("foo".getBytes())));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testExecuteNoArgs() {
|
||||
assertEquals(Arrays.asList(new Object[] { "PONG" }),
|
||||
(List) connection.execute("PING"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,10 @@ public class RjcConnectionPipelineIntegrationTests extends
|
||||
public void testStrLen() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testAppend() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-148 Syntax error on RJC zUnionStore")
|
||||
public void testZUnionStoreAggWeights() {
|
||||
}
|
||||
@@ -128,6 +132,10 @@ public class RjcConnectionPipelineIntegrationTests extends
|
||||
public void exceptionExecuteNative() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testSortStoreNullParams() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-221 database not reset on pooled connections")
|
||||
public void testSelect() {
|
||||
}
|
||||
@@ -220,6 +228,13 @@ public class RjcConnectionPipelineIntegrationTests extends
|
||||
verifyResults(Arrays.asList(new Object[] { "bar" }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteNoArgs() {
|
||||
actual.add(connection.execute("PING"));
|
||||
List<Object> results = getResults();
|
||||
assertEquals("PONG", RjcUtils.decode((byte[])results.get(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "runLongTests", value = "true")
|
||||
public void testBRPopLPushTimeout() throws Exception {
|
||||
@@ -229,6 +244,14 @@ public class RjcConnectionPipelineIntegrationTests extends
|
||||
assertEquals(Arrays.asList(new Object[] { null }), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDel() {
|
||||
connection.set("testing","123");
|
||||
actual.add(connection.del("testing"));
|
||||
actual.add(connection.exists("testing"));
|
||||
verifyResults(Arrays.asList(new Object[] { 1l, 0l }), actual);
|
||||
}
|
||||
|
||||
protected List<Object> convertResults() {
|
||||
List<Object> serializedResults = new ArrayList<Object>();
|
||||
List<Object> pipelinedResults = getResults();
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import redis.reply.BulkReply;
|
||||
import redis.reply.StatusReply;
|
||||
|
||||
/**
|
||||
* Integration test of {@link SrpConnection}
|
||||
@@ -75,4 +76,10 @@ public class SrpConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
BulkReply reply = (BulkReply) connection.execute("GET", "foo");
|
||||
assertEquals("bar", stringSerializer.deserialize(reply.data()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteNoArgs() {
|
||||
StatusReply reply = (StatusReply) connection.execute("PING");
|
||||
assertEquals("PONG", reply.data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,14 @@ public class SrpConnectionPipelineIntegrationTests extends
|
||||
super.testGetRangeSetRange();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDel() {
|
||||
connection.set("testing","123");
|
||||
actual.add(connection.del("testing"));
|
||||
actual.add(connection.exists("testing"));
|
||||
verifyResults(Arrays.asList(new Object[] { 1l, 0l }), actual);
|
||||
}
|
||||
|
||||
protected Object convertResult(Object result) {
|
||||
Object convertedResult = super.convertResult(result);
|
||||
if (convertedResult instanceof Reply[]) {
|
||||
|
||||
@@ -82,6 +82,10 @@ public class SrpConnectionTransactionIntegrationTests extends
|
||||
public void testBRPopLPushTimeout() {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void testOpenPipelineTwice() {
|
||||
}
|
||||
|
||||
@Test(expected = RedisSystemException.class)
|
||||
public void exceptionExecuteNative() throws Exception {
|
||||
connection.execute("ZadD", getClass() + "#foo\t0.90\titem");
|
||||
|
||||
Reference in New Issue
Block a user