@@ -15,24 +15,20 @@
|
||||
*/
|
||||
package example.springdata.redis.cluster;
|
||||
|
||||
import example.springdata.redis.test.util.RequiresRedisServer;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import example.springdata.redis.test.condition.EnabledOnRedisClusterAvailable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
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
|
||||
@@ -40,17 +36,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = { AppConfig.class })
|
||||
public class BasicUsageTests {
|
||||
@EnabledOnRedisClusterAvailable(port = 30001)
|
||||
class BasicUsageTests {
|
||||
|
||||
@Autowired RedisTemplate<String, String> template;
|
||||
|
||||
public static @ClassRule RequiresRedisServer redisServerAvailable = RequiresRedisServer.listeningAt("127.0.0.1",
|
||||
30001);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
template.execute((RedisCallback<String>) connection -> {
|
||||
connection.flushDb();
|
||||
@@ -63,7 +56,7 @@ public class BasicUsageTests {
|
||||
* -> {@code SLOT 5798} served by {@code 127.0.0.1:30002}
|
||||
*/
|
||||
@Test
|
||||
public void singleSlotOperation() {
|
||||
void singleSlotOperation() {
|
||||
|
||||
template.opsForValue().set("name", "rand al'thor"); // slot 5798
|
||||
assertThat(template.opsForValue().get("name")).isEqualTo("rand al'thor");
|
||||
@@ -75,7 +68,7 @@ public class BasicUsageTests {
|
||||
* -> {@code SLOT 14594} served by {@code 127.0.0.1:30003}
|
||||
*/
|
||||
@Test
|
||||
public void multiSlotOperation() {
|
||||
void multiSlotOperation() {
|
||||
|
||||
template.opsForValue().set("name", "matrim cauthon"); // slot 5798
|
||||
template.opsForValue().set("nickname", "prince of the ravens"); // slot 14594
|
||||
@@ -89,7 +82,7 @@ public class BasicUsageTests {
|
||||
* -> {@code SLOT 5798} served by {@code 127.0.0.1:30002}
|
||||
*/
|
||||
@Test
|
||||
public void fixedSlotOperation() {
|
||||
void fixedSlotOperation() {
|
||||
|
||||
template.opsForValue().set("{user}.name", "perrin aybara"); // slot 5474
|
||||
template.opsForValue().set("{user}.nickname", "wolfbrother"); // slot 5474
|
||||
@@ -105,7 +98,7 @@ public class BasicUsageTests {
|
||||
* -> {@code KEY nickname} served by {@code 127.0.0.1:30003}
|
||||
*/
|
||||
@Test
|
||||
public void multiNodeOperation() {
|
||||
void multiNodeOperation() {
|
||||
|
||||
template.opsForValue().set("name", "rand al'thor"); // slot 5798
|
||||
template.opsForValue().set("nickname", "dragon reborn"); // slot 14594
|
||||
|
||||
Reference in New Issue
Block a user