Fix NPE when deserializing a null Map

DATAREDIS-138
This commit is contained in:
Jennifer Hickey
2013-04-01 09:53:08 -07:00
parent 323f8097a7
commit fb25e79380
6 changed files with 55 additions and 77 deletions

View File

@@ -30,6 +30,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.junit.Before;
import org.junit.Ignore;
@@ -732,6 +733,21 @@ abstract public class AbstractConnectionPipelineIntegrationTests extends
actual);
}
@Test
public void testHSetGet() throws Exception {
String hash = getClass() + ":hashtest";
String key1 = UUID.randomUUID().toString();
String key2 = UUID.randomUUID().toString();
String value1 = "foo";
String value2 = "bar";
actual.add(connection.hSet(hash, key1, value1));
actual.add(connection.hSet(hash, key2, value2));
actual.add(connection.hGet(hash, key1));
actual.add(connection.hGetAll(hash));
List<String> expected = Arrays.asList(new String[] { key1, value1, key2, value2 });
verifyResults(Arrays.asList(new Object[] { 1l, 1l, value1, expected }), actual);
}
@Test
public void testHSetNX() throws Exception {
actual.add(connection.hSetNX("myhash", "key1", "foo"));

View File

@@ -17,8 +17,11 @@ package org.springframework.data.redis.connection.jedis;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.junit.After;
import org.junit.Ignore;
@@ -73,24 +76,6 @@ public class JedisConnectionPipelineIntegrationTests extends
public void testFlushDb() {
}
@Ignore("DATAREDIS-138 NPE in DefaultStringRedisConnection deserializing a null Map")
public void testHSetGet() throws Exception {
// String hash = getClass() + ":hashtest";
// String key1 = UUID.randomUUID().toString();
// String key2 = UUID.randomUUID().toString();
// String value1 = "foo";
// String value2 = "bar";
// actual.add(connection.hSet(hash, key1, value1));
// actual.add(connection.hSet(hash, key2, value2));
// actual.add(connection.hGet(hash, key1));
// actual.add(connection.hGetAll(hash));
// Map<String, String> expected = new HashMap<String, String>();
// expected.put(key1, value1);
// expected.put(key2, value2);
// verifyResults(Arrays.asList(new Object[] { 1l, 1l, value1, expected
// }), actual);
}
@Ignore("DATAREDIS-143 Jedis ClassCastExceptions closing pipeline on certain ops")
public void testGetConfig() {
}
@@ -236,6 +221,23 @@ public class JedisConnectionPipelineIntegrationTests extends
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 0l, false }), actual);
}
@Test
public void testHSetGet() throws Exception {
String hash = getClass() + ":hashtest";
String key1 = UUID.randomUUID().toString();
String key2 = UUID.randomUUID().toString();
String value1 = "foo";
String value2 = "bar";
actual.add(connection.hSet(hash, key1, value1));
actual.add(connection.hSet(hash, key2, value2));
actual.add(connection.hGet(hash, key1));
actual.add(connection.hGetAll(hash));
Map<String, String> expected = new HashMap<String, String>();
expected.put(key1, value1);
expected.put(key2, value2);
verifyResults(Arrays.asList(new Object[] { 1l, 1l, value1, expected }), actual);
}
@Test
@IfProfileValue(name = "runLongTests", value = "true")
public void testExpireAt() throws Exception {

View File

@@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import org.junit.Ignore;
import org.junit.Test;
@@ -80,27 +81,26 @@ public class LettuceConnectionPipelineIntegrationTests extends
public void testZCount() {
}
@Ignore("DATAREDIS-138 NPE in DefaultStringRedisConnection deserializing a null Map")
public void testHSetGet() throws Exception {
// String hash = getClass() + ":hashtest";
// String key1 = UUID.randomUUID().toString();
// String key2 = UUID.randomUUID().toString();
// String value1 = "foo";
// String value2 = "bar";
// actual.add(connection.hSet(hash, key1, value1));
// actual.add(connection.hSet(hash, key2, value2));
// actual.add(connection.hGet(hash, key1));
// actual.add(connection.hGetAll(hash));
// Map<String, String> expected = new HashMap<String, String>();
// expected.put(key1, value1);
// expected.put(key2, value2);
// verifyResults(Arrays.asList(new Object[] { true, true, value1,
// expected }), actual);
}
// Overrides, usually due to return values being Long vs Boolean or Set vs
// List
@Test
public void testHSetGet() throws Exception {
String hash = getClass() + ":hashtest";
String key1 = UUID.randomUUID().toString();
String key2 = UUID.randomUUID().toString();
String value1 = "foo";
String value2 = "bar";
actual.add(connection.hSet(hash, key1, value1));
actual.add(connection.hSet(hash, key2, value2));
actual.add(connection.hGet(hash, key1));
actual.add(connection.hGetAll(hash));
Map<String, String> expected = new HashMap<String, String>();
expected.put(key1, value1);
expected.put(key2, value2);
verifyResults(Arrays.asList(new Object[] { true, true, value1, expected }), actual);
}
@Test
public void testInfo() throws Exception {
assertNull(connection.info());

View File

@@ -89,23 +89,6 @@ public class RjcConnectionPipelineIntegrationTests extends
public void testZRevRangeWithScores() {
}
@Ignore("DATAREDIS-138 NPE in DefaultStringRedisConnection deserializing a null Map")
public void testHSetGet() throws Exception {
// String hash = getClass() + ":hashtest";
// String key1 = UUID.randomUUID().toString();
// String key2 = UUID.randomUUID().toString();
// String value1 = "foo";
// String value2 = "bar";
// actual.add(connection.hSet(hash, key1, value1));
// actual.add(connection.hSet(hash, key2, value2));
// actual.add(connection.hGet(hash, key1));
// actual.add(connection.hGetAll(hash));
// List<String> expected = Arrays.asList(new String[] { key1, value1,
// key2, value2 });
// verifyResults(Arrays.asList(new Object[] { 1l, 1l, value1, expected
// }), actual);
}
@Ignore("DATAREDIS-148 Syntax error on RJC zUnionStore")
public void testZUnionStoreAggWeights() {
}

View File

@@ -98,23 +98,6 @@ public class SrpConnectionPipelineIntegrationTests extends
public void testZRangeByScoreWithScoresOffsetCount() {
}
@Ignore("DATAREDIS-138 NPE in DefaultStringRedisConnection deserializing a null Map")
public void testHSetGet() throws Exception {
// String hash = getClass() + ":hashtest";
// String key1 = UUID.randomUUID().toString();
// String key2 = UUID.randomUUID().toString();
// String value1 = "foo";
// String value2 = "bar";
// actual.add(connection.hSet(hash, key1, value1));
// actual.add(connection.hSet(hash, key2, value2));
// actual.add(connection.hGet(hash, key1));
// actual.add(connection.hGetAll(hash));
// List<String> expected = Arrays.asList(new String[] {key1, value1,
// key2, value2});
// verifyResults(Arrays.asList(new Object[] { 1l, 1l, value1, expected
// }), actual);
}
@Test(expected = UnsupportedOperationException.class)
public void testZInterStoreAggWeights() {
super.testZInterStoreAggWeights();