Search in sources :

Example 21 with ConcurrentMap

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

the class ConcurrentHashMapTest method testEntrySetToArray.

/**
     * entrySet.toArray contains all entries
     */
@Test
public void testEntrySetToArray() {
    ConcurrentMap map = map5();
    Set s = map.entrySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    for (int i = 0; i < 5; ++i) {
        assertTrue(map.containsKey(((Map.Entry) (ar[i])).getKey()));
        assertTrue(map.containsValue(((Map.Entry) (ar[i])).getValue()));
    }
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) Test(org.junit.Test)

Example 22 with ConcurrentMap

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

the class ConcurrentHashMapTest method testReplaceValue.

/**
     * replace value fails when the given key not mapped to expected value
     */
@Test
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) Test(org.junit.Test)

Example 23 with ConcurrentMap

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

the class ConcurrentHashMapTest method testReplace.

/**
     * replace fails when the given key is not present
     */
@Test
public void testReplace() {
    ConcurrentMap map = map5();
    assertNull(map.replace(six, "Z"));
    assertFalse(map.containsKey(six));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) Test(org.junit.Test)

Example 24 with ConcurrentMap

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

the class ConcurrentHashMapTest method testReplaceValue2.

/**
     * replace value succeeds when the given key mapped to expected value
     */
@Test
public void testReplaceValue2() {
    ConcurrentMap map = map5();
    assertEquals("A", map.get(one));
    assertTrue(map.replace(one, "A", "Z"));
    assertEquals("Z", map.get(one));
}
Also used : ConcurrentMap(java.util.concurrent.ConcurrentMap) Test(org.junit.Test)

Example 25 with ConcurrentMap

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

the class ConcurrentHashMapTest method testKeySetToArray.

/**
     * keySet.toArray returns contains all keys
     */
@Test
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) Test(org.junit.Test)

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