Search in sources :

Example 41 with ConcurrentNavigableMap

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

the class ConcurrentSkipListMapTest method map5.

/**
     * Returns a new map from Integers 1-5 to Strings "A"-"E".
     */
public ConcurrentNavigableMap map5() {
    ConcurrentNavigableMap map = emptyMap();
    assertTrue(map.isEmpty());
    map.put(one, "A");
    map.put(five, "E");
    map.put(three, "C");
    map.put(two, "B");
    map.put(four, "D");
    assertFalse(map.isEmpty());
    assertEquals(5, map.size());
    return map;
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap)

Example 42 with ConcurrentNavigableMap

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

the class ConcurrentSkipListMapTest method testPollFirstEntry.

/**
     * pollFirstEntry returns entries in order
     */
@Test
public void testPollFirstEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(one, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(two, e.getKey());
    map.put(one, "A");
    e = map.pollFirstEntry();
    assertEquals(one, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(three, e.getKey());
    map.remove(four);
    e = map.pollFirstEntry();
    assertEquals(five, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {
    }
    e = map.pollFirstEntry();
    assertNull(e);
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 43 with ConcurrentNavigableMap

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

the class ConcurrentSkipListMapTest method testReplaceValue.

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

Example 44 with ConcurrentNavigableMap

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

the class ConcurrentSkipListMapTest method testEquals.

//    /**
//     * copy constructor creates map equal to source map
//     */
//    @Test public void testConstructFromSorted() {
//        ConcurrentNavigableMap map = map5();
//        ConcurrentNavigableMap map2 = new ConcurrentNavigableMap(map);
//        assertEquals(map, map2);
//    }
/**
     * Maps with same contents are equal
     */
@Test
public void testEquals() {
    ConcurrentNavigableMap map1 = map5();
    ConcurrentNavigableMap map2 = map5();
    assertEquals(map1, map2);
    assertEquals(map2, map1);
    map1.clear();
    assertFalse(map1.equals(map2));
    assertFalse(map2.equals(map1));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 45 with ConcurrentNavigableMap

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

the class ConcurrentSkipListMapTest method testGet_NullPointerException.

/**
     * toString contains toString of elements
     */
//    @Test public void testToString() {
//        ConcurrentNavigableMap map = map5();
//        String s = map.toString();
//        for (int i = 1; i <= 5; ++i) {
//            assertTrue(s.contains(String.valueOf(i)));
//        }
//    }
// Exception tests
/**
     * get(null) of nonempty map throws NPE
     */
@Test
public void testGet_NullPointerException() {
    ConcurrentNavigableMap c = map5();
    try {
        c.get(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