Search in sources :

Example 36 with CustomEntryConcurrentHashMap

use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.

the class ConcurrentHashMapJUnitTest method testValuesToArray.

/**
   * Values.toArray contains all values
   */
@Test
public void testValuesToArray() {
    CustomEntryConcurrentHashMap map = map5();
    Collection v = map.values();
    Object[] ar = v.toArray();
    ArrayList s = new ArrayList(Arrays.asList(ar));
    assertEquals(5, ar.length);
    assertTrue(s.contains("A"));
    assertTrue(s.contains("B"));
    assertTrue(s.contains("C"));
    assertTrue(s.contains("D"));
    assertTrue(s.contains("E"));
}
Also used : ArrayList(java.util.ArrayList) Collection(java.util.Collection) CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 37 with CustomEntryConcurrentHashMap

use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.

the class ConcurrentHashMapJUnitTest method testRemove3.

/**
   * remove(x, null) returns false
   */
@Test
public void testRemove3() {
    try {
        CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
        c.put("sadsdf", "asdads");
        assertFalse(c.remove("sadsdf", null));
    } catch (NullPointerException e) {
        fail();
    }
}
Also used : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 38 with CustomEntryConcurrentHashMap

use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.

the class ConcurrentHashMapJUnitTest method testContainsKey_NullPointerException.

/**
   * containsKey(null) throws NPE
   */
@Test
public void testContainsKey_NullPointerException() {
    try {
        CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
        c.containsKey(null);
        shouldThrow();
    } catch (NullPointerException e) {
    }
}
Also used : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 39 with CustomEntryConcurrentHashMap

use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.

the class ConcurrentHashMapJUnitTest method testContainsValue.

/**
   * containsValue returns true for held values
   */
@Test
public void testContainsValue() {
    CustomEntryConcurrentHashMap map = map5();
    assertTrue(map.containsValue("A"));
    assertFalse(map.containsValue("Z"));
}
Also used : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 40 with CustomEntryConcurrentHashMap

use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.

the class ConcurrentHashMapJUnitTest method testPutAll.

/**
   * putAll adds all key-value pairs from the given map
   */
@Test
public void testPutAll() {
    CustomEntryConcurrentHashMap empty = new CustomEntryConcurrentHashMap();
    CustomEntryConcurrentHashMap 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 : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

CustomEntryConcurrentHashMap (org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap)46 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)44 Test (org.junit.Test)44 Set (java.util.Set)4 Map (java.util.Map)3 Collection (java.util.Collection)2 Enumeration (java.util.Enumeration)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LRUEntry (org.apache.geode.internal.cache.lru.LRUEntry)1 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)1 StoredObject (org.apache.geode.internal.offheap.StoredObject)1 Released (org.apache.geode.internal.offheap.annotations.Released)1 Retained (org.apache.geode.internal.offheap.annotations.Retained)1