Skip to content

Commit 08fd10b

Browse files
committed
Fix tests
1 parent ebf4b67 commit 08fd10b

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/test/java/redis/clients/jedis/ClusterCommandObjectsTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ClusterCommandObjectsTest {
2727

2828
@BeforeEach
2929
public void setUp() {
30-
clusterCommandObjects = new ClusterCommandObjects();
30+
clusterCommandObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
3131
}
3232

3333
@Test
@@ -472,7 +472,7 @@ public void testGetKeyHashSlots_withByteArrayKey_worksCorrectly() {
472472
@Test
473473
public void testGroupArgumentsByKeyHashSlot_withKeyPreProcessor_usesPreprocessedSlot() {
474474
// Create ClusterCommandObjects with a key preprocessor that adds a hash tag prefix
475-
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects();
475+
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
476476
// The prefix "{sameSlot}:" ensures all keys hash to the same slot
477477
clusterCmdObjects.setKeyArgumentPreProcessor(
478478
new redis.clients.jedis.util.PrefixedKeyArgumentPreProcessor("{sameSlot}:"));
@@ -519,7 +519,7 @@ public void testGroupArgumentsByKeyHashSlot_withKeyPreProcessor_usesPreprocessed
519519
*/
520520
@Test
521521
public void testGroupArgumentsByKeyValueHashSlot_withKeyPreProcessor_usesPreprocessedSlot() {
522-
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects();
522+
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
523523
clusterCmdObjects.setKeyArgumentPreProcessor(
524524
new redis.clients.jedis.util.PrefixedKeyArgumentPreProcessor("{sameSlot}:"));
525525

@@ -557,7 +557,7 @@ public void testGroupArgumentsByKeyValueHashSlot_withKeyPreProcessor_usesPreproc
557557
*/
558558
@Test
559559
public void testGroupArgumentsByKeyHashSlot_withKeyPreProcessor_differentSlotsAfterPreprocess() {
560-
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects();
560+
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
561561
// This preprocessor changes the hash tag, causing keys to hash to different slots
562562
clusterCmdObjects.setKeyArgumentPreProcessor(key -> {
563563
String keyStr = (String) key;
@@ -594,7 +594,7 @@ public void testGroupArgumentsByKeyHashSlot_withKeyPreProcessor_differentSlotsAf
594594
*/
595595
@Test
596596
public void testGroupArgumentsByKeyHashSlot_withKeyPreProcessor_binaryKeys() {
597-
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects();
597+
ClusterCommandObjects clusterCmdObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
598598
clusterCmdObjects.setKeyArgumentPreProcessor(
599599
new redis.clients.jedis.util.PrefixedKeyArgumentPreProcessor("{sameSlot}:"));
600600

src/test/java/redis/clients/jedis/UnboundRedisClusterClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public void testReadFromReplicas() throws Exception {
256256

257257
DefaultJedisClientConfig READ_REPLICAS_CLIENT_CONFIG = DefaultJedisClientConfig.builder()
258258
.password(endpoint.getPassword()).readOnlyForRedisClusterReplicas().build();
259-
ClusterCommandObjects commandObjects = new ClusterCommandObjects();
259+
ClusterCommandObjects commandObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
260260
try (RedisClusterClient jedisCluster = RedisClusterClient.builder()
261261
.nodes(Collections.singleton(nodeInfo1))
262262
.clientConfig(READ_REPLICAS_CLIENT_CONFIG)

src/test/java/redis/clients/jedis/executors/ClusterCommandExecutorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ public void mgetMultiShardReturnsValuesInCorrectOrderWhenKeysSpanMultipleSlots()
12411241
when(connectionHandler.getConnection(ArgumentMatchers.any(CommandArguments.class)))
12421242
.thenReturn(connection);
12431243

1244-
ClusterCommandObjects commandObjects = new ClusterCommandObjects();
1244+
ClusterCommandObjects commandObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
12451245

12461246
// Try many different key combinations including ones where keys hash to different slots
12471247
for (int i = 0; i < 100; i++) {
@@ -1336,7 +1336,7 @@ public void mgetMultiShardReturnsValuesInCorrectOrderForInterleavedSlots() {
13361336
mockedStatic.when(() -> JedisClusterCRC16.getSlot(key2)).thenReturn(200);
13371337
mockedStatic.when(() -> JedisClusterCRC16.getSlot(key3)).thenReturn(100);
13381338

1339-
ClusterCommandObjects commandObjects = new ClusterCommandObjects();
1339+
ClusterCommandObjects commandObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
13401340

13411341
// The fix should create 3 separate commands (not 2) to preserve order
13421342
List<CommandObject<List<String>>> mgetCommands = commandObjects.mgetMultiShard(key1, key2,
@@ -1410,7 +1410,7 @@ public void mgetMultiShardCombinesConsecutiveKeysWithSameSlotIntoOneCommand() {
14101410
mockedStatic.when(() -> JedisClusterCRC16.getSlot(key3)).thenReturn(200);
14111411
mockedStatic.when(() -> JedisClusterCRC16.getSlot(key4)).thenReturn(200);
14121412

1413-
ClusterCommandObjects commandObjects = new ClusterCommandObjects();
1413+
ClusterCommandObjects commandObjects = new ClusterCommandObjects(RedisProtocol.RESP2);
14141414

14151415
// Consecutive keys with the same slot should be combined into one command
14161416
List<CommandObject<List<String>>> mgetCommands = commandObjects.mgetMultiShard(key1, key2,

0 commit comments

Comments
 (0)