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;
}
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);
}
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));
}
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));
}
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) {
}
}
Aggregations