refactoring

pull/6406/head
Nikita Koksharov 1 week ago
parent dd4a63eb71
commit f7f0bd8750

@ -45,7 +45,7 @@ public class JCacheTest {
private static final GenericContainer<?> REDIS = private static final GenericContainer<?> REDIS =
new GenericContainer<>("redis:latest") new GenericContainer<>("redis:latest")
.withCreateContainerCmdModifier(cmd -> { .withCreateContainerCmdModifier(cmd -> {
cmd.withCmd("redis-server", "--save", "''"); cmd.withCmd("redis-server", "--save", "''", "--notify-keyspace-events", "Eh");
}) })
.withExposedPorts(6379); .withExposedPorts(6379);
@ -59,13 +59,16 @@ public class JCacheTest {
assertThat(r.getExitCode()).isEqualTo(0); assertThat(r.getExitCode()).isEqualTo(0);
} }
<K, V> MutableConfiguration<K, V> createConfig() {
return new MutableConfiguration<>();
}
@Test @Test
public void testClose() throws IOException { public void testClose() throws IOException {
URL configUrl = getClass().getResource("redisson-jcache.yaml"); URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl); Config cfg = Config.fromYAML(configUrl);
MutableConfiguration c = new MutableConfiguration(); MutableConfiguration<String, String> c = createConfig();
c.setStatisticsEnabled(true); c.setStatisticsEnabled(true);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg, c); Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg, c);
Cache<String, String> cache = Caching.getCachingProvider() Cache<String, String> cache = Caching.getCachingProvider()
@ -78,7 +81,7 @@ public class JCacheTest {
URL configUrl = getClass().getResource("redisson-jcache.yaml"); URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl); Config cfg = Config.fromYAML(configUrl);
MutableConfiguration c = new MutableConfiguration(); MutableConfiguration c = createConfig();
c.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(MILLISECONDS, 500))); c.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(MILLISECONDS, 500)));
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg, c); Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg, c);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager() Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()
@ -261,7 +264,7 @@ public class JCacheTest {
URL configUrl = getClass().getResource("redisson-jcache.yaml"); URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl); Config cfg = Config.fromYAML(configUrl);
MutableConfiguration<String, String> jcacheConfig = new MutableConfiguration<>(); MutableConfiguration<String, String> jcacheConfig = createConfig();
jcacheConfig.setReadThrough(true); jcacheConfig.setReadThrough(true);
jcacheConfig.setCacheLoaderFactory(new Factory<CacheLoader<String, String>>() { jcacheConfig.setCacheLoaderFactory(new Factory<CacheLoader<String, String>>() {
@Override @Override
@ -379,7 +382,7 @@ public class JCacheTest {
@Test @Test
public void testExpiration() throws InterruptedException, IllegalArgumentException, URISyntaxException { public void testExpiration() throws InterruptedException, IllegalArgumentException, URISyntaxException {
MutableConfiguration<String, String> config = new MutableConfiguration<>(); MutableConfiguration<String, String> config = createConfig();
config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1))); config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
config.setStoreByValue(true); config.setStoreByValue(true);
@ -407,7 +410,7 @@ public class JCacheTest {
@Test @Test
public void testUpdate() throws InterruptedException, URISyntaxException { public void testUpdate() throws InterruptedException, URISyntaxException {
MutableConfiguration<String, String> config = new MutableConfiguration<>(); MutableConfiguration<String, String> config = createConfig();
config.setStoreByValue(true); config.setStoreByValue(true);
URI configUri = getClass().getResource("redisson-jcache.yaml").toURI(); URI configUri = getClass().getResource("redisson-jcache.yaml").toURI();
@ -437,7 +440,7 @@ public class JCacheTest {
@Test @Test
public void testUpdateAsync() throws InterruptedException, URISyntaxException { public void testUpdateAsync() throws InterruptedException, URISyntaxException {
MutableConfiguration<String, String> config = new MutableConfiguration<>(); MutableConfiguration<String, String> config = createConfig();
config.setStoreByValue(true); config.setStoreByValue(true);
URI configUri = getClass().getResource("redisson-jcache.yaml").toURI(); URI configUri = getClass().getResource("redisson-jcache.yaml").toURI();
@ -472,7 +475,7 @@ public class JCacheTest {
@Test @Test
public void testUpdateWithoutOldValue() throws InterruptedException, URISyntaxException { public void testUpdateWithoutOldValue() throws InterruptedException, URISyntaxException {
MutableConfiguration<String, String> config = new MutableConfiguration<>(); MutableConfiguration<String, String> config = createConfig();
config.setStoreByValue(true); config.setStoreByValue(true);
URI configUri = getClass().getResource("redisson-jcache.yaml").toURI(); URI configUri = getClass().getResource("redisson-jcache.yaml").toURI();
@ -502,7 +505,7 @@ public class JCacheTest {
@Test @Test
public void testRemoveListener() throws InterruptedException, URISyntaxException { public void testRemoveListener() throws InterruptedException, URISyntaxException {
MutableConfiguration<String, String> config = new MutableConfiguration<>(); MutableConfiguration<String, String> config = createConfig();
config.setStoreByValue(true); config.setStoreByValue(true);
URI configUri = getClass().getResource("redisson-jcache.yaml").toURI(); URI configUri = getClass().getResource("redisson-jcache.yaml").toURI();

Loading…
Cancel
Save