use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testHigherKey.
/**
* higherKey returns next element
*/
@Test
public void testHigherKey() {
ConcurrentNavigableMap q = map5();
Object e1 = q.higherKey(three);
assertEquals(four, e1);
Object e2 = q.higherKey(zero);
assertEquals(one, e2);
Object e3 = q.higherKey(five);
assertNull(e3);
Object e4 = q.higherKey(six);
assertNull(e4);
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testDescendingKeySetOrder.
/**
* descendingKeySet is ordered
*/
@Test
public void testDescendingKeySetOrder() {
ConcurrentNavigableMap map = map5();
Set s = map.descendingKeySet();
Iterator i = s.iterator();
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 testPutIfAbsent2.
/**
* putIfAbsent does not add the pair if the key is already present
*/
@Test
public void testPutIfAbsent2() {
ConcurrentNavigableMap map = map5();
assertEquals("A", map.putIfAbsent(one, "Z"));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testEntrySet.
/**
* entrySet contains all pairs
*/
@Test
public void testEntrySet() {
ConcurrentNavigableMap map = map5();
Set s = map.entrySet();
assertEquals(5, s.size());
Iterator it = s.iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry) it.next();
assertTrue((e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || (e.getKey().equals(three) && e.getValue().equals("C")) || (e.getKey().equals(four) && e.getValue().equals("D")) || (e.getKey().equals(five) && e.getValue().equals("E")));
}
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testRemove2_NullPointerException.
/**
* remove(null, x) throws NPE
*/
@Test
public void testRemove2_NullPointerException() {
ConcurrentNavigableMap c = emptyMap();
c.put(123234234, "asdads");
try {
c.remove(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {
}
}
Aggregations