Make Lettuce return converted tx results

DATAREDIS-208
This commit is contained in:
Jennifer Hickey
2013-07-23 14:48:31 -07:00
parent aa8d10b150
commit be199d8c97
12 changed files with 758 additions and 857 deletions

View File

@@ -1,41 +1,17 @@
package org.springframework.data.redis.connection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.serializer.SerializationUtils;
import org.springframework.test.annotation.IfProfileValue;
abstract public class AbstractConnectionTransactionIntegrationTests extends
AbstractConnectionIntegrationTests {
protected boolean convert = true;
protected boolean convertLongToBoolean = true;
protected boolean convertStringToProps = false;
@Before
public void setUp() {
super.setUp();
((DefaultStringRedisConnection)connection).setDeserializePipelineAndTxResults(false);
}
@Ignore
public void testMultiDiscard() {
}
@@ -116,325 +92,11 @@ abstract public class AbstractConnectionTransactionIntegrationTests extends
public void testHashNullValue() throws Exception {
}
@Test(expected=UnsupportedOperationException.class)
@Test(expected = UnsupportedOperationException.class)
public void testWatchWhileInTx() {
connection.watch("foo".getBytes());
}
// Type conversion overrides
@Test
public void testExecute() {
connection.set("foo", "bar");
actual.add(connection.execute("GET", "foo"));
assertEquals("bar", getResults().get(0));
}
@Test
public void testExecuteNoArgs() {
actual.add(connection.execute("PING"));
assertEquals("PONG", getResults().get(0));
}
@Test
public void testSort() {
convertLongToBoolean = false;
super.testSort();
}
@Test
public void testSortStore() {
convertLongToBoolean = false;
super.testSortStore();
}
@Test
public void testSortNullParams() {
convertLongToBoolean = false;
super.testSortNullParams();
}
@Test
public void testDbSize() {
convertLongToBoolean = false;
super.testDbSize();
}
@Test
public void testFlushDb() {
convertLongToBoolean = false;
super.testFlushDb();
}
@Test
public void testDel() {
convertLongToBoolean = false;
super.testDel();
}
@Test
public void testIncDecrByLong() {
convertLongToBoolean = false;
super.testIncrDecrByLong();
}
@Test
public void testDecrByIncrBy() {
convertLongToBoolean = false;
super.testDecrByIncrBy();
}
@Test
public void testIncrDecr() {
convertLongToBoolean = false;
super.testIncDecr();
}
@Test
public void testLInsert() {
convertLongToBoolean = false;
super.testLInsert();
}
@Test
public void testLRem() {
convertLongToBoolean = false;
super.testLRem();
}
@Test
public void testLPop() {
convertLongToBoolean = false;
super.testLPop();
}
@Test
public void testLLen() {
convertLongToBoolean = false;
super.testLLen();
}
@Test
public void testLSet() {
convertLongToBoolean = false;
super.testLSet();
}
@Test
public void testLTrim() {
convertLongToBoolean = false;
super.testLTrim();
}
@Test
public void testRPop() {
convertLongToBoolean = false;
super.testRPop();
}
@Test
public void testRPopLPush() {
convertLongToBoolean = false;
super.testRPopLPush();
}
@Test
public void testLPushX() {
convertLongToBoolean = false;
super.testLPushX();
}
@Test
public void testRPushX() {
convertLongToBoolean = false;
super.testRPushX();
}
@Test
public void testLIndex() {
convertLongToBoolean = false;
super.testLIndex();
}
@Test
public void testLPush() throws Exception {
convertLongToBoolean = false;
super.testLPush();
}
@Test
public void testSDiffStore() {
convertLongToBoolean = false;
actual.add(connection.sAdd("myset", "foo"));
actual.add(connection.sAdd("myset", "bar"));
actual.add(connection.sAdd("otherset", "bar"));
actual.add(connection.sDiffStore("thirdset", "myset", "otherset"));
actual.add(connection.sMembers("thirdset"));
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 1l, 1l,
new HashSet<String>(Collections.singletonList("foo")) }));
}
@Test
public void testSInterStore() {
convertLongToBoolean = false;
actual.add(connection.sAdd("myset", "foo"));
actual.add(connection.sAdd("myset", "bar"));
actual.add(connection.sAdd("otherset", "bar"));
actual.add(connection.sInterStore("thirdset", "myset", "otherset"));
actual.add(connection.sMembers("thirdset"));
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 1l, 1l,
new HashSet<String>(Collections.singletonList("bar")) }));
}
@Test
public void testZRank() {
convertLongToBoolean = false;
actual.add(connection.zAdd("myset", 2, "Bob"));
actual.add(connection.zAdd("myset", 1, "James"));
actual.add(connection.zRank("myset", "James"));
actual.add(connection.zRank("myset", "Bob"));
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 0l, 1l }));
}
@Test
public void testZRemRangeByScore() {
convertLongToBoolean = false;
actual.add(connection.zAdd("myset", 2, "Bob"));
actual.add(connection.zAdd("myset", 1, "James"));
actual.add(connection.zRemRangeByScore("myset", 0d, 1d));
actual.add(connection.zRange("myset", 0l, -1l));
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 1l,
new LinkedHashSet<String>(Arrays.asList(new String[] { "Bob" })) }));
}
@Test
public void testZRevRank() {
convertLongToBoolean = false;
actual.add(connection.zAdd("myset", 2, "Bob"));
actual.add(connection.zAdd("myset", 1, "James"));
actual.add(connection.zAdd("myset", 3, "Joe"));
actual.add(connection.zRevRank("myset", "Joe"));
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 1l, 0l }));
}
@Test
public void testIncrDecrByLong() {
convertLongToBoolean = false;
super.testIncrDecrByLong();
}
@Test
public void testIncDecr() {
convertLongToBoolean = false;
super.testIncDecr();
}
@Test
public void testType() {
connection.set("something", "yo");
actual.add(connection.type("something"));
verifyResults(Arrays.asList(new Object[] { "string" }));
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testBitCountNonExistentKey() {
convertLongToBoolean = false;
super.testBitCountNonExistentKey();
}
@Test
public void testInfo() throws Exception {
convertStringToProps = true;
super.testInfo();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testInfoBySection() throws Exception {
convertStringToProps = true;
super.testInfoBySection();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testDumpAndRestore() {
convert = false;
connection.set("testing", "12");
actual.add(connection.dump("testing".getBytes()));
List<Object> results = getResults();
initConnection();
actual.add(connection.del("testing"));
actual.add((connection.get("testing")));
connection.restore("testing".getBytes(), 0, (byte[]) results.get(results.size() - 1));
actual.add(connection.get("testing"));
results = getResults();
assertEquals(3,results.size());
assertEquals(1l, results.get(0));
assertNull(results.get(1));
assertEquals("12", new String((byte[])results.get(2)));
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testScriptLoadEvalSha() {
convert = false;
super.testScriptLoadEvalSha();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalShaArrayStrings() {
convert = false;
super.testEvalShaArrayStrings();
}
@Test(expected = RedisSystemException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testRestoreExistingKey() {
convert = false;
super.testRestoreExistingKey();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalReturnString() {
convert = false;
super.testEvalReturnString();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalReturnArrayStrings() {
convert = false;
super.testEvalReturnArrayStrings();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalReturnSingleOK() {
actual.add(connection.eval("return redis.call('set','abc','ghk')", ReturnType.STATUS, 0));
assertEquals(Arrays.asList(new Object[] { "OK" }), getResultsNoConversion());
}
@SuppressWarnings("unchecked")
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalReturnArrayOKs() {
actual.add(connection.eval(
"return { redis.call('set','abc','ghk'), redis.call('set','abc','lfdf')}",
ReturnType.MULTI, 0));
List<String> result = (List<String>) getResults().get(0);
assertEquals(Arrays.asList(new Object[] { "OK", "OK" }), result);
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testRestoreTtl() {
convert = false;
super.testRestoreTtl();
}
@Test(expected = UnsupportedOperationException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testScriptKill() {
@@ -443,99 +105,14 @@ abstract public class AbstractConnectionTransactionIntegrationTests extends
connection.scriptKill();
}
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testBitCount() {
convertLongToBoolean = false;
String key = "bitset-test";
connection.setBit(key, 0, false);
connection.setBit(key, 1, true);
connection.setBit(key, 2, true);
actual.add(connection.bitCount(key));
// Lettuce setBit returns Long instead of void
verifyResults(new ArrayList<Object>(Arrays.asList(0l, 0l, 0l, 2l)));
}
@Test
public void testGetRangeSetRange() {
connection.set("rangekey", "supercalifrag");
actual.add(connection.getRange("rangekey", 0l, 2l));
connection.setRange("rangekey", "ck", 2);
actual.add(connection.get("rangekey"));
// Lettuce returns a value for setRange
verifyResults(Arrays.asList(new Object[] { "sup", 13l, "suckrcalifrag" }));
}
protected void initConnection() {
connection.multi();
}
protected abstract DataAccessException convertException(Exception ex);
protected List<Object> getResults() {
List<Object> actual = connection.exec();
if (actual == null) {
return null;
}
return convertResults(actual);
}
protected List<Object> getResultsNoConversion() {
return connection.exec();
}
protected List<Object> convertResults(List<Object> results) {
if(results == null) {
return null;
}
List<Object> serializedResults = new ArrayList<Object>();
for (Object result : results) {
Object convertedResult = convertResult(result);
if (convertedResult instanceof Exception) {
throw convertException((Exception) convertedResult);
}
if (!"OK".equals(convertedResult) && !"QUEUED".equals(convertedResult)) {
serializedResults.add(convertedResult);
}
}
return serializedResults;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Object convertResult(Object result) {
if (!convert) {
return result;
}
if (result instanceof List && !(((List) result).isEmpty())
&& ((List) result).get(0) instanceof byte[]) {
return (SerializationUtils.deserialize((List<byte[]>) result, stringSerializer));
} else if (result instanceof byte[]) {
if(convertStringToProps) {
return Converters.toProperties(stringSerializer.deserialize((byte[]) result));
}
return (stringSerializer.deserialize((byte[]) result));
} else if (result instanceof Map
&& ((Map) result).keySet().iterator().next() instanceof byte[]) {
return (SerializationUtils.deserialize((Map) result, stringSerializer));
} else if (result instanceof Set && !(((Set) result).isEmpty())) {
Object firstResult = ((Set) result).iterator().next();
if (firstResult instanceof byte[]) {
return (SerializationUtils.deserialize((Set) result, stringSerializer));
}
} else if (convertLongToBoolean && result instanceof Long) {
if ((Long) result == 1l) {
return true;
} else if ((Long) result == 0l) {
return false;
} else {
return result;
}
} else if (convertStringToProps && result instanceof String) {
return Converters.toProperties((String) result);
}
return result;
}
protected void verifyResults(List<Object> expected) {
List<Object> expectedTx = new ArrayList<Object>();
for (int i = 0; i < actual.size(); i++) {

View File

@@ -1,125 +0,0 @@
package org.springframework.data.redis.connection;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.test.annotation.IfProfileValue;
public class ConvertingAbstractConnectionTransactionIntegrationTests extends
AbstractConnectionIntegrationTests {
@Ignore
public void testMultiDiscard() {
}
@Ignore
public void testMultiExec() {
}
@Ignore
public void testUnwatch() {
}
@Ignore
public void testWatch() {
}
@Ignore
@Test
public void testExecWithoutMulti() {
}
@Ignore
@Test
public void testErrorInTx() {
}
/*
* Using blocking ops inside a tx does not make a lot of sense as it would require blocking the
* entire server in order to execute the block atomically, which in turn does not allow other
* clients to perform a push operation. *
*/
@Ignore
public void testBLPop() {
}
@Ignore
public void testBRPop() {
}
@Ignore
public void testBRPopLPush() {
}
@Ignore
public void testBLPopTimeout() {
}
@Ignore
public void testBRPopTimeout() {
}
@Ignore
public void testBRPopLPushTimeout() {
}
@Ignore("Pub/Sub not supported with transactions")
public void testPubSubWithNamedChannels() throws Exception {
}
@Ignore("Pub/Sub not supported with transactions")
public void testPubSubWithPatterns() throws Exception {
}
@Ignore
public void testNullKey() throws Exception {
}
@Ignore
public void testNullValue() throws Exception {
}
@Ignore
public void testHashNullKey() throws Exception {
}
@Ignore
public void testHashNullValue() throws Exception {
}
@Test(expected = UnsupportedOperationException.class)
public void testWatchWhileInTx() {
connection.watch("foo".getBytes());
}
@Test(expected = UnsupportedOperationException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testScriptKill() {
// Impossible to call script kill in a tx because you can't issue the
// exec command while Redis is running a script
connection.scriptKill();
}
protected void initConnection() {
connection.multi();
}
protected List<Object> getResults() {
return connection.exec();
}
protected void verifyResults(List<Object> expected) {
List<Object> expectedTx = new ArrayList<Object>();
for (int i = 0; i < actual.size(); i++) {
expectedTx.add(null);
}
assertEquals(expectedTx, actual);
List<Object> results = getResults();
assertEquals(expected, results);
}
}

View File

@@ -19,7 +19,7 @@ import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.redis.connection.ConvertingAbstractConnectionTransactionIntegrationTests;
import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -37,7 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("JedisConnectionIntegrationTests-context.xml")
public class JedisConnectionTransactionIntegrationTests extends
ConvertingAbstractConnectionTransactionIntegrationTests {
AbstractConnectionTransactionIntegrationTests {
@After
public void tearDown() {

View File

@@ -23,7 +23,6 @@ import static org.junit.Assume.assumeTrue;
import static org.springframework.data.redis.SpinBarrier.waitFor;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Test;
@@ -44,7 +43,6 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.lambdaworks.redis.RedisAsyncConnection;
import com.lambdaworks.redis.RedisException;
/**
* Integration test of {@link LettuceConnection}
@@ -286,16 +284,4 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
conn2.close();
}
}
@Test
public void testErrorInTx() {
connection.multi();
connection.set("foo","bar");
// Try to do a list op on a value
connection.lPop("foo");
List<Object> execResults = connection.exec();
// Lettuce puts the Exception in the exec results instead of throwing an Exception on exec
// This should be fixed in DATAREDIS-208 when we convert results of tx.exec()
assertTrue(execResults.get(1) instanceof RedisException);
}
}

View File

@@ -21,7 +21,6 @@ import static org.junit.Assume.assumeTrue;
import static org.springframework.data.redis.SpinBarrier.waitFor;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Test;
@@ -39,8 +38,6 @@ import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.lambdaworks.redis.RedisException;
/**
* Integration test of {@link LettuceConnection} pipeline functionality
*
@@ -129,19 +126,4 @@ public class LettuceConnectionPipelineIntegrationTests extends
conn2.close();
}
}
@SuppressWarnings("unchecked")
@Test
public void testErrorInTx() {
connection.multi();
connection.set("foo","bar");
// Try to do a list op on a value
connection.lPop("foo");
connection.exec();
List<Object> results = getResults();
List<Object> execResults = (List<Object>)results.get(0);
// Lettuce puts the Exception in the exec results instead of throwing an Exception on exec
// This should be fixed in DATAREDIS-208 when we convert results of tx.exec()
assertTrue(execResults.get(1) instanceof RedisException);
}
}

View File

@@ -5,6 +5,10 @@ import static org.junit.Assert.assertNull;
import java.util.List;
import org.junit.Test;
import org.springframework.data.redis.connection.RedisPipelineException;
import org.springframework.test.annotation.IfProfileValue;
/**
* Integration test of {@link LettuceConnection} transactions within a pipeline
*
@@ -14,6 +18,30 @@ import java.util.List;
public class LettuceConnectionPipelineTxIntegrationTests extends
LettuceConnectionTransactionIntegrationTests {
@Test(expected = RedisPipelineException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalShaNotFound() {
super.testEvalShaNotFound();
}
@Test(expected = RedisPipelineException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testEvalReturnSingleError() {
super.testEvalReturnSingleError();
}
@Test(expected = RedisPipelineException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testRestoreBadData() {
super.testRestoreBadData();
}
@Test(expected = RedisPipelineException.class)
@IfProfileValue(name = "redisVersion", value = "2.6")
public void testRestoreExistingKey() {
super.testRestoreExistingKey();
}
protected void initConnection() {
connection.openPipeline();
connection.multi();
@@ -21,17 +49,6 @@ public class LettuceConnectionPipelineTxIntegrationTests extends
@SuppressWarnings("unchecked")
protected List<Object> getResults() {
assertNull(connection.exec());
List<Object> pipelined = connection.closePipeline();
// We expect only the results of exec to be in the closed pipeline
assertEquals(1,pipelined.size());
List<Object> txResults = (List<Object>)pipelined.get(0);
// Return exec results and this test should behave exactly like its superclass
return convertResults(txResults);
}
@SuppressWarnings("unchecked")
protected List<Object> getResultsNoConversion() {
assertNull(connection.exec());
List<Object> pipelined = connection.closePipeline();
// We expect only the results of exec to be in the closed pipeline

View File

@@ -17,31 +17,18 @@ package org.springframework.data.redis.connection.lettuce;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.core.convert.converter.Converter;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests;
import org.springframework.data.redis.connection.DefaultStringRedisConnection;
import org.springframework.data.redis.connection.DefaultStringTuple;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.connection.StringRedisConnection;
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
import org.springframework.data.redis.connection.convert.SetConverter;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.lambdaworks.redis.KeyValue;
import com.lambdaworks.redis.ScoredValue;
/**
* Integration test of {@link LettuceConnection} functionality within a
* transaction
@@ -54,141 +41,11 @@ import com.lambdaworks.redis.ScoredValue;
public class LettuceConnectionTransactionIntegrationTests extends
AbstractConnectionTransactionIntegrationTests {
private boolean convertListToSet;
@Test
@Ignore("Exceptions on native execute are swallowed in tx")
@Ignore("DATAREDIS-226 Exceptions on native execute are swallowed in tx")
public void exceptionExecuteNative() throws Exception {
}
// Native Lettuce returns ZSets as Lists
@Test
public void testZAddAndZRange() {
convertListToSet = true;
super.testZAddAndZRange();
}
@Test
public void testZIncrBy() {
convertListToSet = true;
super.testZIncrBy();
}
@Test
public void testZInterStore() {
convertListToSet = true;
super.testZInterStore();
}
@Test
public void testZInterStoreAggWeights() {
convertListToSet = true;
super.testZInterStoreAggWeights();
}
@Test
public void testZRangeWithScores() {
convertListToSet = true;
super.testZRangeWithScores();
}
@Test
public void testZRangeByScore() {
convertListToSet = true;
super.testZRangeByScore();
}
@Test
public void testZRangeByScoreOffsetCount() {
convertListToSet = true;
super.testZRangeByScoreOffsetCount();
}
@Test
public void testZRangeByScoreWithScores() {
convertListToSet = true;
super.testZRangeByScoreWithScores();
}
@Test
public void testZRangeByScoreWithScoresOffsetCount() {
convertListToSet = true;
super.testZRangeByScoreWithScoresOffsetCount();
}
@Test
public void testZRevRangeByScoreOffsetCount() {
convertListToSet = true;
super.testZRevRangeByScoreOffsetCount();
}
@Test
public void testZRevRangeByScore() {
convertListToSet = true;
super.testZRevRangeByScore();
}
@Test
public void testZRevRange() {
convertListToSet = true;
super.testZRevRange();
}
@Test
public void testZRevRangeWithScores() {
convertListToSet = true;
super.testZRevRangeWithScores();
}
@Test
public void testZRem() {
convertListToSet = true;
super.testZRem();
}
@Test
public void testZRemRangeByRank() {
convertListToSet = true;
super.testZRemRangeByRank();
}
@Test
public void testZRemRangeByScore() {
convertListToSet = true;
super.testZRemRangeByScore();
}
@Test
public void testZUnionStore() {
convertListToSet = true;
super.testZUnionStore();
}
@Test
public void testZUnionStoreAggWeights() {
convertListToSet = true;
super.testZUnionStoreAggWeights();
}
@Test
public void testBitSet() throws Exception {
convertLongToBoolean = false;
String key = "bitset-test";
connection.setBit(key, 0, false);
connection.setBit(key, 1, true);
actual.add(connection.getBit(key, 0));
actual.add(connection.getBit(key, 1));
// Lettuce setBit returns Long instead of void
verifyResults(Arrays.asList(new Object[] { 0l, 0l, 0l, 1l }));
}
@Test
public void testHKeys() {
convertListToSet = true;
super.testHKeys();
}
@Test(expected = UnsupportedOperationException.class)
public void testBitOpNotMultipleSources() {
super.testBitOpNotMultipleSources();
@@ -200,12 +57,6 @@ public class LettuceConnectionTransactionIntegrationTests extends
super.testSRandMemberCountNegative();
}
@Test
public void testSortStoreNullParams() {
convertLongToBoolean = false;
super.testSortStoreNullParams();
}
@Test
public void testMove() {
connection.set("foo", "bar");
@@ -230,43 +81,4 @@ public class LettuceConnectionTransactionIntegrationTests extends
public void testSelect() {
super.testSelect();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Object convertResult(Object result) {
if (!convert) {
return result;
}
Object convertedResult = super.convertResult(result);
if (convertedResult instanceof KeyValue) {
List<String> keyValue = new ArrayList<String>();
keyValue.add((String) super.convertResult(((KeyValue) convertedResult).key));
keyValue.add((String) super.convertResult(((KeyValue) convertedResult).value));
return keyValue;
}
if (convertedResult instanceof List && !(((List) result).isEmpty())
&& ((List) convertedResult).get(0) instanceof ScoredValue) {
Set<Tuple> tuples = LettuceConverters.toTupleSet((List) convertedResult);
return new SetConverter<Tuple, StringTuple>(new TupleConverter())
.convert(tuples);
}
if (convertListToSet && convertedResult instanceof List) {
return new LinkedHashSet((List) convertedResult);
}
if (convertStringToProps && convertedResult instanceof String) {
return LettuceConverters.toProperties((String) convertedResult);
}
return convertedResult;
}
private class TupleConverter implements Converter<Tuple, StringTuple> {
public StringTuple convert(Tuple source) {
return new DefaultStringTuple(source, stringSerializer.deserialize(source.getValue()));
}
}
@Override
protected DataAccessException convertException(Exception ex) {
return LettuceConverters.toDataAccessException(ex);
}
}

View File

@@ -19,7 +19,7 @@ import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.redis.connection.ConvertingAbstractConnectionTransactionIntegrationTests;
import org.springframework.data.redis.connection.AbstractConnectionTransactionIntegrationTests;
import org.springframework.data.redis.connection.ReturnType;
import org.springframework.test.annotation.IfProfileValue;
import org.springframework.test.context.ContextConfiguration;
@@ -35,7 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("SrpConnectionIntegrationTests-context.xml")
public class SrpConnectionTransactionIntegrationTests extends ConvertingAbstractConnectionTransactionIntegrationTests {
public class SrpConnectionTransactionIntegrationTests extends AbstractConnectionTransactionIntegrationTests {
@Test
@IfProfileValue(name = "redisVersion", value = "2.6")