Add connection integration tests
This commit is contained in:
@@ -642,6 +642,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();
|
||||
@@ -653,6 +658,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");
|
||||
@@ -728,12 +740,51 @@ 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");
|
||||
assertTrue(connection.dbSize() > 0);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlushDb() {
|
||||
connection.flushDb();
|
||||
|
||||
@@ -106,10 +106,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");
|
||||
@@ -213,6 +228,12 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
|
||||
verifyResults(Arrays.asList(new Object[] { 1l, null, "12" }), 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 {
|
||||
|
||||
@@ -208,6 +208,23 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
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();
|
||||
}
|
||||
|
||||
@Test(expected=InvalidDataAccessApiUsageException.class)
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testEvalReturnSingleError() {
|
||||
|
||||
@@ -87,6 +87,10 @@ public class JedisConnectionPipelineIntegrationTests extends
|
||||
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() {
|
||||
}
|
||||
@@ -156,6 +160,11 @@ public class JedisConnectionPipelineIntegrationTests extends
|
||||
super.testBitSet();
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testBitGet() {
|
||||
connection.getBit("foo", 1l);
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
public void testBitCount() {
|
||||
connection.bitCount("foo");
|
||||
|
||||
@@ -85,6 +85,10 @@ public class JedisConnectionTransactionIntegrationTests extends
|
||||
public void testBRPopLPushTimeout() {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void testOpenPipelineTwice() {
|
||||
}
|
||||
|
||||
// Unsupported Ops
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
|
||||
@@ -86,6 +86,10 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
public void testMSetNxFailure() {
|
||||
}
|
||||
|
||||
@Ignore("Ping returns status response instead of value response")
|
||||
public void testExecuteNoArgs() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectionClosesWhenNotPooled() {
|
||||
connection.close();
|
||||
@@ -130,6 +134,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();
|
||||
@@ -560,6 +569,17 @@ 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");
|
||||
@@ -626,6 +646,16 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
assertEquals(Arrays.asList(new String[] { "baz", "bar" }), 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");
|
||||
|
||||
@@ -91,6 +91,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");
|
||||
|
||||
@@ -30,6 +30,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}
|
||||
@@ -78,6 +79,12 @@ public class SrpConnectionIntegrationTests extends AbstractConnectionIntegration
|
||||
assertEquals("bar", stringSerializer.deserialize(reply.data()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteNoArgs() {
|
||||
StatusReply reply = (StatusReply) connection.execute("PING");
|
||||
assertEquals("PONG", reply.data());
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testEvalReturnArrayOKs() {
|
||||
|
||||
@@ -214,6 +214,14 @@ public class SrpConnectionPipelineIntegrationTests extends
|
||||
verifyResults(Arrays.asList(new Object[] {Arrays.asList(new Object[] {1l, 0l})}), 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, 0l }), actual);
|
||||
}
|
||||
|
||||
protected Object convertResult(Object result) {
|
||||
Object convertedResult = super.convertResult(result);
|
||||
if (convertedResult instanceof Reply[]) {
|
||||
|
||||
@@ -83,6 +83,10 @@ public class SrpConnectionTransactionIntegrationTests extends SrpConnectionPipel
|
||||
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