use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testKeySetToArray.
/**
* keySet.toArray returns contains all keys
*/
@Test
public void testKeySetToArray() {
ConcurrentNavigableMap map = map5();
Set s = map.keySet();
Object[] ar = s.toArray();
assertTrue(s.containsAll(Arrays.asList(ar)));
assertEquals(5, ar.length);
ar[0] = m10;
assertFalse(s.containsAll(Arrays.asList(ar)));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testPollFirstEntry.
/**
* pollFirstEntry returns entries in order
*/
@Test
public void testPollFirstEntry() {
if (isReadOnly())
return;
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);
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testDescendingPutIfAbsent2.
/**
* putIfAbsent does not add the pair if the key is already present
*/
@Test
public void testDescendingPutIfAbsent2() {
if (isReadOnly())
return;
ConcurrentNavigableMap map = dmap5();
assertEquals("A", map.putIfAbsent(m1, "Z"));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testRemove2.
/**
* remove(key,value) removes only if pair present
*/
@Test
public void testRemove2() {
if (isReadOnly())
return;
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 ConcurrentSkipListSubMapTest method testFirstKey.
/**
* firstKey returns first key
*/
@Test
public void testFirstKey() {
ConcurrentNavigableMap map = map5();
assertEquals(one, map.firstKey());
}
Aggregations