Search in sources :

Example 46 with ConcurrentMap

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

the class ConcurrentHashMapTest method testContainsKey.

/**
     * containsKey returns true for contained key
     */
@Test
public void testContainsKey() {
    ConcurrentMap map = map5();
    assertTrue(map.containsKey(one));
    assertFalse(map.containsKey(zero));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) Test(org.junit.Test)

Example 47 with ConcurrentMap

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

the class ConcurrentHashMapV8Test 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)

Example 48 with ConcurrentMap

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

the class ConcurrentHashMapV8Test method testContainsKey_NullPointerException.

/**
     * containsKey(null) throws NPE
     */
public void testContainsKey_NullPointerException() {
    try {
        ConcurrentMap c = newMap(5);
        c.containsKey(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 49 with ConcurrentMap

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

the class ConcurrentHashMapV8Test method testPutIfAbsent2_NullPointerException.

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

Example 50 with ConcurrentMap

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

the class ConcurrentHashMapV8Test method testKeySet.

/**
     * keySet returns a Set containing all the keys
     */
public void testKeySet() {
    ConcurrentMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(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