From 515cec689b0b2c58bc35d6a59fd7d88c0e4f10f8 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 16 Sep 2022 11:44:32 +0200 Subject: [PATCH] Polishing. Add author tags. Align Lettuce BZPOPMIN/MAX tests. Increase timeout to 10ms as Redis blocks indefinitely if the timeout is less than 0.01. See #2324 --- .../jedis/JedisClusterZSetCommands.java | 3 ++- .../jedis/JedisClusterConnectionTests.java | 5 ++--- .../LettuceClusterConnectionTests.java | 22 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java index 76a83603e..9ff07028d 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java @@ -43,6 +43,7 @@ import org.springframework.util.Assert; * @author Mark Paluch * @author Clement Ong * @author Andrey Shlykov + * @author Jens Deppe * @since 2.0 */ class JedisClusterZSetCommands implements RedisZSetCommands { @@ -1254,7 +1255,7 @@ class JedisClusterZSetCommands implements RedisZSetCommands { */ @Nullable @SuppressWarnings("unchecked") - private static Tuple toTuple(List bytes) { + private static Tuple toTuple(@Nullable List bytes) { if (bytes == null || bytes.isEmpty()) { return null; diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java index 480ff50b5..e49574c57 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java @@ -65,7 +65,6 @@ import org.springframework.data.redis.connection.RedisStringCommands.BitOperatio import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.connection.ReturnType; import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding; -import org.springframework.data.redis.connection.RedisListCommands.*; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.script.DigestUtils; @@ -2155,7 +2154,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests { @EnabledOnCommand("BZPOPMIN") public void bzPopMinShouldWorkCorrectly() { - assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS)) + assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)) .isNull(); nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES); @@ -2183,7 +2182,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests { @EnabledOnCommand("BZPOPMAX") public void bzPopMaxShouldWorkCorrectly() { - assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS)) + assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)) .isNull(); nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java index 5352030a1..18c9325c8 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java @@ -91,13 +91,10 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests { private static final GeoLocation PALERMO = new GeoLocation<>("palermo", POINT_PALERMO); private static final GeoLocation ARIGENTO_BYTES = new GeoLocation<>( - "arigento".getBytes(StandardCharsets.UTF_8), - POINT_ARIGENTO); - private static final GeoLocation CATANIA_BYTES = new GeoLocation<>( - "catania".getBytes(StandardCharsets.UTF_8), + "arigento".getBytes(StandardCharsets.UTF_8), POINT_ARIGENTO); + private static final GeoLocation CATANIA_BYTES = new GeoLocation<>("catania".getBytes(StandardCharsets.UTF_8), POINT_CATANIA); - private static final GeoLocation PALERMO_BYTES = new GeoLocation<>( - "palermo".getBytes(StandardCharsets.UTF_8), + private static final GeoLocation PALERMO_BYTES = new GeoLocation<>("palermo".getBytes(StandardCharsets.UTF_8), POINT_PALERMO); private final RedisClusterClient client; @@ -177,7 +174,6 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests { factory.destroy(); } - @Test // DATAREDIS-315 public void appendShouldAddValueCorrectly() { @@ -2193,6 +2189,8 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests { @EnabledOnCommand("BZPOPMIN") public void bzPopMinShouldWorkCorrectly() { + assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull(); + nativeConnection.zadd(KEY_1, 10D, VALUE_1); nativeConnection.zadd(KEY_1, 20D, VALUE_2); nativeConnection.zadd(KEY_1, 30D, VALUE_3); @@ -2205,6 +2203,8 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests { @EnabledOnCommand("ZPOPMAX") public void zPopMaxShouldWorkCorrectly() { + assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull(); + nativeConnection.zadd(KEY_1, 10D, VALUE_1); nativeConnection.zadd(KEY_1, 20D, VALUE_2); nativeConnection.zadd(KEY_1, 30D, VALUE_3); @@ -2376,8 +2376,8 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests { nativeConnection.zadd(KEY_1, 20D, VALUE_2); nativeConnection.zadd(KEY_1, 5D, VALUE_3); - assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2)) - .contains(new DefaultTuple(VALUE_1_BYTES, 10D), new DefaultTuple(VALUE_2_BYTES, 20D)); + assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_1_BYTES, 10D), + new DefaultTuple(VALUE_2_BYTES, 20D)); } @Test // DATAREDIS-315 @@ -2494,8 +2494,8 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests { nativeConnection.zadd(KEY_1, 20D, VALUE_2); nativeConnection.zadd(KEY_1, 5D, VALUE_3); - assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2)) - .contains(new DefaultTuple(VALUE_3_BYTES, 5D), new DefaultTuple(VALUE_1_BYTES, 10D)); + assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_3_BYTES, 5D), + new DefaultTuple(VALUE_1_BYTES, 10D)); } @Test