Package com.hazelcast.client

Examples of com.hazelcast.client.SimpleClient


        int size = 100;
        final IMap map = getMap();
        for (int i = 0; i < size; i++) {
            map.put("-" + i, "-" + i);
        }
        final SimpleClient client = getClient();
        client.send(new MapSizeRequest(mapName));
        assertEquals(size, client.receive());
    }
View Full Code Here


        final IMap map = getMap();
        for (int i = 0; i < size; i++) {
            map.put(i, "v" + i);
            testSet.add(i);
        }
        final SimpleClient client = getClient();
        client.send(new MapKeySetRequest(mapName));
        MapKeySet keyset = (MapKeySet) client.receive();
        for (Data o : keyset.getKeySet()) {
            Object x = TestUtil.toObject(o);
            assertTrue(testSet.remove(x));
        }
        assertEquals(0, testSet.size());
View Full Code Here

        final IMap map = getMap();
        for (int i = 0; i < size; i++) {
            map.put(i, "v" + i);
            testSet.add("v" + i);
        }
        final SimpleClient client = getClient();
        client.send(new MapValuesRequest(mapName));
        MapValueCollection values = (MapValueCollection) client.receive();
        for (Data o : values.getValues()) {
            Object x = TestUtil.toObject(o);
            assertTrue(testSet.remove(x));
        }
        assertEquals(0, testSet.size());
View Full Code Here

    }

    @Test
    public void testMapContainsKeyValue() throws IOException {
        int size = 100;
        final SimpleClient client = getClient();
        client.send(new MapContainsKeyRequest(mapName, TestUtil.toData("-")));
        assertFalse((Boolean) client.receive());
        for (int i = 0; i < size; i++) {
            getMap().put("-" + i, "-" + i);
        }
        for (int i = 0; i < size; i++) {
            client.send(new MapContainsKeyRequest(mapName, TestUtil.toData("-" + i)));
            assertTrue((Boolean) client.receive());
        }
        client.send(new MapContainsKeyRequest(mapName, TestUtil.toData("-")));
        assertFalse((Boolean) client.receive());


        client.send(new MapContainsValueRequest(mapName, TestUtil.toData("-")));
        assertFalse((Boolean) client.receive());
        for (int i = 0; i < size; i++) {
            client.send(new MapContainsValueRequest(mapName, TestUtil.toData("-" + i)));
            assertTrue((Boolean) client.receive());
        }
        client.send(new MapContainsValueRequest(mapName, TestUtil.toData("--")));
        assertFalse((Boolean) client.receive());
    }
View Full Code Here

    }

    @Test
    public void testMapRemoveDeleteEvict() throws IOException {
        final IMap map = getMap();
        final SimpleClient client = getClient();
        for (int i = 0; i < 100; i++) {
            map.put(i, i);
        }

        for (int i = 0; i < 100; i++) {
            getClient().send(new MapRemoveRequest(mapName, TestUtil.toData(i), ThreadUtil.getThreadId()));
            assertEquals(i, client.receive());
        }

        for (int i = 0; i < 100; i++) {
            map.put(i, i);
        }
        for (int i = 0; i < 100; i++) {
            client.send(new MapDeleteRequest(mapName, TestUtil.toData(i), ThreadUtil.getThreadId()));
            client.receive();
            assertNull(map.get(i));
        }

        for (int i = 0; i < 100; i++) {
            map.put(i, i);
        }
        for (int i = 0; i < 100; i++) {
            client.send(new MapEvictRequest(mapName, TestUtil.toData(i), ThreadUtil.getThreadId()));
            client.receive();
            assertNull(map.get(i));
        }

        assertEquals(0, map.size());
    }
View Full Code Here

    }

    @Test
    public void testRemoveIfSame() throws IOException {
        getMap().put(1, 5);
        final SimpleClient client = getClient();
        client.send(new MapRemoveIfSameRequest(mapName, TestUtil.toData(1), TestUtil.toData(3), ThreadUtil.getThreadId()));
        assertEquals(false, client.receive());
        client.send(new MapRemoveIfSameRequest(mapName, TestUtil.toData(1), TestUtil.toData(5), ThreadUtil.getThreadId()));
        assertEquals(true, client.receive());
        assertEquals(0, getMap().size());
    }
View Full Code Here

    @Test
    public void testPutIfAbsent() throws IOException {
        final IMap map = getMap();
        map.put(1, 3);
        final SimpleClient client = getClient();
        client.send(new MapPutIfAbsentRequest(mapName, TestUtil.toData(1), TestUtil.toData(5), ThreadUtil.getThreadId()));
        assertEquals(3, client.receive());
        client.send(new MapPutIfAbsentRequest(mapName, TestUtil.toData(2), TestUtil.toData(5), ThreadUtil.getThreadId()));
        assertEquals(null, client.receive());
        assertEquals(5, map.get(2));
    }
View Full Code Here

    @Test
    public void testMapReplace() throws IOException {
        final IMap map = getMap();
        map.put(1, 2);
        final SimpleClient client = getClient();
        client.send(new MapReplaceRequest(mapName, TestUtil.toData(1), TestUtil.toData(3), ThreadUtil.getThreadId()));
        assertEquals(2, client.receive());
        assertEquals(3, map.get(1));
        client.send(new MapReplaceRequest(mapName, TestUtil.toData(2), TestUtil.toData(3), ThreadUtil.getThreadId()));
        client.receive();
        assertEquals(null, map.get(2));
        client.send(new MapReplaceIfSameRequest(mapName, TestUtil.toData(1), TestUtil.toData(3), TestUtil.toData(5), ThreadUtil.getThreadId()));
        assertEquals(true, client.receive());
        assertEquals(5, map.get(1));
        client.send(new MapReplaceIfSameRequest(mapName, TestUtil.toData(1), TestUtil.toData(0), TestUtil.toData(7), ThreadUtil.getThreadId()));
        assertEquals(false, client.receive());
        assertEquals(5, map.get(1));
    }
View Full Code Here

        assertEquals(5, map.get(1));
    }

    @Test
    public void testMapTryPutRemove() throws IOException {
        final SimpleClient client = getClient();
        client.send(new MapLockRequest(mapName, TestUtil.toData(1), ThreadUtil.getThreadId() + 1));
        client.receive();
        assertEquals(true, getMap().isLocked(1));
        client.send(new MapTryPutRequest(mapName, TestUtil.toData(1), TestUtil.toData(1), ThreadUtil.getThreadId(), 0));
        assertEquals(false, client.receive());
        client.send(new MapTryRemoveRequest(mapName, TestUtil.toData(1), ThreadUtil.getThreadId(), 0));
        assertEquals(false, client.receive());
    }
View Full Code Here

        assertEquals(false, client.receive());
    }

    @Test
    public void testMapLockUnlock() throws IOException {
        final SimpleClient client = getClient();
        client.send(new MapLockRequest(mapName, TestUtil.toData(1), ThreadUtil.getThreadId()));
        client.receive();
        final IMap map = getMap();
        assertEquals(true, map.isLocked(1));
        client.send(new MapUnlockRequest(mapName, TestUtil.toData(1), ThreadUtil.getThreadId()));
        client.receive();
        assertEquals(false, map.isLocked(1));
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.client.SimpleClient

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.