use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method testKeySetSpliterator.
/**
* KeySetView.spliterator returns spliterator over the elements in this set
*/
public void testKeySetSpliterator() {
LongAdder adder = new LongAdder();
ConcurrentMap map = map5();
Set set = map.keySet();
Spliterator<Integer> sp = set.spliterator();
checkSpliteratorCharacteristics(sp, CONCURRENT | DISTINCT | NONNULL);
assertEquals(sp.estimateSize(), map.size());
Spliterator<Integer> sp2 = sp.trySplit();
sp.forEachRemaining((Integer x) -> adder.add(x.longValue()));
long v = adder.sumThenReset();
sp2.forEachRemaining((Integer x) -> adder.add(x.longValue()));
long v2 = adder.sum();
assertEquals(v + v2, 15);
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMapTest method testReplace_NullPointerException.
/**
* replace(null, x) throws NPE
*/
public void testReplace_NullPointerException() {
ConcurrentMap c = map();
try {
c.replace(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMapTest method testContainsValue_NullPointerException.
/**
* containsValue(null) throws NPE
*/
public void testContainsValue_NullPointerException() {
ConcurrentMap c = map();
try {
c.containsValue(null);
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMapTest method testPutIfAbsent1_NullPointerException.
/**
* putIfAbsent(null, x) throws NPE
*/
public void testPutIfAbsent1_NullPointerException() {
ConcurrentMap c = map();
try {
c.putIfAbsent(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {
}
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method testCompute.
/**
* compute does not replace if the function returns null
*/
public void testCompute() {
ConcurrentMap map = map5();
map.compute(six, (x, y) -> null);
assertFalse(map.containsKey(six));
}
Aggregations