diff --git a/gradle.properties b/gradle.properties index 7ee576181..c3bc5ab8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ jedisVersion=2.1.0 springVersion=3.1.4.RELEASE log4jVersion=1.2.17 version=1.1.0.BUILD-SNAPSHOT -srpVersion=0.6 +srpVersion=0.7 jacksonVersion=1.8.8 lettuceVersion=2.3.3 mockitoVersion=1.8.5 diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java index 94438f144..32ea98366 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionIntegrationTests.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals; import java.util.Arrays; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests; @@ -87,9 +86,4 @@ public class SrpConnectionIntegrationTests extends AbstractConnectionIntegration ReturnType.MULTI, 0)); verifyResults(Arrays.asList(new Object[] {Arrays.asList(new Object[] {"OK", "OK"} )}), actual); } - - @Ignore("https://github.com/spullara/redis-protocol/issues/25") - public void testScriptExists() { - //script_exists only returns one result and it's false - } } diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java index d41df0a98..f3927958b 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineIntegrationTests.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Properties; import java.util.Set; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests; @@ -226,9 +225,14 @@ public class SrpConnectionPipelineIntegrationTests extends verifyResults(Arrays.asList(new Object[] { 1l, "6.4", "6.4" }), actual); } - @Ignore("https://github.com/spullara/redis-protocol/issues/25") + @Test + @IfProfileValue(name = "redisVersion", value = "2.6") public void testScriptExists() { - // script_exists only returns one result and it's false + getResults(); + String sha1 = connection.scriptLoad("return 'foo'"); + initConnection(); + actual.add(connection.scriptExists(sha1, "98777234")); + verifyResults(Arrays.asList(new Object[] {Arrays.asList(new Object[] {1l, 0l})}), actual); } protected Object convertResult(Object result) { diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java index 1020c5d8b..822f8bfb5 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionPipelineTxIntegrationTests.java @@ -26,6 +26,8 @@ import org.junit.Test; import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisVersionUtils; import org.springframework.data.redis.connection.RedisPipelineException; +import org.springframework.data.redis.connection.ReturnType; +import org.springframework.data.redis.connection.RedisStringCommands.BitOperation; import org.springframework.test.annotation.IfProfileValue; /** @@ -100,6 +102,52 @@ public class SrpConnectionPipelineTxIntegrationTests extends SrpConnectionTransa verifyResults(Arrays.asList(new Object[] { "sup", 13l, "suckrcalifrag" }), actual); } + @Test(expected=RedisPipelineException.class) + @IfProfileValue(name = "redisVersion", value = "2.6") + public void testEvalShaNotFound() { + connection.evalSha("somefakesha", ReturnType.VALUE, 2, "key1", "key2"); + getResults(); + } + + @Test(expected=RedisPipelineException.class) + @IfProfileValue(name = "redisVersion", value = "2.6") + public void testEvalReturnSingleError() { + connection.eval("return redis.call('expire','foo')", ReturnType.BOOLEAN, 0); + getResults(); + } + + @Test(expected=RedisPipelineException.class) + @IfProfileValue(name = "redisVersion", value = "2.6") + public void testRestoreBadData() { + // Use something other than dump-specific serialization + connection.restore("testing".getBytes(), 0, "foo".getBytes()); + getResults(); + } + + @Test + @IfProfileValue(name = "redisVersion", value = "2.6") + public void testRestoreExistingKey() { + connection.set("testing", "12"); + connection.dump("testing".getBytes()); + List results = getResults(); + initConnection(); + connection.restore("testing".getBytes(), 0, (byte[]) results.get(1)); + try { + getResults(); + fail("Expected pipeline exception restoring an existing key"); + }catch(RedisPipelineException e) { + } + } + + @Test(expected=RedisPipelineException.class) + @IfProfileValue(name = "redisVersion", value = "2.6") + public void testBitOpNotMultipleSources() { + connection.set("key1", "abcd"); + connection.set("key2", "efgh"); + actual.add(connection.bitOp(BitOperation.NOT, "key3", "key1", "key2")); + getResults(); + } + protected void initConnection() { connection.openPipeline(); connection.multi(); diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java index 7fc095342..f9a19dab1 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionTransactionIntegrationTests.java @@ -15,12 +15,16 @@ */ package org.springframework.data.redis.connection.srp; +import static org.junit.Assert.fail; + import java.util.Arrays; import java.util.List; import org.junit.Ignore; import org.junit.Test; import org.springframework.data.redis.RedisSystemException; +import org.springframework.data.redis.connection.RedisStringCommands.BitOperation; +import org.springframework.data.redis.connection.ReturnType; import org.springframework.test.annotation.IfProfileValue; /** @@ -95,44 +99,50 @@ public class SrpConnectionTransactionIntegrationTests extends SrpConnectionPipel verifyResults(Arrays.asList(new Object[] { "sup", 13l, "suckrcalifrag" }), actual); } - @Ignore("https://github.com/spullara/redis-protocol/issues/24") - @Test + @Test(expected=RedisSystemException.class) @IfProfileValue(name = "redisVersion", value = "2.6") public void testEvalReturnSingleError() { - // SRP issue exec does not report individual ErrorReplys in a MultiBulkReply - // as Exceptions + connection.eval("return redis.call('expire','foo')", ReturnType.BOOLEAN, 0); + getResults(); } - @Ignore("https://github.com/spullara/redis-protocol/issues/24") - @Test + @Test(expected=RedisSystemException.class) @IfProfileValue(name = "redisVersion", value = "2.6") public void testEvalShaNotFound() { - // SRP issue exec does not report individual ErrorReplys in a MultiBulkReply - // as Exceptions + connection.evalSha("somefakesha", ReturnType.VALUE, 2, "key1", "key2"); + getResults(); } - @Ignore("https://github.com/spullara/redis-protocol/issues/24") - @Test + @Test(expected=RedisSystemException.class) @IfProfileValue(name = "redisVersion", value = "2.6") public void testRestoreBadData() { - // SRP issue exec does not report individual ErrorReplys in a MultiBulkReply - // as Exceptions + // Use something other than dump-specific serialization + connection.restore("testing".getBytes(), 0, "foo".getBytes()); + getResults(); } - @Ignore("https://github.com/spullara/redis-protocol/issues/24") @Test @IfProfileValue(name = "redisVersion", value = "2.6") public void testRestoreExistingKey() { - // SRP issue exec does not report individual ErrorReplys in a MultiBulkReply - // as Exceptions + connection.set("testing", "12"); + connection.dump("testing".getBytes()); + List results = getResults(); + initConnection(); + connection.restore("testing".getBytes(), 0, (byte[]) results.get(1)); + try { + getResults(); + fail("Expected pipeline exception restoring an existing key"); + }catch(RedisSystemException e) { + } } - @Ignore("https://github.com/spullara/redis-protocol/issues/24") - @Test + @Test(expected=RedisSystemException.class) @IfProfileValue(name = "redisVersion", value = "2.6") public void testBitOpNotMultipleSources() { - // SRP issue exec does not report individual ErrorReplys in a MultiBulkReply - // as Exceptions + connection.set("key1", "abcd"); + connection.set("key2", "efgh"); + actual.add(connection.bitOp(BitOperation.NOT, "key3", "key1", "key2")); + getResults(); } @Test(expected = UnsupportedOperationException.class)