|
|
|
@ -8,6 +8,10 @@ import java.net.URI;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
@ -30,18 +34,43 @@ import org.redisson.RedisRunner;
|
|
|
|
|
import org.redisson.RedisRunner.FailedToStartRedisException;
|
|
|
|
|
import org.redisson.RedisRunner.RedisProcess;
|
|
|
|
|
import org.redisson.client.codec.JsonJacksonMapCodec;
|
|
|
|
|
import org.redisson.codec.JsonJacksonCodec;
|
|
|
|
|
import org.redisson.codec.SnappyCodec;
|
|
|
|
|
import org.redisson.config.Config;
|
|
|
|
|
import org.redisson.jcache.configuration.RedissonConfiguration;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
|
|
|
|
|
|
|
|
import reactor.io.codec.json.JacksonJsonCodec;
|
|
|
|
|
|
|
|
|
|
public class JCacheTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetAll() throws Exception {
|
|
|
|
|
RedisProcess runner = new RedisRunner()
|
|
|
|
|
.nosave()
|
|
|
|
|
.randomDir()
|
|
|
|
|
.port(6311)
|
|
|
|
|
.run();
|
|
|
|
|
|
|
|
|
|
URL configUrl = getClass().getResource("redisson-jcache.json");
|
|
|
|
|
Config cfg = Config.fromJSON(configUrl);
|
|
|
|
|
cfg.useSingleServer().setTimeout(300000);
|
|
|
|
|
|
|
|
|
|
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
|
|
|
|
|
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()
|
|
|
|
|
.createCache("test", config);
|
|
|
|
|
|
|
|
|
|
cache.put("1", "2");
|
|
|
|
|
cache.put("3", "4");
|
|
|
|
|
|
|
|
|
|
Map<String, String> entries = cache.getAll(new HashSet<String>(Arrays.asList("1", "3", "7")));
|
|
|
|
|
Map<String, String> expected = new HashMap<String, String>();
|
|
|
|
|
expected.put("1", "2");
|
|
|
|
|
expected.put("3", "4");
|
|
|
|
|
assertThat(entries).isEqualTo(expected);
|
|
|
|
|
|
|
|
|
|
cache.close();
|
|
|
|
|
runner.stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testJson() throws InterruptedException, IllegalArgumentException, URISyntaxException, IOException {
|
|
|
|
|
RedisProcess runner = new RedisRunner()
|
|
|
|
@ -66,7 +95,6 @@ public class JCacheTest extends BaseTest {
|
|
|
|
|
|
|
|
|
|
cache.close();
|
|
|
|
|
runner.stop();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|