use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testPut1_NullPointerException.
/**
* put(null,x) throws NPE
*/
@Test
public void testPut1_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
c.put(null, "whatever");
shouldThrow();
} catch (NullPointerException e) {
}
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testRemove2.
/**
* remove(key,value) removes only if pair present
*/
@Test
public void testRemove2() {
CustomEntryConcurrentHashMap 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 org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testEntrySet.
/**
* entrySet contains all pairs
*/
@Test
public void testEntrySet() {
CustomEntryConcurrentHashMap map = map5();
Set s = map.entrySet();
assertEquals(5, s.size());
Iterator it = s.iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry) it.next();
assertTrue((e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || (e.getKey().equals(three) && e.getValue().equals("C")) || (e.getKey().equals(four) && e.getValue().equals("D")) || (e.getKey().equals(five) && e.getValue().equals("E")));
}
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testSetValueWriteThrough.
/**
* SetValue of an EntrySet entry sets value in the map.
*/
@Test
public void testSetValueWriteThrough() {
// Adapted from a bug report by Eric Zoerner
CustomEntryConcurrentHashMap map = new CustomEntryConcurrentHashMap(2, 5.0f, 1);
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();
// assert that entry1 is not 16
assertTrue("entry is 16, test not valid", !entry1.getKey().equals(new Integer(16)));
// remove 16 (a different key) from map
// which just happens to cause entry1 to be cloned in map
map.remove(new Integer(16));
entry1.setValue("XYZ");
// fails
assertTrue(map.containsValue("XYZ"));
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testEnumeration.
/**
* enumeration returns an enumeration containing the correct elements
*/
@Test
public void testEnumeration() {
CustomEntryConcurrentHashMap map = map5();
Enumeration e = map.elements();
int count = 0;
while (e.hasMoreElements()) {
count++;
e.nextElement();
}
assertEquals(5, count);
}
Aggregations