use of org.redisson.config.Config in project redisson by redisson.
the class RedissonTest method testNextResponseAfterDecoderError.
@Test
public void testNextResponseAfterDecoderError() throws Exception {
Config config = new Config();
config.useSingleServer().setConnectionMinimumIdleSize(1).setConnectionPoolSize(1).setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedissonClient redisson = Redisson.create(config);
setJSONValue(redisson, "test1", "test1");
setStringValue(redisson, "test2", "test2");
setJSONValue(redisson, "test3", "test3");
try {
RBuckets buckets = redisson.getBuckets(new JsonJacksonCodec());
buckets.get("test2", "test1");
} catch (Exception e) {
e.printStackTrace();
}
assertThat(getStringValue(redisson, "test3")).isEqualTo("\"test3\"");
redisson.shutdown();
}
use of org.redisson.config.Config in project redisson by redisson.
the class RedissonTwoLockedThread method testCountDown.
@ParameterizedTest
@MethodSource("data")
public void testCountDown(Codec codec) throws InterruptedException {
Config config = BaseTest.createConfig();
config.setCodec(codec);
RedissonClient redisson = Redisson.create(config);
Assertions.assertTimeout(Duration.ofSeconds(3), () -> {
final String countDownName = getClass().getName() + ":countDown#1";
final CountDownLatch startSignal = new CountDownLatch(1);
final CountDownLatch testSignal = new CountDownLatch(1);
final CountDownLatch completeSignal = new CountDownLatch(2);
System.out.println("configure");
final long millis = System.currentTimeMillis();
new Thread() {
@Override
public void run() {
try {
startSignal.await();
RCountDownLatch countDownLatch = redisson.getCountDownLatch(countDownName);
System.out.println("1. getCountDownLatch " + countDownLatch.getName() + " - " + Thread.currentThread().getId());
countDownLatch.trySetCount(1);
System.out.println("1. trySetCount " + countDownLatch.getName() + " - " + Thread.currentThread().getId());
Thread.sleep(500);
testSignal.countDown();
Thread.sleep(500);
System.out.println("1. sleep " + countDownLatch.getName() + " - " + Thread.currentThread().getId());
countDownLatch.countDown();
System.out.println("1. countDown " + countDownLatch.getName() + " - " + Thread.currentThread().getId());
} catch (InterruptedException e) {
e.printStackTrace();
}
completeSignal.countDown();
}
}.start();
new Thread() {
@Override
public void run() {
try {
testSignal.await();
RCountDownLatch countDownLatch = redisson.getCountDownLatch(countDownName);
System.out.println("2. getCountDownLatch " + countDownLatch.getName() + " - " + Thread.currentThread().getId());
countDownLatch.await();
System.out.println("2. await " + countDownLatch.getName() + " - " + Thread.currentThread().getId());
long current = System.currentTimeMillis();
Assertions.assertTrue((current - millis) >= 1000, "current=" + current + ", millis=" + millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
completeSignal.countDown();
}
}.start();
System.out.println("start");
startSignal.countDown();
completeSignal.await();
System.out.println("complete");
});
}
use of org.redisson.config.Config in project redisson by redisson.
the class JCacheTest method testGetAll.
@Test
public void testGetAll() throws Exception {
RedisProcess runner = new RedisRunner().nosave().randomDir().port(6311).run();
URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl);
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();
}
use of org.redisson.config.Config in project redisson by redisson.
the class JCacheTest method testReactive.
@Test
public void testReactive() throws Exception {
RedisProcess runner = new RedisRunner().nosave().randomDir().port(6311).run();
URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager().createCache("test", config);
CacheReactive<String, String> reactive = cache.unwrap(CacheReactive.class);
reactive.put("1", "2").block();
assertThat(reactive.get("1").block()).isEqualTo("2");
cache.close();
runner.stop();
}
use of org.redisson.config.Config in project redisson by redisson.
the class JCacheTest method testGetAllHighVolume.
@Test
public void testGetAllHighVolume() throws Exception {
RedisProcess runner = new RedisRunner().nosave().randomDir().port(6311).run();
URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager().createCache("test", config);
Map<String, String> m = new HashMap<>();
for (int i = 0; i < 10000; i++) {
m.put("" + i, "" + i);
}
cache.putAll(m);
Map<String, String> entries = cache.getAll(m.keySet());
assertThat(entries).isEqualTo(m);
cache.close();
runner.stop();
}
Aggregations