use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testEntrySetToArray.
/**
* entrySet.toArray contains all entries
*/
@Test
public void testEntrySetToArray() {
ConcurrentMap map = map5();
Set s = map.entrySet();
Object[] ar = s.toArray();
assertEquals(5, ar.length);
for (int i = 0; i < 5; ++i) {
assertTrue(map.containsKey(((Map.Entry) (ar[i])).getKey()));
assertTrue(map.containsValue(((Map.Entry) (ar[i])).getValue()));
}
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testReplaceValue.
/**
* replace value fails when the given key not mapped to expected value
*/
@Test
public void testReplaceValue() {
ConcurrentMap map = map5();
assertEquals("A", map.get(one));
assertFalse(map.replace(one, "Z", "Z"));
assertEquals("A", map.get(one));
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testReplace.
/**
* replace fails when the given key is not present
*/
@Test
public void testReplace() {
ConcurrentMap map = map5();
assertNull(map.replace(six, "Z"));
assertFalse(map.containsKey(six));
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testReplaceValue2.
/**
* replace value succeeds when the given key mapped to expected value
*/
@Test
public void testReplaceValue2() {
ConcurrentMap map = map5();
assertEquals("A", map.get(one));
assertTrue(map.replace(one, "A", "Z"));
assertEquals("Z", map.get(one));
}
use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.
the class ConcurrentHashMapTest method testKeySetToArray.
/**
* keySet.toArray returns contains all keys
*/
@Test
public void testKeySetToArray() {
ConcurrentMap 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)));
}
Aggregations