@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user