Search in sources :

Example 86 with ConcurrentMap

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

the class ConcurrentHashMapTest method testRemove2_NullPointerException.

/**
     * remove(null, x) throws NPE
     */
public void testRemove2_NullPointerException() {
    ConcurrentMap c = map();
    c.put("sadsdf", "asdads");
    try {
        c.remove(null, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 87 with ConcurrentMap

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

the class ConcurrentHashMapTest method testRemove1_NullPointerException.

/**
     * remove(null) throws NPE
     */
public void testRemove1_NullPointerException() {
    ConcurrentMap c = map();
    c.put("sadsdf", "asdads");
    try {
        c.remove(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 88 with ConcurrentMap

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

the class ConcurrentHashMapTest method testIsEmpty.

/**
     * isEmpty is true of empty map and false for non-empty
     */
public void testIsEmpty() {
    ConcurrentMap empty = map();
    ConcurrentMap map = map5();
    assertTrue(empty.isEmpty());
    assertFalse(map.isEmpty());
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 89 with ConcurrentMap

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

the class ConcurrentHashMapTest method testKeySetToArray.

/**
     * keySet.toArray returns contains all keys
     */
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)));
}
Also used : Set(java.util.Set) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 90 with ConcurrentMap

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

the class ConcurrentHashMapTest method testPutAll.

/**
     * putAll adds all key-value pairs from the given map
     */
public void testPutAll() {
    ConcurrentMap empty = map();
    ConcurrentMap map = map5();
    empty.putAll(map);
    assertEquals(5, empty.size());
    assertTrue(empty.containsKey(one));
    assertTrue(empty.containsKey(two));
    assertTrue(empty.containsKey(three));
    assertTrue(empty.containsKey(four));
    assertTrue(empty.containsKey(five));
}
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