use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testHeadMapContents.
/**
* headMap returns map with keys in requested range
*/
@Test
public void testHeadMapContents() {
ConcurrentNavigableMap map = map5();
NavigableMap sm = map.headMap(four, false);
assertTrue(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertFalse(sm.containsKey(four));
assertFalse(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer) (i.next());
assertEquals(one, k);
k = (Integer) (i.next());
assertEquals(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
assertFalse(i.hasNext());
if (isReadOnly())
return;
sm.clear();
assertTrue(sm.isEmpty());
assertEquals(2, map.size());
assertEquals(four, map.firstKey());
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testSubMapContents.
/**
* subMap returns map with keys in requested range
*/
@Test
public void testSubMapContents() {
ConcurrentNavigableMap map = map5();
NavigableMap sm = map.subMap(two, true, four, false);
assertEquals(two, sm.firstKey());
assertEquals(three, sm.lastKey());
assertEquals(2, sm.size());
assertFalse(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertFalse(sm.containsKey(four));
assertFalse(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer) (i.next());
assertEquals(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
assertFalse(i.hasNext());
Iterator r = sm.descendingKeySet().iterator();
k = (Integer) (r.next());
assertEquals(three, k);
k = (Integer) (r.next());
assertEquals(two, k);
assertFalse(r.hasNext());
if (isReadOnly())
return;
Iterator j = sm.keySet().iterator();
j.next();
j.remove();
assertFalse(map.containsKey(two));
assertEquals(4, map.size());
assertEquals(1, sm.size());
assertEquals(three, sm.firstKey());
assertEquals(three, sm.lastKey());
assertEquals("C", sm.remove(three));
assertTrue(sm.isEmpty());
assertEquals(3, map.size());
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testSize.
/**
* size returns the correct values
*/
@Test
public void testSize() {
ConcurrentNavigableMap map = map5();
ConcurrentNavigableMap empty = emptyMap();
assertEquals(0, empty.size());
assertEquals(5, map.size());
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testSize.
/**
* size returns the correct values
*/
@Test
public void testSize() {
ConcurrentNavigableMap map = map5();
ConcurrentNavigableMap empty = map0();
assertEquals(0, empty.size());
assertEquals(5, map.size());
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testReplaceValue.
/**
* replace value fails when the given key not mapped to expected value
*/
@Test
public void testReplaceValue() {
if (isReadOnly())
return;
ConcurrentNavigableMap map = map5();
assertEquals("A", map.get(one));
assertFalse(map.replace(one, "Z", "Z"));
assertEquals("A", map.get(one));
}
Aggregations