Search in sources :

Example 11 with CustomEntryConcurrentHashMap

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

the class ConcurrentHashMapJUnitTest method testGet.

/**
   * get returns the correct element at the given key, or null if not present
   */
@Test
public void testGet() {
    CustomEntryConcurrentHashMap map = map5();
    assertEquals("A", (String) map.get(one));
    CustomEntryConcurrentHashMap empty = new CustomEntryConcurrentHashMap();
    assertNull(map.get("anything"));
}
Also used : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 12 with CustomEntryConcurrentHashMap

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

the class ConcurrentHashMapJUnitTest method testSize.

/**
   * size returns the correct values
   */
@Test
public void testSize() {
    CustomEntryConcurrentHashMap map = map5();
    CustomEntryConcurrentHashMap empty = new CustomEntryConcurrentHashMap();
    assertEquals(0, empty.size());
    assertEquals(5, map.size());
}
Also used : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 13 with CustomEntryConcurrentHashMap

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

the class ConcurrentHashMapJUnitTest method testRemove.

/**
   * remove removes the correct key-value pair from the map
   */
@Test
public void testRemove() {
    CustomEntryConcurrentHashMap map = map5();
    map.remove(five);
    assertEquals(4, map.size());
    assertFalse(map.containsKey(five));
}
Also used : CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 14 with CustomEntryConcurrentHashMap

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

the class ConcurrentHashMapJUnitTest method testKeySet.

/**
   * keySet returns a Set containing all the keys
   */
@Test
public void testKeySet() {
    CustomEntryConcurrentHashMap 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 : Set(java.util.Set) CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 15 with CustomEntryConcurrentHashMap

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

the class ConcurrentHashMapJUnitTest method testSerialization.

/**
   * A deserialized map equals original
   */
@Test
public void testSerialization() {
    CustomEntryConcurrentHashMap q = map5();
    try {
        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
        out.writeObject(q);
        out.close();
        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
        CustomEntryConcurrentHashMap r = (CustomEntryConcurrentHashMap) in.readObject();
        assertEquals(q.size(), r.size());
        assertTrue(q.equals(r));
        assertTrue(r.equals(q));
    } catch (Exception e) {
        e.printStackTrace();
        unexpectedException();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) CustomEntryConcurrentHashMap(org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap) ObjectInputStream(java.io.ObjectInputStream) 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