Search in sources :

Example 91 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingDescendingKeySetToArray.

/**
     * descendingkeySet.toArray returns contains all keys
     */
@Test
public void testDescendingDescendingKeySetToArray() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.descendingKeySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    assertTrue(s.containsAll(Arrays.asList(ar)));
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
Also used : Set(java.util.Set) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 92 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingGet.

/**
     * get returns the correct element at the given key,
     * or null if not present
     */
@Test
public void testDescendingGet() {
    ConcurrentNavigableMap map = dmap5();
    assertEquals("A", (String) map.get(m1));
    ConcurrentNavigableMap empty = dmap0();
    assertNull(empty.get(m1));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 93 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testReplaceValue_NullPointerException.

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

Example 94 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testDescendingRemove2_NullPointerException.

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

Example 95 with ConcurrentNavigableMap

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

the class ConcurrentSkipListSubMapTest method testPollLastEntry.

/**
     * pollLastEntry returns entries in order
     */
@Test
public void testPollLastEntry() {
    if (isReadOnly())
        return;
    ConcurrentNavigableMap map = map5();
    Map.Entry e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(four, e.getKey());
    map.put(five, "E");
    e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(three, e.getKey());
    map.remove(two);
    e = map.pollLastEntry();
    assertEquals(one, e.getKey());
    try {
        e.setValue("E");
        shouldThrow();
    } catch (UnsupportedOperationException success) {
    }
    e = map.pollLastEntry();
    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)

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