use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testContainsKey_NullPointerException.
/**
* containsKey(null) throws NPE
*/
@Test
public void testContainsKey_NullPointerException() {
ConcurrentMap c = makeMap();
try {
c.containsKey(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testSetValueWriteThrough.
//TODO serialization
// /**
// * A deserialized map equals original
// */
// @Test public void testSerialization() throws Exception {
// Map x = map5();
// Map y = serialClone(x);
//
// assertNotSame(x, y);
// assertEquals(x.size(), y.size());
// assertEquals(x, y);
// assertEquals(y, x);
// }
/**
* SetValue of an EntrySet entry sets value in the map.
*/
@Test
public void testSetValueWriteThrough() {
// Adapted from a bug report by Eric Zoerner
ConcurrentMap map = makeGenericMap();
assertTrue(map.isEmpty());
for (int i = 0; i < 20; i++) map.put(new Integer(i), new Integer(i));
assertFalse(map.isEmpty());
Map.Entry entry1 = (Map.Entry) map.entrySet().iterator().next();
// cloned in map
if (!entry1.getKey().equals(new Integer(16))) {
map.remove(new Integer(16));
entry1.setValue("XYZ");
// fails if write-through broken
assertTrue(map.containsValue("XYZ"));
}
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testContains_NullPointerException.
/**
* contains(null) throws NPE
*/
@Test
public void testContains_NullPointerException() {
ConcurrentMap c = makeMap();
try {
c.containsKey(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method map5.
/**
* Returns a new map from Integers 1-5 to Strings "A"-"E".
*/
ConcurrentMap<Integer, String> map5() {
ConcurrentMap map = makeMap();
assertTrue(map.isEmpty());
map.put(one, "A");
map.put(two, "B");
map.put(three, "C");
map.put(four, "D");
map.put(five, "E");
assertFalse(map.isEmpty());
assertEquals(5, map.size());
return map;
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testKeySet.
/**
* keySet returns a Set containing all the keys
*/
@Test
public void testKeySet() {
ConcurrentMap map = map5();
Set s = map.keySet();
assertEquals(5, s.size());
assertTrue(s.contains(one));
assertTrue(s.contains(two));
assertTrue(s.contains(three));
assertTrue(s.contains(four));
assertTrue(s.contains(five));
}
Aggregations