Examples of RexsterClient


Examples of com.tinkerpop.rexster.client.RexsterClient

    }

    @Test
    public void executeAndReturnTable() throws Exception {
        final RexsterClient client = getClient();

        final List<Object> tableResults = client.execute("g=TinkerGraphFactory.createTinkerGraph();g.v(1).out.name.as('x').table.cap.next()");
        assertEquals(3, tableResults.size());

        assertTrue(tableResults.get(0) instanceof Map);

        final List<String> names = new ArrayList<String>(){{
            add("vadas");
            add("josh");
            add("lop");
        }};

        for(Object e : tableResults) {
            final Map<String,Object> m = (Map<String, Object>) e;
            assertTrue(names.contains(m.get("x")));
        }

        client.close();

    }
View Full Code Here

Examples of com.tinkerpop.rexster.client.RexsterClient

    }

    @Test
    public void executeForProperties() throws Exception {
        final RexsterClient client = getClient();

        final List<Map> stuffs = client.execute("g=TinkerGraphFactory.createTinkerGraph();g.v(1).properties");
        assertEquals(1, stuffs.size());

        Map<String,Object> m = stuffs.get(0);

        assertEquals("class com.tinkerpop.blueprints.impls.tg.TinkerVertex", m.get("class"));
View Full Code Here

Examples of com.tinkerpop.rexster.client.RexsterClient

    }

    @Test
    public void executeForTextWithBreaks() throws Exception {
        final RexsterClient client = getClient();

        // note that you have to escape the \r\n for it to be understood as a property value else the script engine
        // assumes it is line breaks in the script itself.
        final List<String> text = client.execute("g=new TinkerGraph();g.addVertex(['text':'''test1\\r\\ntest2\\r\\ntest3''']);g.v(0).text");

        assertEquals(1, text.size());
        assertEquals("test1\r\ntest2\r\ntest3", text.get(0));

    }
View Full Code Here

Examples of com.tinkerpop.rexster.client.RexsterClient

    /**
     * Tests that requests to create and destroy sessions work as expected
     */
    @Test
    public void testSessionRequestAndResponse() throws Exception {
        final RexsterClient client = getClient();

        //create a session
        final SessionRequestMessage outMsg = new SessionRequestMessage();
        outMsg.setRequestAsUUID(UUID.randomUUID());

        RexProMessage inMsg = client.execute(outMsg);
        Assert.assertNotNull(inMsg.Session);
        Assert.assertTrue(inMsg instanceof SessionResponseMessage);

        UUID sessionKey = BitWorks.convertByteArrayToUUID(inMsg.Session);

        //kill said session
        final SessionRequestMessage deathMsg = new SessionRequestMessage();
        deathMsg.Session = BitWorks.convertUUIDToByteArray(sessionKey);
        deathMsg.setRequestAsUUID(UUID.randomUUID());
        deathMsg.metaSetKillSession(true);

        inMsg = client.execute(deathMsg);
        Assert.assertNotNull(inMsg.Session);
        Assert.assertTrue(inMsg instanceof SessionResponseMessage);

        //try to use the killed session
        final ScriptRequestMessage scriptMessage = new ScriptRequestMessage();
        scriptMessage.Script = "5";
        scriptMessage.LanguageName = "groovy";
        scriptMessage.metaSetInSession(true);
        scriptMessage.setRequestAsUUID(UUID.randomUUID());
        scriptMessage.Session = BitWorks.convertUUIDToByteArray(sessionKey);

        inMsg = client.execute(scriptMessage);
        Assert.assertTrue(inMsg instanceof ErrorResponseMessage);
        Assert.assertEquals(((ErrorResponseMessage) inMsg).metaGetFlag(), ErrorResponseMessage.INVALID_SESSION_ERROR);
    }
View Full Code Here

Examples of com.tinkerpop.rexster.client.RexsterClient

    /**
     * Tests defining graph objects while opening a session
     */
    @Test
    public void testSessionGraphDefinition() throws Exception {
        final RexsterClient client = getClient();

        for (Map.Entry<String, Map<String,String>> entry : getAvailableGraphs(client).entrySet()) {
            //create a session
            final SessionRequestMessage outMsg = new SessionRequestMessage();
            outMsg.setRequestAsUUID(UUID.randomUUID());
            outMsg.metaSetGraphName(entry.getKey());
            outMsg.metaSetGraphObjName("graph");

            RexProMessage inMsg = client.execute(outMsg);
            Assert.assertNotNull(inMsg.Session);
            Assert.assertTrue(inMsg instanceof SessionResponseMessage);

            UUID sessionKey = BitWorks.convertByteArrayToUUID(inMsg.Session);

            //try to use the graph on the session
            final ScriptRequestMessage scriptMessage = new ScriptRequestMessage();
            scriptMessage.Script = "graph.addVertex()";
            scriptMessage.LanguageName = "groovy";
            scriptMessage.metaSetInSession(true);
            scriptMessage.setRequestAsUUID(UUID.randomUUID());
            scriptMessage.Session = BitWorks.convertUUIDToByteArray(sessionKey);

            inMsg = client.execute(scriptMessage);
            Assert.assertTrue(inMsg instanceof ScriptResponseMessage);
            Assert.assertTrue(((ScriptResponseMessage) inMsg).Results.get() != null);
        }
    }
View Full Code Here

Examples of com.tinkerpop.rexster.client.RexsterClient

     * Tests that attempting to define graph objects with graph names
     * that don't exist returns an error response
     */
    @Test
    public void testDefiningNonExistentGraphNameFails() throws Exception {
        final RexsterClient client = getClient();

        //create a session
        final SessionRequestMessage outMsg = new SessionRequestMessage();
        outMsg.setRequestAsUUID(UUID.randomUUID());
        outMsg.metaSetGraphName("undefined");

        RexProMessage inMsg = client.execute(outMsg);
        Assert.assertNotNull(inMsg.Session);
        Assert.assertTrue(inMsg instanceof ErrorResponseMessage);
        Assert.assertEquals(((ErrorResponseMessage) inMsg).metaGetFlag(), ErrorResponseMessage.GRAPH_CONFIG_ERROR);

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.