Search in sources :

Example 56 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.

the class ConcurrentHashMapV8Test method testRemove2.

/**
     * remove(key,value) removes only if pair present
     */
public void testRemove2() {
    ConcurrentMap 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));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 57 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.

the class ConcurrentHashMapV8Test 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 : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 58 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.

the class ConcurrentHashMapV8Test method testPut2_NullPointerException.

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

Example 59 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.

the class ConcurrentHashMapV8Test method testPutAll.

/**
     * putAll adds all key-value pairs from the given map
     */
public void testPutAll() {
    ConcurrentMap empty = newMap();
    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)

Example 60 with ConcurrentMap

use of java.util.concurrent.ConcurrentMap in project mapdb by jankotek.

the class ConcurrentHashMapV8Test method testGet.

/**
     * get returns the correct element at the given key,
     * or null if not present
     */
public void testGet() {
    ConcurrentMap map = map5();
    assertEquals("A", (String) map.get(one));
    ConcurrentMap empty = newMap();
    assertNull(map.get("anything"));
}
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