Package com.hazelcast.client

Examples of com.hazelcast.client.SimpleClient


    @Test
    public void get() throws Exception {
        IAtomicReference<String> reference = getAtomicReference();

        final SimpleClient client = getClient();
        client.send(new GetRequest(name));
        assertNull(client.receive());

        reference.set("foo");
        client.send(new GetRequest(name));
        assertEquals("foo",client.receive());
    }
View Full Code Here


    @Test
    public void isNull() throws Exception {
        IAtomicReference<String> reference = getAtomicReference();

        final SimpleClient client = getClient();
        client.send(new IsNullRequest(name));
        assertEquals(Boolean.TRUE,client.receive());

        reference.set("foo");
        client.send(new IsNullRequest(name));
        assertEquals(Boolean.FALSE,client.receive());
    }
View Full Code Here

    @Test
    @ClientCompatibleTest
    public void contains()throws Exception {
        IAtomicReference<String> reference = getAtomicReference();
        final SimpleClient client = getClient();

        client.send(new ContainsRequest(name, toData(null)));
        assertEquals(Boolean.TRUE, client.receive());

        reference.set("foo");

        client.send(new ContainsRequest(name, toData(null)));
        assertEquals(Boolean.FALSE, client.receive());

        client.send(new ContainsRequest(name, toData("foo")));
        assertEquals(Boolean.TRUE,client.receive());

        client.send(new ContainsRequest(name, toData("bar")));
        assertEquals(Boolean.FALSE,client.receive());
    }
View Full Code Here

    @Test
    public void set() throws Exception {
        IAtomicReference<String> reference = getAtomicReference();

        final SimpleClient client = getClient();

        client.send(new SetRequest(name, toData(null)));
        assertNull(client.receive());
        assertNull(reference.get());

        client.send(new SetRequest(name, toData("foo")));
        assertNull(client.receive());
        assertEquals("foo", reference.get());

        client.send(new SetRequest(name, toData("foo")));
        assertNull(client.receive());
        assertEquals("foo", reference.get());

        client.send(new SetRequest(name, toData(null)));
        assertNull(client.receive());
        assertEquals(null,reference.get());
    }
View Full Code Here

    @Test
    public void getAndSet() throws Exception {
        IAtomicReference<String> reference = getAtomicReference();

        final SimpleClient client = getClient();

        client.send(new GetAndSetRequest(name, toData(null)));
        assertNull(client.receive());
        assertNull(reference.get());

        client.send(new GetAndSetRequest(name, toData("foo")));
        assertNull(client.receive());
        assertEquals("foo",reference.get());

        client.send(new GetAndSetRequest(name, toData("foo")));
        assertEquals("foo", client.receive());
        assertEquals("foo",reference.get());

        client.send(new GetAndSetRequest(name, toData("bar")));
        assertEquals("foo", client.receive());
        assertEquals("bar",reference.get());

        client.send(new GetAndSetRequest(name, toData(null)));
        assertEquals("bar", client.receive());
        assertNull(reference.get());
    }
View Full Code Here

    @Test
    public void compareAndSet() throws Exception {
        IAtomicReference<String> reference = getAtomicReference();

        final SimpleClient client = getClient();

        client.send(new CompareAndSetRequest(name, toData(null), toData(null)));
        assertEquals(Boolean.TRUE, client.receive());
        assertNull(reference.get());

        client.send(new CompareAndSetRequest(name, toData("foo"), toData(null)));
        assertEquals(Boolean.FALSE, client.receive());
        assertNull(reference.get());

        client.send(new CompareAndSetRequest(name, toData(null), toData("foo")));
        assertEquals(Boolean.TRUE, client.receive());
        assertEquals("foo", reference.get());

        client.send(new CompareAndSetRequest(name, toData("foo"), toData("foo")));
        assertEquals(Boolean.TRUE, client.receive());
        assertEquals("foo",reference.get());

        client.send(new CompareAndSetRequest(name, toData(null), toData("pipo")));
        assertEquals(Boolean.FALSE, client.receive());
        assertEquals("foo",reference.get());

        client.send(new CompareAndSetRequest(name, toData("bar"), toData("foo")));
        assertEquals(Boolean.FALSE, client.receive());
        assertEquals("foo",reference.get());

        client.send(new CompareAndSetRequest(name, toData("foo"), toData("bar")));
        assertEquals(Boolean.TRUE, client.receive());
        assertEquals("bar",reference.get());

        client.send(new CompareAndSetRequest(name, toData("bar"), toData(null)));
        assertEquals(Boolean.TRUE, client.receive());
        assertEquals(null,reference.get());
    }
View Full Code Here

        mm.put("key1", "value1");
        mm.put("key1", "value2");

        mm.put("key2", "value3");

        final SimpleClient client = getClient();
        client.send(new ClearRequest(name));
        assertNull(client.receive());
        assertEquals(0, mm.size());
    }
View Full Code Here

        mm.put("key1", "value1");
        mm.put("key2", "value2");
        mm.put("key3", "value3");

        //contains key value
        final SimpleClient client = getClient();
        client.send(new KeyBasedContainsRequest(name, ss.toData("key1"), ss.toData("value1")));
        boolean result = (Boolean) client.receive();
        assertTrue(result);

        //not contains key value
        client.send(new KeyBasedContainsRequest(name, ss.toData("key1"), ss.toData("value2")));
        result = (Boolean) client.receive();
        assertFalse(result);

        //contains key
        client.send(new KeyBasedContainsRequest(name, ss.toData("key2"), null));
        result = (Boolean) client.receive();
        assertTrue(result);

        //not contains key
        client.send(new KeyBasedContainsRequest(name, ss.toData("key4"), null));
        result = (Boolean) client.receive();
        assertFalse(result);

        //contains value
        client.send(new ContainsRequest(name, ss.toData("value3")));
        result = (Boolean) client.receive();
        assertTrue(result);

        //not contains value
        client.send(new ContainsRequest(name, ss.toData("value0")));
        result = (Boolean) client.receive();
        assertFalse(result);
    }
View Full Code Here

        mm.put("key4", "value4");

        mm.put("key5", "value3");

        final SimpleClient client = getClient();
        client.send(new EntrySetRequest(name));
        PortableEntrySetResponse result = (PortableEntrySetResponse) client.receive();
        Set<Map.Entry> entrySet = result.getEntrySet();
        Data value = (Data) entrySet.iterator().next().getValue();
        String s = (String) ss.toObject(value);
        assertTrue(s.startsWith("value"));
        assertEquals(6, entrySet.size());
View Full Code Here

        mm.put("key1", "value1");

        mm.put("key2", "value1");
        mm.put("key2", "value2");

        final SimpleClient client = getClient();
        client.send(new GetAllRequest(name, ss.toData("key1")));
        PortableCollection result = (PortableCollection) client.receive();
        Collection<Data> coll = result.getCollection();
        assertEquals(1, coll.size());
        assertEquals("value1", ss.toObject(coll.iterator().next()));

        client.send(new GetAllRequest(name, ss.toData("key2")));
        result = (PortableCollection) client.receive();
        coll = result.getCollection();
        assertEquals(2, coll.size());
    }
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.