fix incorrect cast of BulkReply to byte[] in SprConnection

DATAREDIS-114
This commit is contained in:
Costin Leau
2013-02-05 19:01:14 +02:00
parent a0f7e690cf
commit 0b70fa2d23
2 changed files with 17 additions and 2 deletions

View File

@@ -147,10 +147,10 @@ abstract class SrpUtils {
return tuples;
}
static Map<byte[], byte[]> toMap(Object[] byteArrays) {
static Map<byte[], byte[]> toMap(Reply[] byteArrays) {
Map<byte[], byte[]> map = new LinkedHashMap<byte[], byte[]>(byteArrays.length / 2);
for (int i = 0; i < byteArrays.length; i++) {
map.put((byte[]) byteArrays[i++], (byte[]) byteArrays[i]);
map.put((byte[]) byteArrays[i++].data(), (byte[]) byteArrays[i].data());
}
return map;
}

View File

@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.BlockingDeque;
@@ -374,4 +375,18 @@ public abstract class AbstractConnectionIntegrationTests {
assertArrayEquals(value1.getBytes(), (byte[]) result.get(2));
assertArrayEquals(value2.getBytes(), (byte[]) result.get(3));
}
@Test
public void testHashMethod() throws Exception {
String hash = getClass() + ":hashtest";
String key1 = UUID.randomUUID().toString();
String key2 = UUID.randomUUID().toString();
connection.hSet(hash, key1, UUID.randomUUID().toString());
connection.hSet(hash, key2, UUID.randomUUID().toString());
Map<String, String> hashMap = connection.hGetAll(hash);
assertTrue(hashMap.size() >= 2);
assertTrue(hashMap.containsKey(key1));
assertTrue(hashMap.containsKey(key2));
}
}