use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testKeySetDescendingIteratorOrder.
/**
* descending iterator of key set is inverse ordered
*/
@Test
public void testKeySetDescendingIteratorOrder() {
ConcurrentNavigableMap map = map5();
NavigableSet s = map.navigableKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer) i.next();
assertEquals(last, five);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer) i.next();
assertTrue(last.compareTo(k) > 0);
last = k;
++count;
}
assertEquals(5, count);
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testReplace2.
/**
* replace succeeds if the key is already present
*/
@Test
public void testReplace2() {
ConcurrentNavigableMap map = map5();
assertNotNull(map.replace(one, "Z"));
assertEquals("Z", map.get(one));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testRemove2.
/**
* remove(key,value) removes only if pair present
*/
@Test
public void testRemove2() {
ConcurrentNavigableMap map = map5();
assertTrue(map.containsKey(five));
assertEquals("E", map.get(five));
map.remove(five, "E");
assertEquals(4, map.size());
assertFalse(map.containsKey(five));
map.remove(four, "A");
assertEquals(4, map.size());
assertTrue(map.containsKey(four));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testReplace.
/**
* replace fails when the given key is not present
*/
@Test
public void testReplace() {
ConcurrentNavigableMap map = map5();
assertNull(map.replace(six, "Z"));
assertFalse(map.containsKey(six));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testCeilingEntry.
/**
* ceilingEntry returns next entry.
*/
@Test
public void testCeilingEntry() {
ConcurrentNavigableMap map = map5();
Map.Entry e1 = map.ceilingEntry(three);
assertEquals(three, e1.getKey());
Map.Entry e2 = map.ceilingEntry(zero);
assertEquals(one, e2.getKey());
Map.Entry e3 = map.ceilingEntry(five);
assertEquals(five, e3.getKey());
Map.Entry e4 = map.ceilingEntry(six);
assertNull(e4);
}
Aggregations