Package net.openhft.collections

Examples of net.openhft.collections.SharedHashMap


    /**
     * entrySet.toArray contains all entries
     */
    @Test
    public void testEntrySetToArray() throws IOException {
        SharedHashMap 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()));
        }
    }
View Full Code Here


    /**
     * values collection contains all values
     */
    @Test
    public void testValues() throws IOException {
        SharedHashMap map = map5();
        Collection s = map.values();
        assertEquals(5, s.size());
        assertTrue(s.contains("A"));
        assertTrue(s.contains("B"));
        assertTrue(s.contains("C"));
        assertTrue(s.contains("D"));
View Full Code Here

    /**
     * entrySet contains all pairs
     */
    @Test
    public void testEntrySet() throws IOException {
        SharedHashMap map = map5();
        Set s = map.entrySet();
        assertEquals(5, s.size());
        Iterator it = s.iterator();
        while (it.hasNext()) {
            Map.Entry e = (Map.Entry) it.next();
            assertTrue(
View Full Code Here

    /**
     * putAll adds all key-value pairs from the given map
     */
    @Test
    public void testPutAll() throws IOException {
        SharedHashMap empty = newShmIntString();
        SharedHashMap map = map5();
        empty.putAll(map);
        assertEquals(5, empty.size());
        assertTrue(empty.containsKey(one));
        assertTrue(empty.containsKey(two));
        assertTrue(empty.containsKey(three));
View Full Code Here

    /**
     * putIfAbsent works when the given key is not present
     */
    @Test
    public void testPutIfAbsent() throws IOException {
        SharedHashMap map = map5();
        map.putIfAbsent(six, "Z");
        assertTrue(map.containsKey(six));
    }
View Full Code Here

    /**
     * putIfAbsent does not add the pair if the key is already present
     */
    @Test
    public void testPutIfAbsent2() throws IOException {
        SharedHashMap map = map5();
        assertEquals("A", map.putIfAbsent(one, "Z"));
    }
View Full Code Here

    /**
     * replace fails when the given key is not present
     */
    @Test
    public void testReplace() throws IOException {
        SharedHashMap map = map5();
        assertNull(map.replace(six, "Z"));
        assertFalse(map.containsKey(six));
    }
View Full Code Here

    /**
     * replace succeeds if the key is already present
     */
    @Test
    public void testReplace2() throws IOException {
        SharedHashMap map = map5();
        assertNotNull(map.replace(one, "Z"));
        assertEquals("Z", map.get(one));
    }
View Full Code Here

    /**
     * replace value fails when the given key not mapped to expected value
     */
    @Test
    public void testReplaceValue() throws IOException {
        SharedHashMap map = map5();
        assertEquals("A", map.get(one));
        assertFalse(map.replace(one, "Z", "Z"));
        assertEquals("A", map.get(one));
    }
View Full Code Here

    /**
     * replace value succeeds when the given key mapped to expected value
     */
    @Test
    public void testReplaceValue2() throws IOException {
        SharedHashMap map = map5();
        assertEquals("A", map.get(one));
        assertTrue(map.replace(one, "A", "Z"));
        assertEquals("Z", map.get(one));
    }
View Full Code Here

TOP

Related Classes of net.openhft.collections.SharedHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.