Search in sources :

Example 11 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingPollFirstEntry.

/**
     * pollFirstEntry returns entries in order
     */
@Test
public void testDescendingPollFirstEntry() {
    if (isReadOnly())
        return;
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m2, e.getKey());
    map.put(m1, "A");
    e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m3, e.getKey());
    map.remove(m4);
    e = map.pollFirstEntry();
    assertEquals(m5, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {
    }
    e = map.pollFirstEntry();
    assertNull(e);
}
Also used : Map(java.util.Map) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 12 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingClear.

/**
     * clear removes all pairs
     */
@Test
public void testDescendingClear() {
    if (isReadOnly())
        return;
    ConcurrentNavigableMap map = dmap5();
    map.clear();
    assertEquals(0, map.size());
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 13 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingReplaceValue_NullPointerException.

/**
     * replace(null, x, y) throws NPE
     */
@Test
public void testDescendingReplaceValue_NullPointerException() {
    if (isReadOnly())
        return;
    try {
        ConcurrentNavigableMap c = dmap5();
        c.replace(null, m1, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 14 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testHigherEntry.

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

Example 15 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testContainsValue_NullPointerException.

/**
     * containsValue(null) throws NPE
     */
@Test
public void testContainsValue_NullPointerException() {
    try {
        ConcurrentNavigableMap c = map0();
        c.containsValue(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
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