Package com.hazelcast.core

Examples of com.hazelcast.core.IList


    @Test
    public void testList() throws Exception {
        String partitionKey = "hazelcast";
        HazelcastInstance hz = getHazelcastInstance(partitionKey);

        IList list = hz.getList("list@" + partitionKey);
        list.add("");
        assertEquals("list@" + partitionKey, list.getName());
        assertEquals(partitionKey, list.getPartitionKey());

        ListService service = getNodeEngine(hz).getService(ListService.SERVICE_NAME);
        assertTrue(service.getContainerMap().containsKey(list.getName()));
    }
View Full Code Here


    }

    @Test
    public void testAddRemove() throws Exception {
        String listName = randomString();
        final IList l = client.getList(listName);
        l.add("item1");

        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        final TransactionalList<Object> list = context.getList(listName);
        assertTrue(list.add("item2"));
        assertEquals(2, list.size());
        assertEquals(1, l.size());
        assertFalse(list.remove("item3"));
        assertTrue(list.remove("item1"));

        context.commitTransaction();

        assertEquals(1, l.size());
    }
View Full Code Here

    }

    @Test
    public void testAddAndRoleBack() throws Exception {
        final String listName = randomString();
        final IList l = client.getList(listName);
        l.add("item1");

        final TransactionContext context = client.newTransactionContext();
        context.beginTransaction();
        final TransactionalList<Object> list = context.getList(listName);
        list.add("item2");
        context.rollbackTransaction();

        assertEquals(1, l.size());
    }
View Full Code Here

//    ====================== Clear =======================

    @Test
    public void testClear() {
        IList list = newList_withInitialData(10);
        list.clear();
        assertEquals(0, list.size());
    }
View Full Code Here

//    ===================== Contains ========================

    @Test
    public void testContains() {
        IList list = newList_withInitialData(10);
        assertTrue(list.contains("item1"));
        assertTrue(list.contains("item5"));
        assertTrue(list.contains("item7"));
        assertFalse(list.contains("item11"));
    }
View Full Code Here

//   ===================== ContainsAll =========================

    @Test
    public void testContainsAll() {
        IList list = newList_withInitialData(10);
        List listTest = new ArrayList<String>();
        listTest.add("item1");
        listTest.add("item4");
        listTest.add("item7");

        assertTrue(list.containsAll(listTest));
    }
View Full Code Here

        assertTrue(list.containsAll(listTest));
    }

    @Test
    public void testContainsAll_whenListNotContains() {
        IList list = newList_withInitialData(10);
        List listTest = new ArrayList<String>();
        listTest.add("item1");
        listTest.add("item4");
        listTest.add("item14");

        assertFalse(list.containsAll(listTest));
    }
View Full Code Here

        assertFalse(list.containsAll(listTest));
    }

    @Test(expected = NullPointerException.class)
    public void testContainsAll_whenCollectionNull() {
        IList list = newList_withInitialData(10);
        List listTest = null;
        list.containsAll(listTest);
    }
View Full Code Here

//    ===================== Get ========================

    @Test
    public void testGet() {
        IList list = newList_withInitialData(10);
        assertEquals("item1", list.get(1));
        assertEquals("item7", list.get(7));
        assertEquals("item9", list.get(9));
    }
View Full Code Here

        assertEquals("item9", list.get(9));
    }

    @Test(expected = IndexOutOfBoundsException.class)
    public void testGet_whenIndexNotExists() {
        IList list = newList_withInitialData(10);
        list.get(14);
    }
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.