|
|
@ -3,17 +3,15 @@ package org.redisson.rx;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.redisson.TestObject;
|
|
|
|
import org.redisson.TestObject;
|
|
|
|
|
|
|
|
import org.redisson.api.RSetCacheReactive;
|
|
|
|
import org.redisson.api.RSetCacheRx;
|
|
|
|
import org.redisson.api.RSetCacheRx;
|
|
|
|
|
|
|
|
|
|
|
|
public class RedissonSetCacheRxTest extends BaseRxTest {
|
|
|
|
public class RedissonSetCacheRxTest extends BaseRxTest {
|
|
|
@ -290,5 +288,23 @@ public class RedissonSetCacheRxTest extends BaseRxTest {
|
|
|
|
Assertions.assertEquals(0, sync(cache.size()).intValue());
|
|
|
|
Assertions.assertEquals(0, sync(cache.size()).intValue());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void testAddIfAbsentWithMapParam() throws InterruptedException {
|
|
|
|
|
|
|
|
sync(redisson.getKeys().flushall());
|
|
|
|
|
|
|
|
RSetCacheRx<String> cache = redisson.getSetCache("cache");
|
|
|
|
|
|
|
|
Map<String, Duration> map = new HashMap<>();
|
|
|
|
|
|
|
|
map.put("key1", Duration.ofMinutes(1));
|
|
|
|
|
|
|
|
map.put("key2", Duration.ofMinutes(1));
|
|
|
|
|
|
|
|
assertThat(sync(cache.addIfAbsent(map))).isTrue();
|
|
|
|
|
|
|
|
map = new HashMap<>();
|
|
|
|
|
|
|
|
map.put("key1", Duration.ofMinutes(1));
|
|
|
|
|
|
|
|
assertThat(sync(cache.addIfAbsent(map))).isFalse();
|
|
|
|
|
|
|
|
map = new HashMap<>();
|
|
|
|
|
|
|
|
map.put("key3", Duration.ofSeconds(1));
|
|
|
|
|
|
|
|
assertThat(sync(cache.addIfAbsent(map))).isTrue();
|
|
|
|
|
|
|
|
Thread.sleep(1200);
|
|
|
|
|
|
|
|
assertThat(sync(cache.addIfAbsent(map))).isTrue();
|
|
|
|
|
|
|
|
sync((redisson.getKeys().flushall()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|