Package com.hazelcast.core

Examples of com.hazelcast.core.MultiMap


    }

    @Test(expected = NullPointerException.class)
    public void testContainsKey_whenNullKey() throws InterruptedException {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
        MultiMap multiMap = getMultiMap(factory.newInstances(), randomString());

        multiMap.containsKey(null);
    }
View Full Code Here


    }

    @Test(expected = NullPointerException.class)
    public void testContainsValue_whenNullKey() throws InterruptedException {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
        MultiMap multiMap = getMultiMap(factory.newInstances(), randomString());

        multiMap.containsValue(null);
    }
View Full Code Here

    }

    @Test(expected = NullPointerException.class)
    public void testContainsEntry_whenNullKey() throws InterruptedException {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
        MultiMap multiMap = getMultiMap(factory.newInstances(), randomString());

        multiMap.containsEntry(null, "someVal");
    }
View Full Code Here

    }

    @Test(expected = NullPointerException.class)
    public void testContainsEntry_whenNullValue() throws InterruptedException {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
        MultiMap multiMap = getMultiMap(factory.newInstances(), randomString());

        multiMap.containsEntry("someVal", null);
    }
View Full Code Here

    @Test
    public void testMultiMapPutGetRemove() {
        final HazelcastInstance instance = createHazelcastInstance();

        MultiMap mm = instance.getMultiMap("testMultiMapPutGetRemove");
        mm.put("1", "C");
        mm.put("2", "x");
        mm.put("2", "y");
        mm.put("1", "A");
        mm.put("1", "B");
        Collection g1 = mm.get("1");
        assertTrue(g1.contains("A"));
        assertTrue(g1.contains("B"));
        assertTrue(g1.contains("C"));
        assertEquals(5, mm.size());
        assertTrue(mm.remove("1", "C"));
        assertEquals(4, mm.size());
        Collection g2 = mm.get("1");
        assertTrue(g2.contains("A"));
        assertTrue(g2.contains("B"));
        assertFalse(g2.contains("C"));
        Collection r1 = mm.remove("2");
        assertTrue(r1.contains("x"));
        assertTrue(r1.contains("y"));
        assertNotNull(mm.get("2"));
        assertTrue(mm.get("2").isEmpty());
        assertEquals(2, mm.size());
        Collection r2 = mm.remove("1");
        assertTrue(r2.contains("A"));
        assertTrue(r2.contains("B"));
        assertNotNull(mm.get("1"));
        assertTrue(mm.get("1").isEmpty());
        assertEquals(0, mm.size());
    }
View Full Code Here

     * Issue 818
     */
    public void testMultiMapWithCustomSerializable() {
        final HazelcastInstance instance = createHazelcastInstance();

        MultiMap map = instance.getMultiMap("testMultiMapWithCustomSerializable");
        map.put("1", new CustomSerializable());
        assertEquals(1, map.size());
        map.remove("1");
        assertEquals(0, map.size());
    }
View Full Code Here


    @Test
    public void testMultiMapPutRemoveWithTxn() {
        final HazelcastInstance instance = createHazelcastInstance();
        MultiMap multiMap = instance.getMultiMap("testMultiMapPutRemoveWithTxn");

        multiMap.put("1", "C");
        multiMap.put("2", "x");
        multiMap.put("2", "y");

        final TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        TransactionalMultiMap txnMap = context.getMultiMap("testMultiMapPutRemoveWithTxn");
        txnMap.put("1", "A");
        txnMap.put("1", "B");
        Collection g1 = txnMap.get("1");
        assertTrue(g1.contains("A"));
        assertTrue(g1.contains("B"));
        assertTrue(g1.contains("C"));
        assertTrue(txnMap.remove("1", "C"));
        assertEquals(4, txnMap.size());
        Collection g2 = txnMap.get("1");
        assertTrue(g2.contains("A"));
        assertTrue(g2.contains("B"));
        assertFalse(g2.contains("C"));
        Collection r1 = txnMap.remove("2");
        assertTrue(r1.contains("x"));
        assertTrue(r1.contains("y"));
        assertEquals(0, txnMap.get("2").size());
        Collection r2 = txnMap.remove("1");
        assertEquals(2, r2.size());
        assertTrue(r2.contains("A"));
        assertTrue(r2.contains("B"));
        assertEquals(0, txnMap.get("1").size());
        assertEquals(0, txnMap.size());
        assertEquals(3, multiMap.size());
        context.commitTransaction();
        assertEquals(0, multiMap.size());
    }
View Full Code Here

        assertFalse(mm.containsEntry("NOT_THERE", "value1"));
    }

    @Test(expected = UnsupportedOperationException.class)
    public void testGetLocalMultiMapStats() {
        final MultiMap mm = client.getMultiMap(randomString());
        mm.getLocalMultiMapStats();
    }
View Full Code Here

        mm.getLocalMultiMapStats();
    }

    @Test
    public void testClear() {
        final MultiMap mm = client.getMultiMap(randomString());
        final int maxKeys = 9;
        final int maxValues = 3;

        for ( int key=0; key< maxKeys; key++ ){
            for ( int val=0; val< maxValues; val++ ){
                mm.put(key, val);
            }
        }
        mm.clear();
        assertEquals(0, mm.size());
    }
View Full Code Here

        Hazelcast.shutdownAll();
    }

    @Test
    public void testIsLocked_whenNotLocked() throws Exception {
        final MultiMap mm = client.getMultiMap(randomString());
        final Object key = "KeyNotLocked";
        final boolean result = mm.isLocked(key);
        assertFalse(result);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.core.MultiMap

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.