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/25 20:08:41 UTC
incubator-tinkerpop git commit: Add integration tests for the Gephi
Plugin TINKERPOP3-748
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 1e7842a54 -> 6d51cdc5e
Add integration tests for the Gephi Plugin TINKERPOP3-748
The tests are mostly focused on exercising portions of the code that tend to fail the most.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/6d51cdc5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/6d51cdc5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/6d51cdc5
Branch: refs/heads/master
Commit: 6d51cdc5e5c1a48a35188de849dd0aedba116ab5
Parents: 1e7842a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 25 14:05:26 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 25 14:05:26 2015 -0400
----------------------------------------------------------------------
gremlin-console/pom.xml | 68 ++++++++++++
.../GephiRemoteAcceptorIntegrateTest.java | 108 +++++++++++++++++++
2 files changed, 176 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6d51cdc5/gremlin-console/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-console/pom.xml b/gremlin-console/pom.xml
index eba2719..adec1ef 100644
--- a/gremlin-console/pom.xml
+++ b/gremlin-console/pom.xml
@@ -45,9 +45,24 @@ limitations under the License.
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
+ <!-- conflict with wiremock -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <!-- conflict with wiremock - added back explicitly below -->
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.5</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>${project.version}</version>
@@ -87,6 +102,59 @@ limitations under the License.
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock</artifactId>
+ <version>1.56</version>
+ <scope>test</scope>
+ <classifier>standalone</classifier>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.skyscreamer</groupId>
+ <artifactId>jsonassert</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>net.sf.jopt-simple</groupId>
+ <artifactId>jopt-simple</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
<directory>${basedir}/target</directory>
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6d51cdc5/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
new file mode 100644
index 0000000..d75b736
--- /dev/null
+++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.console.groovy.plugin;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import org.apache.commons.io.input.NullInputStream;
+import org.apache.tinkerpop.gremlin.console.GremlinGroovysh;
+import org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor;
+import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.codehaus.groovy.tools.shell.IO;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GephiRemoteAcceptorIntegrateTest {
+ private static final Groovysh groovysh = new GremlinGroovysh();
+ private GephiRemoteAcceptor acceptor;
+
+ private final InputStream inputStream = new NullInputStream(0);
+ private final OutputStream outputStream = new ByteArrayOutputStream();
+ private final OutputStream errorStream = new ByteArrayOutputStream();
+ private final IO io = new IO(inputStream, outputStream, errorStream);
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8080);
+
+ @Before
+ public void before() throws Exception {
+ acceptor = new GephiRemoteAcceptor(groovysh, io);
+ }
+
+ @Test
+ public void shouldConnectWithDefaults() throws RemoteException {
+ assertThat(acceptor.connect(Collections.emptyList()).toString(), startsWith("Connection to Gephi - http://localhost:8080/workspace0"));
+ }
+
+ @Test
+ public void shouldSubmitGraph() throws RemoteException {
+ stubFor(post(urlPathEqualTo("/workspace0"))
+ .withQueryParam("format", equalTo("JSON"))
+ .withQueryParam("operation", equalTo("updateGraph"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+
+ stubFor(get(urlPathEqualTo("/workspace0"))
+ .withQueryParam("operation", equalTo("getNode"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+
+ acceptor.submit(Arrays.asList("g = org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.open();g.addVertex();g"));
+
+ wireMockRule.verify(2, postRequestedFor(urlPathEqualTo("/workspace0")));
+ wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/workspace0")));
+ }
+
+ @Test
+ public void shouldSubmitTraversal() throws RemoteException {
+ stubFor(post(urlPathEqualTo("/workspace0"))
+ .withQueryParam("format", equalTo("JSON"))
+ .withQueryParam("operation", equalTo("updateGraph"))
+ .willReturn(aResponse()
+ .withStatus(200)));
+
+ acceptor.submit(Arrays.asList("g = org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.createModern().traversal();" +
+ "traversal = g.V(2).store('1').in('knows').store('2').out('knows').has('age',org.apache.tinkerpop.gremlin.process.traversal.P.gt(30)).store('3').outE('created').has('weight',org.apache.tinkerpop.gremlin.process.traversal.P.gt(0.5d)).inV().store('4');" +
+ "traversal.iterate();" +
+ "traversal"));
+
+ wireMockRule.verify(10, postRequestedFor(urlPathEqualTo("/workspace0")));
+ }
+}