Search in sources :

Example 16 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingValuesToArray.

/**
     * Values.toArray contains all values
     */
@Test
public void testDescendingValuesToArray() {
    ConcurrentNavigableMap map = dmap5();
    Collection v = map.values();
    Object[] ar = v.toArray();
    ArrayList s = new ArrayList(Arrays.asList(ar));
    assertEquals(5, ar.length);
    assertTrue(s.contains("A"));
    assertTrue(s.contains("B"));
    assertTrue(s.contains("C"));
    assertTrue(s.contains("D"));
    assertTrue(s.contains("E"));
}
Also used : ArrayList(java.util.ArrayList) Collection(java.util.Collection) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 17 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testPutIfAbsent2.

/**
     * putIfAbsent does not add the pair if the key is already present
     */
@Test
public void testPutIfAbsent2() {
    if (isReadOnly())
        return;
    ConcurrentNavigableMap map = map5();
    assertEquals("A", map.putIfAbsent(one, "Z"));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 18 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingPutAll.

/**
     * putAll adds all key-value pairs from the given map
     */
@Test
public void testDescendingPutAll() {
    if (isReadOnly())
        return;
    ConcurrentNavigableMap empty = dmap0();
    ConcurrentNavigableMap map = dmap5();
    empty.putAll(map);
    assertEquals(5, empty.size());
    assertTrue(empty.containsKey(m1));
    assertTrue(empty.containsKey(m2));
    assertTrue(empty.containsKey(m3));
    assertTrue(empty.containsKey(m4));
    assertTrue(empty.containsKey(m5));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 19 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingReplace.

/**
     * replace fails when the given key is not present
     */
@Test
public void testDescendingReplace() {
    if (isReadOnly())
        return;
    ConcurrentNavigableMap map = dmap5();
    assertNull(map.replace(six, "Z"));
    assertFalse(map.containsKey(six));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 20 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testIsEmpty.

/**
     * isEmpty is true of empty map and false for non-empty
     */
@Test
public void testIsEmpty() {
    ConcurrentNavigableMap empty = map0();
    ConcurrentNavigableMap map = map5();
    assertTrue(empty.isEmpty());
    assertFalse(map.isEmpty());
}
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