Search in sources :

Example 1 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testReplaceValue2.

/**
     * replace value succeeds when the given key mapped to expected value
     */
@Test
public void testReplaceValue2() {
    ConcurrentNavigableMap map = map5();
    assertEquals("A", map.get(one));
    assertTrue(map.replace(one, "A", "Z"));
    assertEquals("Z", map.get(one));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 2 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testLowerEntry.

/**
     * lowerEntry returns preceding entry.
     */
@Test
public void testLowerEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.lowerEntry(three);
    assertEquals(two, e1.getKey());
    Map.Entry e2 = map.lowerEntry(six);
    assertEquals(five, e2.getKey());
    Map.Entry e3 = map.lowerEntry(one);
    assertNull(e3);
    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 3 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testContainsKey.

/**
     * containsKey returns true for contained key
     */
@Test
public void testContainsKey() {
    ConcurrentNavigableMap map = map5();
    assertTrue(map.containsKey(one));
    assertFalse(map.containsKey(zero));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 4 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testPutIfAbsent1_NullPointerException.

/**
     * putIfAbsent(null, x) throws NPE
     */
@Test
public void testPutIfAbsent1_NullPointerException() {
    ConcurrentNavigableMap c = map5();
    try {
        c.putIfAbsent(null, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 5 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testKeySet.

/**
     * keySet returns a Set containing all the keys
     */
@Test
public void testKeySet() {
    ConcurrentNavigableMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Aggregations

ConcurrentNavigableMap (java.util.concurrent.ConcurrentNavigableMap)156 Test (org.junit.Test)147 SortedMap (java.util.SortedMap)25 Map (java.util.Map)19 NavigableMap (java.util.NavigableMap)19 Iterator (java.util.Iterator)12 Set (java.util.Set)10 Collection (java.util.Collection)4 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)4 Update (co.cask.cdap.data2.dataset2.lib.table.Update)3 ArrayList (java.util.ArrayList)2 IncrementValue (co.cask.cdap.data2.dataset2.lib.table.IncrementValue)1 PutValue (co.cask.cdap.data2.dataset2.lib.table.PutValue)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1