Search in sources :

Example 91 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.

the class ConcurrentHashMapTest method testGet_NullPointerException.

// Exception tests
/**
     * get(null) throws NPE
     */
public void testGet_NullPointerException() {
    ConcurrentMap c = map();
    try {
        c.get(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 92 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.

the class ConcurrentHashMapTest method testToString.

/**
     * toString contains toString of elements
     */
public void testToString() {
    ConcurrentMap map = map5();
    String s = map.toString();
    for (int i = 1; i <= 5; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 93 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.

the class ConcurrentHashMapTest method testClear.

/**
     * clear removes all pairs
     */
public void testClear() {
    ConcurrentMap map = map5();
    map.clear();
    assertEquals(0, map.size());
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 94 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.

the class ConcurrentHashMapTest method testPutIfAbsent.

/**
     * putIfAbsent works when the given key is not present
     */
public void testPutIfAbsent() {
    ConcurrentMap map = map5();
    map.putIfAbsent(six, "Z");
    assertTrue(map.containsKey(six));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 95 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.

the class ConcurrentHashMapTest method testReplaceValue.

/**
     * replace value fails when the given key not mapped to expected value
     */
public void testReplaceValue() {
    ConcurrentMap map = map5();
    assertEquals("A", map.get(one));
    assertFalse(map.replace(one, "Z", "Z"));
    assertEquals("A", map.get(one));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

ConcurrentMap (java.util.concurrent.ConcurrentMap)218 Map (java.util.Map)53 Test (org.junit.Test)47 HashMap (java.util.HashMap)31 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)28 ArrayList (java.util.ArrayList)26 Set (java.util.Set)20 URL (com.alibaba.dubbo.common.URL)17 Iterator (java.util.Iterator)11 IOException (java.io.IOException)10 Collection (java.util.Collection)10 Arrays (java.util.Arrays)9 Collections (java.util.Collections)8 HashSet (java.util.HashSet)7 List (java.util.List)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 LongAdder (java.util.concurrent.atomic.LongAdder)6 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)5