new tests added

pull/243/head
Nikita 10 years ago
parent 63543ced1c
commit 2464df938d

@ -16,4 +16,26 @@ public class RedissonHyperLogLogTest extends BaseTest {
Assert.assertEquals(3L, log.count());
}
@Test
public void testMerge() {
RHyperLogLog<String> hll1 = redisson.getHyperLogLog("hll1");
Assert.assertTrue(hll1.add("foo"));
Assert.assertTrue(hll1.add("bar"));
Assert.assertTrue(hll1.add("zap"));
Assert.assertTrue(hll1.add("a"));
RHyperLogLog<String> hll2 = redisson.getHyperLogLog("hll2");
Assert.assertTrue(hll2.add("a"));
Assert.assertTrue(hll2.add("b"));
Assert.assertTrue(hll2.add("c"));
Assert.assertTrue(hll2.add("foo"));
Assert.assertFalse(hll2.add("c"));
RHyperLogLog<String> hll3 = redisson.getHyperLogLog("hll3");
hll3.mergeWith("hll1", "hll2");
Assert.assertEquals(6L, hll3.count());
}
}

@ -1,9 +1,5 @@
package org.redisson;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.lambdaworks.redis.RedisException;
import io.netty.util.concurrent.Future;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
@ -12,12 +8,16 @@ import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.core.Predicate;
import org.redisson.core.RMap;
import io.netty.util.concurrent.Future;
public class RedissonMapTest extends BaseTest {
public static class SimpleKey implements Serializable {
@ -121,7 +121,7 @@ public class RedissonMapTest extends BaseTest {
}
}
@Test
public void testAddAndGet() throws InterruptedException {
RMap<Integer, Integer> map = redisson.getMap("getAll");
@ -231,6 +231,19 @@ public class RedissonMapTest extends BaseTest {
Assert.assertEquals("43", val3);
}
@Test
public void testEntrySet() {
Map<Integer, String> map = redisson.getMap("simple12");
map.put(1, "12");
map.put(2, "33");
map.put(3, "43");
Assert.assertEquals(3, map.entrySet().size());
MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(1), Matchers.equalTo("12")));
MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(2), Matchers.equalTo("33")));
MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(3), Matchers.equalTo("43")));
}
@Test
public void testSimpleTypes() {
Map<Integer, String> map = redisson.getMap("simple12");
@ -468,6 +481,14 @@ public class RedissonMapTest extends BaseTest {
Assert.assertEquals(1, map.size());
}
@Test
public void testFastPut() throws Exception {
RMap<Integer, Integer> map = redisson.getMap("simple");
Assert.assertTrue(map.fastPut(1, 2));
Assert.assertFalse(map.fastPut(1, 3));
Assert.assertEquals(1, map.size());
}
@Test
public void testFastRemoveEmpty() throws Exception {
RMap<Integer, Integer> map = redisson.getMap("simple");

Loading…
Cancel
Save