You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/06/29 21:14:52 UTC

[7/7] incubator-tinkerpop git commit: Add test for REST of transactional graph.

Add test for REST of transactional graph.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/75ae7bda
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/75ae7bda
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/75ae7bda

Branch: refs/heads/master
Commit: 75ae7bdac65dca49a5847a98df48da6015db7800
Parents: b05151c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 29 15:14:27 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 29 15:14:27 2015 -0400

----------------------------------------------------------------------
 .../server/GremlinServerHttpIntegrateTest.java  | 39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/75ae7bda/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index 57dbd3e..650a195 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -34,6 +34,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
 
+import java.io.File;
 import java.util.Arrays;
 
 import static org.junit.Assert.assertEquals;
@@ -63,6 +64,10 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
             case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndRebinding":
                 settings.scriptEngines.get("gremlin-groovy").scripts = Arrays.asList("scripts/generate-classic.groovy");
                 break;
+            case "should200OnPOSTTransactionalGraph":
+                deleteDirectory(new File("/tmp/neo4j"));
+                settings.graphs.put("graph", "conf/neo4j-empty.properties");
+                break;
         }
         return settings;
     }
@@ -204,6 +209,40 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
     }
 
     @Test
+    public void should200OnPOSTTransactionalGraph() throws Exception {
+        assumeNeo4jIsPresent();
+
+        final CloseableHttpClient httpclient = HttpClients.createDefault();
+        final HttpPost httppost = new HttpPost("http://localhost:8182");
+        httppost.addHeader("Content-Type", "application/json");
+        httppost.setEntity(new StringEntity("{\"gremlin\":\"graph.addVertex('name','stephen');g.V().count()\"}", Consts.UTF_8));
+
+        try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
+            assertEquals(200, response.getStatusLine().getStatusCode());
+            assertEquals("application/json", response.getEntity().getContentType().getValue());
+            final String json = EntityUtils.toString(response.getEntity());
+            final JsonNode node = mapper.readTree(json);
+            assertEquals(1, node.get("result").get("data").get(0).intValue());
+        }
+
+        final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=g.V().count()");
+        httpget.addHeader("Accept", "application/json");
+
+        // execute this a bunch of times so that there's a good chance a different thread on the server processes
+        // the request
+        for (int ix = 0; ix < 100; ix++) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
+                assertEquals(200, response.getStatusLine().getStatusCode());
+                assertEquals("application/json", response.getEntity().getContentType().getValue());
+                final String json = EntityUtils.toString(response.getEntity());
+                final JsonNode node = mapper.readTree(json);
+                assertEquals(1, node.get("result").get("data").get(0).intValue());
+            }
+        }
+
+    }
+
+    @Test
     public void should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResult() throws Exception {
         final CloseableHttpClient httpclient = HttpClients.createDefault();
         final HttpPost httppost = new HttpPost("http://localhost:8182");