Upgrade to SRP 0.7

DATAREDIS-205
This commit is contained in:
Jennifer Hickey
2013-06-30 15:01:20 -07:00
parent d07967a183
commit 62d2fe26cb
5 changed files with 85 additions and 29 deletions

View File

@@ -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
}
}

View File

@@ -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) {

View File

@@ -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<Object> 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();

View File

@@ -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<Object> 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)