Search in sources :

Example 36 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 37 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)

Example 38 with ConcurrentMap

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

the class ConcurrentHashMapV8Test method testRemove1_NullPointerException.

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

Example 39 with ConcurrentMap

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

the class ConcurrentHashMapV8Test method testPutIfAbsent2.

/**
     * putIfAbsent does not add the pair if the key is already present
     */
public void testPutIfAbsent2() {
    ConcurrentMap map = map5();
    assertEquals("A", map.putIfAbsent(one, "Z"));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 40 with ConcurrentMap

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

the class ConcurrentHashMapV8Test method testContainsKey.

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

Aggregations

ConcurrentMap (java.util.concurrent.ConcurrentMap)450 Map (java.util.Map)125 Test (org.junit.Test)111 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)83 HashMap (java.util.HashMap)75 ArrayList (java.util.ArrayList)58 Set (java.util.Set)41 URL (com.alibaba.dubbo.common.URL)32 List (java.util.List)26 Collectors (java.util.stream.Collectors)22 IOException (java.io.IOException)21 HashSet (java.util.HashSet)21 Collection (java.util.Collection)19 UsageCount (org.apache.felix.framework.ServiceRegistry.UsageCount)19 Bundle (org.osgi.framework.Bundle)19 CountDownLatch (java.util.concurrent.CountDownLatch)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 Arrays (java.util.Arrays)15 Field (java.lang.reflect.Field)14 Iterator (java.util.Iterator)13