use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testPutIfAbsent2_NullPointerException.
/**
* putIfAbsent(x, null) throws NPE
*/
@Test
public void testPutIfAbsent2_NullPointerException() {
ConcurrentMap c = makeMap();
try {
c.putIfAbsent("whatever", null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testRemove2.
/**
* remove(key,value) removes only if pair present
*/
@Test
public void testRemove2() {
ConcurrentMap map = map5();
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.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testContains.
//TODO hash code
// /**
// * hashCode() equals sum of each key.hashCode ^ value.hashCode
// */
// @Test public void testHashCode() {
// ConcurrentMap<Integer,String> map = map5();
// int sum = 0;
// for (Map.Entry<Integer,String> e : map.entrySet())
// sum += e.getKey().hashCode() ^ e.getValue().hashCode();
// assertEquals(sum, map.hashCode());
// }
/**
* contains returns true for contained value
*/
@Test
public void testContains() {
ConcurrentMap map = map5();
assertTrue(map.containsValue("A"));
assertFalse(map.containsValue("Z"));
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testReplace2.
/**
* replace succeeds if the key is already present
*/
@Test
public void testReplace2() {
ConcurrentMap map = map5();
assertNotNull(map.replace(one, "Z"));
assertEquals("Z", map.get(one));
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testRemove1_NullPointerException.
/**
* remove(null) throws NPE
*/
@Test
public void testRemove1_NullPointerException() {
ConcurrentMap c = makeGenericMap();
c.put("sadsdf", "asdads");
try {
c.remove(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
Aggregations