Skip to content

Commit 43827c8

Browse files
committed
Replace JedisCluster with RedisClusterClient in tests
1 parent e8fdd20 commit 43827c8

19 files changed

+624
-284
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void constructorConnectionProvider() {
176176

177177
@Test
178178
public void clusterPipelined() {
179-
try (JedisCluster cluster = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG);
179+
try (RedisClusterClient cluster = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build();
180180
ClusterPipeline pipeline = cluster.pipelined()) {
181181

182182
Response<String> r1 = pipeline.set("key1", "value1");
@@ -199,7 +199,7 @@ public void clusterPipelined() {
199199

200200
@Test
201201
public void intermediateSync() {
202-
try (JedisCluster cluster = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG);
202+
try (RedisClusterClient cluster = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build();
203203
ClusterPipeline pipeline = cluster.pipelined()) {
204204

205205
Response<String> r1 = pipeline.set("key1", "value1");
@@ -226,7 +226,7 @@ public void intermediateSync() {
226226

227227
@Test
228228
public void intermediateSyncs() {
229-
try (JedisCluster cluster = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG);
229+
try (RedisClusterClient cluster = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build();
230230
ClusterPipeline pipeline = cluster.pipelined()) {
231231

232232
Response<String> r1 = pipeline.set("key1", "value1");
@@ -253,7 +253,7 @@ public void intermediateSyncs() {
253253

254254
@Test
255255
public void pipelineResponse() {
256-
try (JedisCluster jc = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
256+
try (RedisClusterClient jc = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
257257
jc.set("string", "foo");
258258
jc.lpush("list", "foo");
259259
jc.hset("hash", "foo", "bar");
@@ -305,7 +305,7 @@ public void pipelineResponse() {
305305

306306
@Test
307307
public void pipelineBinarySafeHashCommands() {
308-
try (JedisCluster jc = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
308+
try (RedisClusterClient jc = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
309309
jc.hset("key".getBytes(), "f1".getBytes(), "v111".getBytes());
310310
jc.hset("key".getBytes(), "f22".getBytes(), "v2222".getBytes());
311311
}
@@ -970,7 +970,7 @@ public void testEvalNestedListsWithBinary() {
970970
public void testEvalsha() {
971971
String script = "return 'success!'";
972972
String sha1;
973-
try (JedisCluster jc = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
973+
try (RedisClusterClient jc = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
974974
sha1 = jc.scriptLoad(script, "sampleKey");
975975
assertTrue(jc.scriptExists(sha1, "sampleKey"));
976976
}
@@ -990,7 +990,7 @@ public void testEvalshaKeyAndArg() {
990990
String arg = "3";
991991
String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
992992
String sha1;
993-
try (JedisCluster jc = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
993+
try (RedisClusterClient jc = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
994994
sha1 = jc.scriptLoad(script, key);
995995
assertTrue(jc.scriptExists(sha1, key));
996996
}
@@ -1017,7 +1017,7 @@ public void testEvalshaKeyAndArgWithBinary() {
10171017
String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";
10181018
byte[] bScript = SafeEncoder.encode(script);
10191019
byte[] bSha1;
1020-
try (JedisCluster jc = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
1020+
try (RedisClusterClient jc = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
10211021
bSha1 = jc.scriptLoad(bScript, bKey);
10221022
assertTrue(jc.scriptExists(bSha1, bKey));
10231023
}
@@ -1039,7 +1039,7 @@ public void testEvalshaKeyAndArgWithBinary() {
10391039

10401040
@Test
10411041
public void spublishInPipeline() {
1042-
try (JedisCluster jedis = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
1042+
try (RedisClusterClient jedis = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
10431043
ClusterPipeline pipelined = jedis.pipelined();
10441044
Response<Long> p1 = pipelined.publish("foo", "bar");
10451045
Response<Long> p2 = pipelined.publish("foo".getBytes(), "bar".getBytes());
@@ -1051,7 +1051,7 @@ public void spublishInPipeline() {
10511051

10521052
@Test
10531053
public void simple() { // TODO: move into 'redis.clients.jedis.commands.unified.cluster' package
1054-
try (JedisCluster jedis = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
1054+
try (RedisClusterClient jedis = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
10551055
final int count = 10;
10561056
int totalCount = 0;
10571057
for (int i = 0; i < count; i++) {
@@ -1084,7 +1084,7 @@ public void simple() { // TODO: move into 'redis.clients.jedis.commands.unified.
10841084

10851085
@Test
10861086
public void transaction() {
1087-
try (JedisCluster cluster = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
1087+
try (RedisClusterClient cluster = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
10881088
assertThrows(UnsupportedOperationException.class, () -> cluster.multi());
10891089
}
10901090
}
@@ -1095,7 +1095,7 @@ public void multiple() {
10951095
final int maxTotal = 100;
10961096
ConnectionPoolConfig poolConfig = new ConnectionPoolConfig();
10971097
poolConfig.setMaxTotal(maxTotal);
1098-
try (JedisCluster cluster = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG, 5, poolConfig)) {
1098+
try (RedisClusterClient cluster = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).maxAttempts(5).poolConfig(poolConfig).build()) {
10991099
for (int i = 0; i < maxTotal; i++) {
11001100
assertThreadsCount();
11011101
String s = Integer.toString(i);
@@ -1110,7 +1110,7 @@ public void multiple() {
11101110

11111111
@Test
11121112
public void testPipelineKeysAtSameNode() {
1113-
try (JedisCluster cluster = new JedisCluster(nodes, DEFAULT_CLIENT_CONFIG)) {
1113+
try (RedisClusterClient cluster = RedisClusterClient.builder().nodes(nodes).clientConfig(DEFAULT_CLIENT_CONFIG).build()) {
11141114

11151115
// test simple key
11161116
cluster.set("foo", "bar");

0 commit comments

Comments
 (0)