Package com.hazelcast.core

Examples of com.hazelcast.core.IList


//  ===================== SubList ========================

    @Test
    public void testSublist() {
        IList list = newList_withInitialData(10);
        List listTest = list.subList(3, 7);
        assertEquals(4, listTest.size());
        assertIterableEquals(listTest, "item3", "item4", "item5", "item6");
    }
View Full Code Here


        assertIterableEquals(listTest, "item3", "item4", "item5", "item6");
    }

    @Test(expected = IndexOutOfBoundsException.class)
    public void testSublist_whenFromIndexIllegal() {
        IList list = newList();
        list.subList(8, 7);
    }
View Full Code Here

        list.subList(8, 7);
    }

    @Test(expected = IndexOutOfBoundsException.class)
    public void testSublist_whenToIndexIllegal() {
        IList list = newList_withInitialData(10);
        list.subList(4, 14);
    }
View Full Code Here

//    ================== Iterator ====================

    @Test
    public void testIterator() {
        IList list = newList_withInitialData(10);
        ListIterator iterator = list.listIterator();
        int i = 0;
        while (iterator.hasNext()) {
            Object o = iterator.next();
            assertEquals(o, "item" + i++);
        }
View Full Code Here

        }
    }

    @Test
    public void testIteratorWithIndex() {
        IList list = newList_withInitialData(10);
        int i = 4;
        ListIterator iterator = list.listIterator(i);
        while (iterator.hasNext()) {
            Object o = iterator.next();
            assertEquals(o, "item" + i++);
        }
    }
View Full Code Here

    public void testAddRemove() {
        final String name = randomString();
        final int count = 100;
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        final HazelcastInstance[] instances = factory.newInstances();
        IList list1 = instances[0].getList(name);
        IList list2 = instances[1].getList(name);
        for (int i = 0; i < count; i++) {
            assertTrue(list1.add("item" + i));
            assertTrue(list2.add("item" + i));
        }
        assertSizeEventually(200, list1);
        assertSizeEventually(200, list2);
        assertEquals("item0", list1.get(0));
        assertEquals("item0", list2.get(0));
        assertEquals("item99", list1.get(199));
        assertEquals("item99", list2.get(199));

        for (int i = 0; i < count; i++) {
            assertEquals("item" + i, list1.remove(i));
        }
        assertSizeEventually(100, list2);
        for (int i = 0; i < count; i++) {
            assertTrue(list2.remove("item" + i));
        }
        assertSizeEventually(0, list1);
        assertSizeEventually(0, list2);
    }
View Full Code Here

    public void testAddContainsRemoveRetainsAll() {
        final String name = randomString();
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        HazelcastInstance instance1 = factory.newHazelcastInstance();
        HazelcastInstance instance2 = factory.newHazelcastInstance();
        IList list1 = instance1.getList(name);
        IList list2 = instance2.getList(name);
        List listTest1 = new ArrayList();
        for (int i = 0; i < 100; i++) {
            listTest1.add("item" + i);
        }
        assertTrue(list1.addAll(listTest1));
        assertSizeEventually(100,list2);
        List listTest2 = new ArrayList();
        for (int i = 30; i < 40; i++) {
            listTest2.add("item" + i);
        }
        assertTrue(list2.containsAll(listTest2));
        assertTrue(list2.retainAll(listTest2));
        assertSizeEventually(10,list1);
        assertTrue(list1.removeAll(listTest2));
        assertSizeEventually(0, list1);
    }
View Full Code Here

    @Test
    public void testShutdown() {
        final String name = randomString();
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        final HazelcastInstance[] instances = factory.newInstances();
        IList list1 = instances[0].getList(name);
        IList list2 = instances[1].getList(name);
        warmUpPartitions(instances);

        for (int i = 0; i < 50; i++) {
            list1.add("item" + i);
        }
        instances[0].shutdown();
        assertSizeEventually(50, list2);
         for (int i = 50; i < 100; i++) {
            list2.add("item" + i);
        }
        for (int i = 0; i < 100; i++) {
            assertEquals("item" + i, list2.remove(0));
        }
    }
View Full Code Here

        final String name = randomString();
        config.addListConfig(new ListConfig().setName(name).setBackupCount(1));
        final int insCount = 4;
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(insCount);
        HazelcastInstance instance1 = factory.newHazelcastInstance(config);
        IList list = instance1.getList(name);

        for (int i = 0; i < 100; i++) {
            list.add("item" + i);
        }

        HazelcastInstance instance2 = factory.newHazelcastInstance(config);
        assertEquals(100, instance2.getList(name).size());

        HazelcastInstance instance3 = factory.newHazelcastInstance(config);
        assertEquals(100, instance3.getList(name).size());

        instance1.shutdown();
        assertEquals(100, instance3.getList(name).size());

        list = instance2.getList(name);
        for (int i = 0; i < 100; i++) {
            list.add("item-" + i);
        }

        instance2.shutdown();
        assertEquals(200, instance3.getList(name).size());
View Full Code Here

        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(insCount);

        HazelcastInstance instance1 = factory.newHazelcastInstance(config);
        HazelcastInstance instance2 = factory.newHazelcastInstance(config);

        IList list = instance1.getList(name);

        for (int i = 0; i < 100; i++) {
            assertTrue(list.add("item" + i));
        }
        assertFalse(list.add("item"));
        assertNotNull(list.remove(0));
        assertTrue(list.add("item"));
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.core.IList

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.