Java 16 migration for Redis examples.

See #606.
This commit is contained in:
Mark Paluch
2021-04-29 11:03:21 +02:00
parent 338d9d92ca
commit 88aabe89e2
16 changed files with 77 additions and 98 deletions

View File

@@ -15,10 +15,6 @@
*/
package example.springdata.redis.cluster;
import static org.hamcrest.core.Is.*;
import static org.hamcrest.core.IsCollectionContaining.*;
import static org.junit.Assert.*;
import example.springdata.redis.test.util.RequiresRedisServer;
import java.util.Arrays;
@@ -36,6 +32,8 @@ import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.assertj.core.api.Assertions.assertThat;
/**
* {@link BasicUsageTests} shows general usage of {@link RedisTemplate} and {@link RedisOperations} in a clustered
* environment.
@@ -54,13 +52,9 @@ public class BasicUsageTests {
@Before
public void setUp() {
template.execute(new RedisCallback<String>() {
@Override
public String doInRedis(RedisConnection connection) throws DataAccessException {
connection.flushDb();
return "FLUSHED";
}
template.execute((RedisCallback<String>) connection -> {
connection.flushDb();
return "FLUSHED";
});
}
@@ -72,7 +66,7 @@ public class BasicUsageTests {
public void singleSlotOperation() {
template.opsForValue().set("name", "rand al'thor"); // slot 5798
assertThat(template.opsForValue().get("name"), is("rand al'thor"));
assertThat(template.opsForValue().get("name")).isEqualTo("rand al'thor");
}
/**
@@ -86,8 +80,8 @@ public class BasicUsageTests {
template.opsForValue().set("name", "matrim cauthon"); // slot 5798
template.opsForValue().set("nickname", "prince of the ravens"); // slot 14594
assertThat(template.opsForValue().multiGet(Arrays.asList("name", "nickname")),
hasItems("matrim cauthon", "prince of the ravens"));
assertThat(template.opsForValue().multiGet(Arrays.asList("name", "nickname"))).contains("matrim cauthon",
"prince of the ravens");
}
/**
@@ -100,8 +94,8 @@ public class BasicUsageTests {
template.opsForValue().set("{user}.name", "perrin aybara"); // slot 5474
template.opsForValue().set("{user}.nickname", "wolfbrother"); // slot 5474
assertThat(template.opsForValue().multiGet(Arrays.asList("{user}.name", "{user}.nickname")),
hasItems("perrin aybara", "wolfbrother"));
assertThat(template.opsForValue().multiGet(Arrays.asList("{user}.name", "{user}.nickname")))
.contains("perrin aybara", "wolfbrother");
}
/**
@@ -117,6 +111,6 @@ public class BasicUsageTests {
template.opsForValue().set("nickname", "dragon reborn"); // slot 14594
template.opsForValue().set("age", "23"); // slot 741;
assertThat(template.keys("*"), hasItems("name", "nickname", "age"));
assertThat(template.keys("*")).contains("name", "nickname", "age");
}
}