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 2017/02/27 22:05:09 UTC
[30/38] tinkerpop git commit: TINKERPOP-1612 Removed a number of
deprecated classes from the old plugin infrastructure
TINKERPOP-1612 Removed a number of deprecated classes from the old plugin infrastructure
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1cc19e9a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1cc19e9a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1cc19e9a
Branch: refs/heads/TINKERPOP-1612
Commit: 1cc19e9a2ea442fc3bab1aa34e96a2a1d8076ecf
Parents: 85f007f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Feb 25 11:18:23 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Feb 27 13:40:23 2017 -0500
----------------------------------------------------------------------
docs/src/upgrade/release-3.3.x.asciidoc | 7 +
.../ConsoleImportCustomizerProvider.groovy | 50 ---
.../console/plugin/GephiRemoteAcceptor.groovy | 373 -------------------
.../GephiTraversalVisualizationStrategy.groovy | 123 ------
.../groovy/plugin/DriverGremlinPlugin.java | 65 ----
.../groovy/plugin/DriverRemoteAcceptor.java | 233 ------------
.../groovy/plugin/GephiGremlinPlugin.java | 54 ---
.../groovy/plugin/UtilitiesGremlinPlugin.java | 71 ----
...inkerpop.gremlin.groovy.plugin.GremlinPlugin | 3 -
.../AbstractGremlinServerIntegrationTest.java | 64 ----
.../groovy/plugin/DriverGremlinPluginTest.java | 58 ---
.../DriverRemoteAcceptorIntegrateTest.java | 156 --------
.../groovy/plugin/DriverRemoteAcceptorTest.java | 140 -------
.../GephiRemoteAcceptorIntegrateTest.java | 179 ---------
.../groovy/plugin/GremlinPluginAdapterTest.java | 124 ------
.../groovy/plugin/SpyPluginAcceptor.java | 87 -----
.../groovy/plugin/SugarGremlinPluginTest.java | 63 ----
.../plugin/UtilitiesGremlinPluginTest.java | 72 ----
.../plugin/gremlin-server-integration.yaml | 54 ---
.../gremlin/console/groovy/plugin/remote.yaml | 20 -
.../groovy/plugin/script-customizer-1.groovy | 3 -
.../groovy/plugin/script-customizer-2.groovy | 2 -
.../groovy/plugin/tinkergraph-empty.properties | 18 -
.../jsr223/gremlin-server-integration.yaml | 30 +-
24 files changed, 22 insertions(+), 2027 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/docs/src/upgrade/release-3.3.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc
index a9a70f7..9a58f08 100644
--- a/docs/src/upgrade/release-3.3.x.asciidoc
+++ b/docs/src/upgrade/release-3.3.x.asciidoc
@@ -181,6 +181,13 @@ The following deprecated classes, methods or fields have been removed in this ve
** org.apache.tinkerpop.gremlin.giraph.groovy.plugin.GiraphGremlinPlugin
* `gremlin-console`
** `org.apache.tinkerpop.gremlin.console.Console(String)`
+** `org.apache.tinkerpop.gremlin.console.ConsoleImportCustomizerProvider`
+** `org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor`
+** `org.apache.tinkerpop.gremlin.console.plugin.GephiTraversalVisualizationStrategy`
+** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin`
+** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverRemoteAcceptor`
+** `org.apache.tinkerpop.gremlin.console.groovy.plugin.GephiGremlinPlugin`
+** `org.apache.tinkerpop.gremlin.console.groovy.plugin.UtilitiesGremlinPlugin`
* `gremlin-core`
** `org.apache.tinkerpop.gremlin.jsr223.CoreGremlinModule`
** `org.apache.tinkerpop.gremlin.jsr223.GremlinModule`
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
deleted file mode 100644
index 85fda8c..0000000
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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
-
-import org.apache.tinkerpop.gremlin.groovy.AbstractImportCustomizerProvider
-import groovy.sql.Sql
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.4, not replaced.
- */
-@Deprecated
-class ConsoleImportCustomizerProvider extends AbstractImportCustomizerProvider {
- public ConsoleImportCustomizerProvider() {
- // useful groovy bits that are good for the Console
- extraImports.add(Sql.class.getPackage().getName() + DOT_STAR)
- }
-
- public Set<String> getCombinedStaticImports() {
- final Set<String> combined = new HashSet<>();
- combined.addAll(getStaticImports());
- combined.addAll(extraStaticImports);
-
- return Collections.unmodifiableSet(combined);
- }
-
- public Set<String> getCombinedImports() {
- final Set<String> combined = new HashSet<>();
- combined.addAll(getImports());
- combined.addAll(extraImports);
-
- return Collections.unmodifiableSet(combined);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
deleted file mode 100644
index 902a479..0000000
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * 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.plugin
-
-import groovy.json.JsonOutput
-import groovy.transform.CompileStatic
-import org.apache.http.client.methods.CloseableHttpResponse
-import org.apache.http.client.methods.HttpUriRequest
-import org.apache.http.client.methods.RequestBuilder
-import org.apache.http.entity.StringEntity
-import org.apache.http.impl.client.CloseableHttpClient
-import org.apache.http.impl.client.HttpClients
-import org.apache.http.util.EntityUtils
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
-import org.apache.tinkerpop.gremlin.structure.Edge
-import org.apache.tinkerpop.gremlin.structure.Graph
-import org.apache.tinkerpop.gremlin.structure.Vertex
-import groovy.json.JsonSlurper
-import org.codehaus.groovy.tools.shell.Groovysh
-import org.codehaus.groovy.tools.shell.IO
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @author Randall Barnhart (randompi@gmail.com)
- * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.GephiRemoteAcceptor}
- */
-@Deprecated
-class GephiRemoteAcceptor implements RemoteAcceptor {
-
- private String host = "localhost"
- private int port = 8080
- private String workspace = "workspace1"
-
- private final Groovysh shell
- private final IO io
-
- private final Random rand = new Random();
- boolean traversalSubmittedForViz = false
- long vizStepDelay
- private float[] vizStartRGBColor
- private float[] vizDefaultRGBColor
- private char vizColorToFade
- private float vizColorFadeRate
- private float vizStartSize
- private float vizSizeDecrementRate
- private Map vertexAttributes = [:]
-
- private CloseableHttpClient httpclient = HttpClients.createDefault();
-
- public GephiRemoteAcceptor(final Groovysh shell, final IO io) {
- this.shell = shell
- this.io = io
-
- // traversal visualization defaults
- vizStepDelay = 1000; // 1 second pause between viz of steps
- vizStartRGBColor = [0.0f, 1.0f, 0.5f] // light aqua green
- vizDefaultRGBColor = [0.6f, 0.6f, 0.6f] // light grey
- vizColorToFade = 'g' // will fade so blue is strongest
- vizColorFadeRate = 0.7 // the multiplicative rate to fade visited vertices
- vizStartSize = 10
- vizSizeDecrementRate = 0.33f
- }
-
- @Override
- connect(final List<String> args) throws RemoteException {
- if (args.size() >= 1)
- workspace = args[0]
-
- if (args.size() >= 2)
- host = args[1]
-
- if (args.size() >= 3) {
- try {
- port = Integer.parseInt(args[2])
- } catch (Exception ex) {
- throw new RemoteException("Port must be an integer value")
- }
- }
-
- def vizConfig = " with stepDelay:$vizStepDelay, startRGBColor:$vizStartRGBColor, " +
- "colorToFade:$vizColorToFade, colorFadeRate:$vizColorFadeRate, startSize:$vizStartSize," +
- "sizeDecrementRate:$vizSizeDecrementRate"
-
- return "Connection to Gephi - http://$host:$port/$workspace" + vizConfig
- }
-
- @Override
- Object configure(final List<String> args) throws RemoteException {
- if (args.size() < 2)
- throw new RemoteException("Invalid config arguments - check syntax")
-
- if (args[0] == "host")
- host = args[1]
- else if (args[0] == "port") {
- try {
- port = Integer.parseInt(args[1])
- } catch (Exception ignored) {
- throw new RemoteException("Port must be an integer value")
- }
- } else if (args[0] == "workspace")
- workspace = args[1]
- else if (args[0] == "stepDelay")
- parseVizStepDelay(args[1])
- else if (args[0] == "startRGBColor")
- parseVizStartRGBColor(args[1])
- else if (args[0] == "colorToFade")
- parseVizColorToFade(args[1])
- else if (args[0] == "colorFadeRate")
- parseVizColorFadeRate(args[1])
- else if (args[0] == "sizeDecrementRate")
- parseVizSizeDecrementRate(args[1])
- else if (args[0] == "startSize")
- parseVizStartSize(args[1])
- else if (args[0] == "visualTraversal") {
- def graphVar = shell.interp.context.getVariable(args[1])
- if (!(graphVar instanceof Graph))
- throw new RemoteException("Invalid argument to 'visualTraversal' - first parameter must be a Graph instance")
-
- def gVar = args.size() == 3 ? args[2] : "vg"
- def theG = GraphTraversalSource.build().with(new GephiTraversalVisualizationStrategy(this)).create(graphVar)
- shell.interp.context.setVariable(gVar, theG)
- } else
- throw new RemoteException("Invalid config arguments - check syntax")
-
- return "Connection to Gephi - http://$host:$port/$workspace" +
- " with stepDelay:$vizStepDelay, startRGBColor:$vizStartRGBColor, " +
- "colorToFade:$vizColorToFade, colorFadeRate:$vizColorFadeRate, startSize:$vizStartSize," +
- "sizeDecrementRate:$vizSizeDecrementRate"
- }
-
- @Override
- @CompileStatic
- Object submit(final List<String> args) throws RemoteException {
- final String line = String.join(" ", args)
- if (line.trim() == "clear") {
- clearGraph()
- io.out.println("Gephi workspace cleared")
- return
- }
-
- // need to clear the vertex attributes
- vertexAttributes.clear()
-
- // this tells the GraphTraversalVisualizationStrategy that if the line eval's to a traversal it should
- // try to visualize it
- traversalSubmittedForViz = true
-
- // get the colors/sizes back to basics before trying visualize
- resetColorsSizes()
-
- final Object o = shell.execute(line)
- if (o instanceof Graph) {
- clearGraph()
- def graph = (Graph) o
- def g = graph.traversal()
- g.V().sideEffect { addVertexToGephi(g, it.get()) }.iterate()
- }
-
- traversalSubmittedForViz = false
- }
-
- @Override
- void close() throws IOException {
- httpclient.close()
- }
-
- /**
- * Visits the last set of vertices traversed and degrades their color and size.
- */
- def updateVisitedVertices(def List except = []) {
- vertexAttributes.keySet().findAll{ vertexId -> !except.contains(vertexId) }.each { String vertexId ->
- def attrs = vertexAttributes[vertexId]
- float currentColor = attrs.color
- currentColor *= vizColorFadeRate
-
- int currentSize = attrs["size"]
- currentSize = Math.max(vizStartSize, currentSize - (currentSize * vizSizeDecrementRate))
-
- vertexAttributes.get(vertexId).color = currentColor
- vertexAttributes.get(vertexId).size = currentSize
-
- changeVertexAttributes(vertexId)
- }
- }
-
- def changeVertexAttributes(def String vertexId) {
- def props = [:]
- props.put(vizColorToFade.toString(), vertexAttributes[vertexId].color)
- props.put("size", vertexAttributes[vertexId].size)
- updateGephiGraph([cn: [(vertexId): props]])
- }
-
- /**
- * Visit a vertex traversed and initialize its color and size.
- */
- def visitVertexInGephi(def Vertex v) {
- def props = [:]
- props.put('r', vizStartRGBColor[0])
- props.put('g', vizStartRGBColor[1])
- props.put('b', vizStartRGBColor[2])
- props.put('size', vizStartSize * 2.5)
- props.put('visited', 1)
-
- updateGephiGraph([cn: [(v.id().toString()): props]])
-
- vertexAttributes[v.id().toString()] = [color: vizStartRGBColor[fadeColorIndex()], size: vizStartSize * 2.5, touch: 1]
- }
-
- def fadeColorIndex() {
- if (vizColorToFade == 'r')
- return 0
- else if (vizColorToFade == 'g')
- return 1
- else if (vizColorToFade == 'b')
- return 2
- }
-
- def addVertexToGephi(def GraphTraversalSource g, def Vertex v, def boolean ignoreEdges = false) {
- // grab the first property value from the strategies of values
- def props = g.V(v).valueMap().next().collectEntries { kv -> [(kv.key): kv.value[0]] }
- props << [label: v.label()]
- props.put('r', vizDefaultRGBColor[0])
- props.put('g', vizDefaultRGBColor[1])
- props.put('b', vizDefaultRGBColor[2])
- props.put('x', rand.nextFloat())
- props.put('y', rand.nextFloat())
- props.put('size', 10)
- props.put('visited', 0)
-
- // only add if it does not exist in graph already
- if (!getFromGephiGraph([operation: "getNode", id: v.id().toString()]).isPresent())
- updateGephiGraph([an: [(v.id().toString()): props]])
-
- if (!ignoreEdges) {
- g.V(v).outE().sideEffect {
- addEdgeToGephi(g, it.get())
- }.iterate()
- }
- }
-
- @CompileStatic
- def addEdgeToGephi(def GraphTraversalSource g, def Edge e) {
- def props = g.E(e).valueMap().next()
- props.put('label', e.label())
- props.put('source', e.outVertex().id().toString())
- props.put('target', e.inVertex().id().toString())
- props.put('directed', true)
- props.put('visited', 0)
-
- // make sure the in vertex is there but don't add its edges - that will happen later as we are looping
- // all vertices in the graph
- addVertexToGephi(g, e.inVertex(), true)
-
- // both vertices are definitely there now, so add the edge
- updateGephiGraph([ae: [(e.id().toString()): props]])
- }
-
- def clearGraph() {
- updateGephiGraph([dn: [filter: "ALL"]])
- }
-
- def resetColorsSizes() {
- updateGephiGraph([cn: [filter: [nodeAttribute: [attribute: "visited", value: 1]],
- attributes: [size: 1, r: vizDefaultRGBColor[0], g: vizDefaultRGBColor[1], b: vizDefaultRGBColor[2]]]])
- updateGephiGraph([ce: [filter: [edgeAttribute: [attribute: "visited", value: 1]],
- attributes: [size: 1, r: vizDefaultRGBColor[0], g: vizDefaultRGBColor[1], b: vizDefaultRGBColor[2]]]])
- }
-
- def getFromGephiGraph(def Map queryArgs) {
- def requestBuilder = RequestBuilder.get("http://$host:$port/$workspace")
- queryArgs.each { requestBuilder = requestBuilder.addParameter(it.key, it.value) }
-
- def httpResp = makeRequest(requestBuilder.build())
- def resp = EntityUtils.toString(httpResp.entity)
-
- // gephi streaming plugin does not set the content type or respect the Accept header - treat as text
- if (resp.isEmpty())
- return Optional.empty()
- else
- return Optional.of(new JsonSlurper().parseText(resp))
- }
-
- def updateGephiGraph(def Map postBody) {
- def requestBuilder = RequestBuilder.post("http://$host:$port/$workspace")
- .addParameter("format", "JSON")
- .addParameter("operation", "updateGraph")
- .setEntity(new StringEntity(JsonOutput.toJson(postBody)))
- EntityUtils.consume(makeRequest(requestBuilder.build()).entity)
- }
-
- private CloseableHttpResponse makeRequest(HttpUriRequest request) {
- def httpResp = httpclient.execute(request)
- if (httpResp.getStatusLine().getStatusCode() == 200) {
- return httpResp
- } else {
- def resp = EntityUtils.toString(httpResp.entity)
- throw new RuntimeException("Unsuccessful request to Gephi - [${httpResp.getStatusLine().getStatusCode()}] ${httpResp.getStatusLine().getReasonPhrase()} - $resp")
- }
- }
-
- @Override
- public String toString() {
- return "Gephi - [$workspace]"
- }
-
- private void parseVizStepDelay(String arg) {
- try {
- vizStepDelay = Long.parseLong(arg)
- } catch (Exception ignored) {
- throw new RemoteException("The stepDelay must be a long value")
- }
- }
-
- private void parseVizStartRGBColor(String arg) {
- try {
- vizStartRGBColor = arg[1..-2].tokenize(',')*.toFloat()
- assert (vizStartRGBColor.length == 3)
- } catch (Exception ignored) {
- throw new RemoteException("The vizStartRGBColor must be an array of 3 float values, e.g. [0.0,1.0,0.5]")
- }
- }
-
- private void parseVizColorToFade(String arg) {
- try {
- vizColorToFade = arg.charAt(0).toLowerCase();
- assert (vizColorToFade == 'r' || vizColorToFade == 'g' || vizColorToFade == 'b')
- } catch (Exception ignored) {
- throw new RemoteException("The vizColorToFade must be one character value among: r, g, b, R, G, B")
- }
- }
-
- private void parseVizColorFadeRate(String arg) {
- try {
- vizColorFadeRate = Float.parseFloat(arg)
- } catch (Exception ignored) {
- throw new RemoteException("The colorFadeRate must be a float value")
- }
- }
-
- private void parseVizSizeDecrementRate(String arg) {
- try {
- vizSizeDecrementRate = Float.parseFloat(arg)
- } catch (Exception ignored) {
- throw new RemoteException("The sizeDecrementRate must be a float value")
- }
- }
-
- private void parseVizStartSize(String arg) {
- try {
- vizStartSize = Float.parseFloat(arg)
- } catch (Exception ignored) {
- throw new RemoteException("The startSize must be a float value")
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiTraversalVisualizationStrategy.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiTraversalVisualizationStrategy.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiTraversalVisualizationStrategy.groovy
deleted file mode 100644
index c19de06..0000000
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiTraversalVisualizationStrategy.groovy
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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.plugin
-
-import groovy.transform.CompileStatic
-import org.apache.tinkerpop.gremlin.process.traversal.Step
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeOtherVertexStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.LambdaSideEffectStep
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper
-import org.apache.tinkerpop.gremlin.structure.Vertex
-
-import java.util.stream.Collectors
-
-/**
- * A strategy that works in conjuction with the {@link GephiRemoteAcceptor} to automatically inject visualization
- * steps after "vertex" steps to show the vertices traversed for a step. If the traversal was evaluated in the
- * console normally then the visualization strategy will not be applied. It must be {@code :submit} to the
- * console for the strategy to be applied.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.5, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.GephiTraversalVisualizationStrategy}
- */
-@CompileStatic
-@Deprecated
-class GephiTraversalVisualizationStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy>
- implements TraversalStrategy.FinalizationStrategy {
-
- private static final Set<Class<? extends TraversalStrategy.FinalizationStrategy>> POSTS = new HashSet<>();
-
- static {
- POSTS.add(ProfileStrategy.class);
- }
-
- private final GephiRemoteAcceptor acceptor
-
- private final String sideEffectKey = "viz-" + UUID.randomUUID()
-
- GephiTraversalVisualizationStrategy(final GephiRemoteAcceptor acceptor) {
- this.acceptor = acceptor
- }
-
- @Override
- void apply(final Traversal.Admin<?, ?> traversal) {
- if (TraversalHelper.onGraphComputer(traversal))
- return
-
- // only apply these strategies if the traversal was :submit to the acceptor - otherwise process as usual
- if (acceptor.traversalSubmittedForViz) {
- final List<GraphStep> graphSteps = TraversalHelper.getStepsOfAssignableClass(GraphStep.class, traversal)
- final List<VertexStep> vertexSteps = TraversalHelper.getStepsOfAssignableClass(VertexStep.class, traversal)
-
- def List<Step> addAfter = new ArrayList<>()
- addAfter.addAll(TraversalHelper.getStepsOfAssignableClass(EdgeOtherVertexStep.class, traversal))
- addAfter.addAll(TraversalHelper.getStepsOfAssignableClass(EdgeVertexStep.class, traversal))
- addAfter.addAll(vertexSteps.stream().filter { it.returnsVertex() }.collect(Collectors.toList()))
- addAfter.addAll(graphSteps.stream().filter { it.returnsVertex() }.collect(Collectors.toList()))
-
- // decay all vertices and visit each one to update their colors to the brightest
- addAfter.each { Step s ->
- TraversalHelper.insertAfterStep(new LambdaSideEffectStep(traversal, { Traverser traverser ->
- final BulkSet<Vertex> vertices = ((BulkSet<Vertex>) traverser.sideEffects(sideEffectKey))
- if (!vertices.isEmpty()) {
- acceptor.updateVisitedVertices()
- vertices.forEach { Vertex v, Long l -> acceptor.visitVertexInGephi(v) }
- vertices.clear()
- Thread.sleep(acceptor.vizStepDelay)
- }
- }), s, traversal)
- TraversalHelper.insertAfterStep(new AggregateStep(traversal, sideEffectKey), s, traversal)
- }
-
- // decay all vertices except those that made it through the filter - "this way you can watch
- // the Gremlins dying" - said daniel kuppitz. can't do this easily with generic FilterStep as
- // it creates odd behaviors when used with loop (extra decay that probably shouldn't be there.
- // todo: can this be better? maybe we shouldn't do this at all
- TraversalHelper.getStepsOfAssignableClass(HasStep.class, traversal).each { HasStep s ->
- TraversalHelper.insertAfterStep(new LambdaSideEffectStep(traversal, { Traverser traverser ->
- final BulkSet<Object> objects = ((BulkSet<Object>) traverser.sideEffects(sideEffectKey))
- if (!objects.isEmpty()) {
- final List<String> vertices = objects.findAll { Object o -> o instanceof Vertex }
- .collect { Object o -> ((Vertex) o).id().toString() }
- acceptor.updateVisitedVertices(vertices)
- objects.clear()
- Thread.sleep(acceptor.vizStepDelay)
- }
- }), s, traversal)
- TraversalHelper.insertAfterStep(new AggregateStep(traversal, sideEffectKey), s, traversal)
- }
- }
- }
-
- @Override
- public Set<Class<? extends TraversalStrategy.FinalizationStrategy>> applyPost() {
- return POSTS;
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
deleted file mode 100644
index 2f8fc75..0000000
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.driver.Cluster;
-import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
-import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
-import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
-import org.apache.tinkerpop.gremlin.driver.ser.SerTokens;
-import org.apache.tinkerpop.gremlin.groovy.plugin.AbstractGremlinPlugin;
-import org.apache.tinkerpop.gremlin.groovy.plugin.IllegalEnvironmentException;
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor;
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginInitializationException;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor;
-
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.DriverGremlinPlugin}.
- */
-@Deprecated
-public class DriverGremlinPlugin extends AbstractGremlinPlugin {
-
- private static final Set<String> IMPORTS = new HashSet<String>() {{
- add(IMPORT_SPACE + Cluster.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_SPACE + ConnectionException.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_SPACE + RequestMessage.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_SPACE + SerTokens.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_SPACE + DriverRemoteConnection.class.getPackage().getName() + DOT_STAR);
- }};
-
- @Override
- public String getName() {
- return "tinkerpop.server";
- }
-
- @Override
- public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException {
- pluginAcceptor.addImports(IMPORTS);
- }
-
- @Override
- public Optional<RemoteAcceptor> remoteAcceptor() {
- return null == this.shell ? Optional.empty() : Optional.of(new DriverRemoteAcceptor(this.shell));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
deleted file mode 100644
index 80e8194..0000000
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.driver.Client;
-import org.apache.tinkerpop.gremlin.driver.Cluster;
-import org.apache.tinkerpop.gremlin.driver.Result;
-import org.apache.tinkerpop.gremlin.driver.ResultSet;
-import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.codehaus.groovy.tools.shell.Groovysh;
-
-import javax.security.sasl.SaslException;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.stream.Stream;
-
-/**
- * A {@link RemoteAcceptor} that takes input from the console and sends it to Gremlin Server over the standard
- * Java driver.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.DriverRemoteAcceptor}.
- */
-@Deprecated
-public class DriverRemoteAcceptor implements RemoteAcceptor {
- public static final int NO_TIMEOUT = 0;
-
- private Cluster currentCluster;
- private Client currentClient;
- private int timeout = NO_TIMEOUT;
- private Map<String,String> aliases = new HashMap<>();
- private Optional<String> session = Optional.empty();
-
- private static final String TOKEN_RESET = "reset";
- private static final String TOKEN_SHOW = "show";
-
- /**
- * @deprecated As of 3.1.3, replaced by "none" option
- */
- @Deprecated
- private static final String TOKEN_MAX = "max";
- private static final String TOKEN_NONE = "none";
- private static final String TOKEN_TIMEOUT = "timeout";
- private static final String TOKEN_ALIAS = "alias";
- private static final String TOKEN_SESSION = "session";
- private static final String TOKEN_SESSION_MANAGED = "session-managed";
- private static final List<String> POSSIBLE_TOKENS = Arrays.asList(TOKEN_TIMEOUT, TOKEN_ALIAS);
-
- private final Groovysh shell;
-
- public DriverRemoteAcceptor(final Groovysh shell) {
- this.shell = shell;
- }
-
- @Override
- public Object connect(final List<String> args) throws RemoteException {
- if (args.size() < 1) throw new RemoteException("Expects the location of a configuration file as an argument");
-
- try {
- this.currentCluster = Cluster.open(args.get(0));
- final boolean useSession = args.size() >= 2 && (args.get(1).equals(TOKEN_SESSION) || args.get(1).equals(TOKEN_SESSION_MANAGED));
- if (useSession) {
- final String sessionName = args.size() == 3 ? args.get(2) : UUID.randomUUID().toString();
- session = Optional.of(sessionName);
-
- final boolean managed = args.get(1).equals(TOKEN_SESSION_MANAGED);
-
- this.currentClient = this.currentCluster.connect(sessionName, managed);
- } else {
- this.currentClient = this.currentCluster.connect();
- }
- this.currentClient.init();
- return String.format("Configured %s", this.currentCluster) + getSessionStringSegment();
- } catch (final FileNotFoundException ignored) {
- throw new RemoteException("The 'connect' option must be accompanied by a valid configuration file");
- } catch (final Exception ex) {
- throw new RemoteException("Error during 'connect' - " + ex.getMessage(), ex);
- }
- }
-
- @Override
- public Object configure(final List<String> args) throws RemoteException {
- final String option = args.size() == 0 ? "" : args.get(0);
- if (!POSSIBLE_TOKENS.contains(option))
- throw new RemoteException(String.format("The 'config' option expects one of ['%s'] as an argument", String.join(",", POSSIBLE_TOKENS)));
-
- final List<String> arguments = args.subList(1, args.size());
-
- if (option.equals(TOKEN_TIMEOUT)) {
- final String errorMessage = "The timeout option expects a positive integer representing milliseconds or 'none' as an argument";
- if (arguments.size() != 1) throw new RemoteException(errorMessage);
- try {
- // first check for MAX timeout then NONE and finally parse the config to int. "max" is now "deprecated"
- // in the sense that it will no longer be promoted. support for it will be removed at a later date
- timeout = arguments.get(0).equals(TOKEN_MAX) ? Integer.MAX_VALUE :
- arguments.get(0).equals(TOKEN_NONE) ? NO_TIMEOUT : Integer.parseInt(arguments.get(0));
- if (timeout < NO_TIMEOUT) throw new RemoteException("The value for the timeout cannot be less than " + NO_TIMEOUT);
- return timeout == NO_TIMEOUT ? "Remote timeout is disabled" : "Set remote timeout to " + timeout + "ms";
- } catch (Exception ignored) {
- throw new RemoteException(errorMessage);
- }
- } else if (option.equals(TOKEN_ALIAS)) {
- if (arguments.size() == 1 && arguments.get(0).equals(TOKEN_RESET)) {
- aliases.clear();
- return "Aliases cleared";
- }
-
- if (arguments.size() == 1 && arguments.get(0).equals(TOKEN_SHOW)) {
- return aliases;
- }
-
- if (arguments.size() % 2 != 0)
- throw new RemoteException("Arguments to alias must be 'reset' to clear any existing alias settings or key/value alias/binding pairs");
-
- final Map<String,Object> aliasMap = ElementHelper.asMap(arguments.toArray());
- aliases.clear();
- aliasMap.forEach((k,v) -> aliases.put(k, v.toString()));
- return aliases;
- }
-
- return this.toString();
- }
-
- @Override
- public Object submit(final List<String> args) throws RemoteException {
- final String line = RemoteAcceptor.getScript(String.join(" ", args), this.shell);
-
- try {
- final List<Result> resultSet = send(line);
- this.shell.getInterp().getContext().setProperty(RESULT, resultSet);
- return resultSet.stream().map(result -> result.getObject()).iterator();
- } catch (SaslException sasl) {
- throw new RemoteException("Security error - check username/password and related settings", sasl);
- } catch (Exception ex) {
- final Optional<ResponseException> inner = findResponseException(ex);
- if (inner.isPresent()) {
- final ResponseException responseException = inner.get();
- if (responseException.getResponseStatusCode() == ResponseStatusCode.SERVER_ERROR_SERIALIZATION)
- throw new RemoteException(String.format("Server could not serialize the result requested. Server error - %s. Note that the class must be serializable by the client and server for proper operation.", responseException.getMessage()));
- else
- throw new RemoteException(responseException.getMessage());
- } else if (ex.getCause() != null) {
- final Throwable rootCause = ExceptionUtils.getRootCause(ex);
- if (rootCause instanceof TimeoutException)
- throw new RemoteException("Host did not respond in a timely fashion - check the server status and submit again.");
- else
- throw new RemoteException(rootCause.getMessage());
- } else
- throw new RemoteException(ex.getMessage());
- }
- }
-
- @Override
- public void close() throws IOException {
- if (this.currentClient != null) this.currentClient.close();
- if (this.currentCluster != null) this.currentCluster.close();
- }
-
- public int getTimeout() {
- return timeout;
- }
-
- private List<Result> send(final String gremlin) throws SaslException {
- try {
- final ResultSet rs = this.currentClient.submitAsync(gremlin, aliases, Collections.emptyMap()).get();
- return timeout > NO_TIMEOUT ? rs.all().get(timeout, TimeUnit.MILLISECONDS) : rs.all().get();
- } catch(TimeoutException ignored) {
- throw new IllegalStateException("Request timed out while processing - increase the timeout with the :remote command");
- } catch (Exception e) {
- // handle security error as-is and unwrapped
- final Optional<Throwable> throwable = Stream.of(ExceptionUtils.getThrowables(e)).filter(t -> t instanceof SaslException).findFirst();
- if (throwable.isPresent())
- throw (SaslException) throwable.get();
-
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- @Override
- public boolean allowRemoteConsole() {
- return true;
- }
-
- @Override
- public String toString() {
- return "Gremlin Server - [" + this.currentCluster + "]" + getSessionStringSegment();
- }
-
- private Optional<ResponseException> findResponseException(final Throwable ex) {
- if (ex instanceof ResponseException)
- return Optional.of((ResponseException) ex);
-
- if (null == ex.getCause())
- return Optional.empty();
-
- return findResponseException(ex.getCause());
- }
-
- private String getSessionStringSegment() {
- return session.isPresent() ? String.format("-[%s]", session.get()) : "";
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
deleted file mode 100644
index df0541f..0000000
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor;
-import org.apache.tinkerpop.gremlin.groovy.plugin.AbstractGremlinPlugin;
-import org.apache.tinkerpop.gremlin.groovy.plugin.IllegalEnvironmentException;
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor;
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginInitializationException;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor;
-
-import java.util.Optional;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.GephiGremlinPlugin}.
- */
-public class GephiGremlinPlugin extends AbstractGremlinPlugin {
-
- public GephiGremlinPlugin() {
- super(true);
- }
-
- @Override
- public String getName() {
- return "tinkerpop.gephi";
- }
-
- @Override
- public Optional<RemoteAcceptor> remoteAcceptor() {
- return Optional.of(new GephiRemoteAcceptor(shell, io));
- }
-
- @Override
- public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException {
- // do nothing
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
deleted file mode 100644
index d1c853d..0000000
--- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.groovy.plugin.AbstractGremlinPlugin;
-import org.apache.tinkerpop.gremlin.groovy.plugin.IllegalEnvironmentException;
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor;
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginInitializationException;
-import groovyx.gbench.Benchmark;
-import groovyx.gbench.BenchmarkStaticExtension;
-import groovyx.gprof.ProfileStaticExtension;
-import groovyx.gprof.Profiler;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.console.jsr223.UtilitiesGremlinPlugin}.
- */
-public class UtilitiesGremlinPlugin extends AbstractGremlinPlugin {
-
- private static final Set<String> IMPORTS = new HashSet<String>() {{
- add(IMPORT_SPACE + Benchmark.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_STATIC_SPACE + BenchmarkStaticExtension.class.getName() + DOT_STAR);
- add(IMPORT_SPACE + Profiler.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_STATIC_SPACE + ProfileStaticExtension.class.getName() + DOT_STAR);
- }};
-
- @Override
- public String getName() {
- return "tinkerpop.utilities";
- }
-
- @Override
- public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException {
- pluginAcceptor.addImports(IMPORTS);
-
- String line;
- try {
- final BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("UtilitiesGremlinPluginScript.groovy")));
- while ((line = reader.readLine()) != null) {
- pluginAcceptor.eval(line);
- }
- reader.close();
- } catch (Exception ex) {
- if (io != null)
- io.out.println("Error loading the 'utilities' plugin - " + ex.getMessage());
- else
- throw new PluginInitializationException("Error loading the 'utilities' plugin - " + ex.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin b/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
deleted file mode 100644
index a74add4..0000000
--- a/gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
+++ /dev/null
@@ -1,3 +0,0 @@
-org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin
-org.apache.tinkerpop.gremlin.console.groovy.plugin.GephiGremlinPlugin
-org.apache.tinkerpop.gremlin.console.groovy.plugin.UtilitiesGremlinPlugin
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/AbstractGremlinServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/AbstractGremlinServerIntegrationTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/AbstractGremlinServerIntegrationTest.java
deleted file mode 100644
index a6787e6..0000000
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/AbstractGremlinServerIntegrationTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.server.GremlinServer;
-import org.apache.tinkerpop.gremlin.server.Settings;
-import org.junit.After;
-import org.junit.Before;
-
-import java.io.File;
-import java.io.InputStream;
-
-/**
- * Starts and stops an instance for each executed test.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public abstract class AbstractGremlinServerIntegrationTest {
- private GremlinServer server;
-
- public Settings overrideSettings(final Settings settings) {
- return settings;
- }
-
- public InputStream getSettingsInputStream() {
- return AbstractGremlinServerIntegrationTest.class.getResourceAsStream("gremlin-server-integration.yaml");
- }
-
- @Before
- public void setUp() throws Exception {
- final InputStream stream = getSettingsInputStream();
- final Settings settings = Settings.read(stream);
-
- final Settings overridenSettings = overrideSettings(settings);
- this.server = new GremlinServer(overridenSettings);
-
- server.start().join();
- }
-
- @After
- public void tearDown() throws Exception {
- stopServer();
- }
-
- public void stopServer() throws Exception {
- server.stop().join();
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPluginTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPluginTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPluginTest.java
deleted file mode 100644
index 6ff5721..0000000
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPluginTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 org.codehaus.groovy.tools.shell.Groovysh;
-import org.codehaus.groovy.tools.shell.IO;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class DriverGremlinPluginTest {
-
- @Test
- public void shouldConstructEmptyRemoteAcceptorWhenNotInConsoleEnvironment() throws Exception {
- final DriverGremlinPlugin plugin = new DriverGremlinPlugin();
- final SpyPluginAcceptor spy = new SpyPluginAcceptor();
- plugin.pluginTo(spy);
-
- assertThat(plugin.remoteAcceptor().isPresent(), is(false));
- }
-
- @Test
- public void shouldConstructRemoteAcceptorWhenInConsoleEnvironment() throws Exception {
- final DriverGremlinPlugin plugin = new DriverGremlinPlugin();
- final Map<String, Object> env = new HashMap<>();
- env.put("ConsolePluginAcceptor.io", new IO());
- env.put("ConsolePluginAcceptor.shell", new Groovysh());
- final SpyPluginAcceptor spy = new SpyPluginAcceptor(() -> env);
- plugin.pluginTo(spy);
-
- assertThat(plugin.remoteAcceptor().isPresent(), is(true));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorIntegrateTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorIntegrateTest.java
deleted file mode 100644
index 1363c26..0000000
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorIntegrateTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.driver.Result;
-import org.apache.tinkerpop.gremlin.server.Settings;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.codehaus.groovy.tools.shell.Groovysh;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class DriverRemoteAcceptorIntegrateTest extends AbstractGremlinServerIntegrationTest {
- private final Groovysh groovysh = new Groovysh();
- private DriverRemoteAcceptor acceptor;
-
- @Rule
- public TestName name = new TestName();
-
- /**
- * Configure specific Gremlin Server settings for specific tests.
- */
- @Override
- public Settings overrideSettings(final Settings settings) {
- try {
- final String tinkerGraphConfig = TestHelper.generateTempFileFromResource(this.getClass(), "tinkergraph-empty.properties", ".tmp").getAbsolutePath();
- settings.graphs.put("g", tinkerGraphConfig);
- return settings;
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- @Before
- public void before() throws Exception {
- acceptor = new DriverRemoteAcceptor(groovysh);
- }
-
- @After
- public void after() {
- try {
- acceptor.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- @Test
- public void shouldConnect() throws Exception {
- assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- }
-
- @Test
- public void shouldConnectAndSubmitSession() throws Exception {
- assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session")).toString(), startsWith("Configured "));
- assertEquals("1", ((Iterator) acceptor.submit(Collections.singletonList("x = 1"))).next());
- assertEquals("0", ((Iterator) acceptor.submit(Collections.singletonList("x - 1"))).next());
- assertEquals("0", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- }
-
- @Test
- public void shouldConnectAndSubmitManagedSession() throws Exception {
- assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session-managed")).toString(), startsWith("Configured "));
- assertEquals("1", ((Iterator) acceptor.submit(Collections.singletonList("x = 1"))).next());
- assertEquals("0", ((Iterator) acceptor.submit(Collections.singletonList("x - 1"))).next());
- assertEquals("0", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- }
-
- @Test
- public void shouldConnectAndSubmitSimple() throws Exception {
- assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- assertEquals("2", ((Iterator) acceptor.submit(Collections.singletonList("1+1"))).next());
- assertEquals("2", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- }
-
- @Test
- public void shouldConnectAndSubmitSimpleList() throws Exception {
- assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- assertThat(IteratorUtils.list(((Iterator<String>) acceptor.submit(Collections.singletonList("[1,2,3,4,5]")))), contains("1", "2", "3", "4", "5"));
- assertThat(((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).stream().map(Result::getString).collect(Collectors.toList()), contains("1", "2", "3", "4", "5"));
- }
-
- @Test
- public void shouldConnectAndReturnVertices() throws Exception {
- assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- assertThat(IteratorUtils.list(((Iterator<String>) acceptor.submit(Collections.singletonList("g.addVertex('name','stephen');g.addVertex('name','marko');g.traversal().V()")))), hasSize(2));
- assertThat(((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).stream().map(Result::getString).collect(Collectors.toList()), hasSize(2));
- }
-
- @Test
- public void shouldConnectAndReturnVerticesWithAnAlias() throws Exception {
- assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- acceptor.configure(Arrays.asList("alias", "x", "g"));
- assertThat(IteratorUtils.list(((Iterator<String>) acceptor.submit(Collections.singletonList("x.addVertex('name','stephen');x.addVertex('name','marko');x.traversal().V()")))), hasSize(2));
- assertThat(((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).stream().map(Result::getString).collect(Collectors.toList()), hasSize(2));
- }
-
- @Test
- public void shouldConnectAndSubmitForNull() throws Exception {
- assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- assertThat(IteratorUtils.list(((Iterator<String>) acceptor.submit(Collections.singletonList("g.traversal().V().drop().iterate();null")))), contains("null"));
- assertThat(((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).stream().map(Result::getObject).collect(Collectors.toList()), contains("null"));
- }
-
- @Test
- public void shouldConnectAndSubmitInSession() throws Exception {
- assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session")).toString(), startsWith("Configured "));
- assertEquals("2", ((Iterator) acceptor.submit(Collections.singletonList("x=1+1"))).next());
- assertEquals("2", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- assertEquals("4", ((Iterator) acceptor.submit(Collections.singletonList("x+2"))).next());
- assertEquals("4", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- }
-
- @Test
- public void shouldConnectAndSubmitInNamedSession() throws Exception {
- assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session", "AAA")).toString(), startsWith("Configured "));
- assertEquals("2", ((Iterator) acceptor.submit(Collections.singletonList("x=1+1"))).next());
- assertEquals("2", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- assertEquals("4", ((Iterator) acceptor.submit(Collections.singletonList("x+2"))).next());
- assertEquals("4", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
deleted file mode 100644
index ef2a0c6..0000000
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException;
-import org.codehaus.groovy.tools.shell.Groovysh;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class DriverRemoteAcceptorTest {
-
- private final Groovysh groovysh = new Groovysh();
- private DriverRemoteAcceptor acceptor;
-
- @Before
- public void setUp() {
- acceptor = new DriverRemoteAcceptor(groovysh);
- }
-
- @After
- public void tearDown() {
- try {
- acceptor.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- @Test(expected = RemoteException.class)
- public void shouldNotConfigureWithBadCommand() throws Exception {
- acceptor.configure(Arrays.asList("test"));
- }
-
- @Test(expected = RemoteException.class)
- public void shouldNotConfigureWithUnevenPairsOfAliases() throws Exception {
- acceptor.configure(Arrays.asList("alias g social x"));
- }
-
- @Test
- public void shouldResetAliases() throws Exception {
- final Map<String,String> resetAliases = (Map<String,String>) acceptor.configure(Arrays.asList("alias", "g", "main.social"));
- assertEquals(1, resetAliases.size());
- assertEquals("main.social", resetAliases.get("g"));
-
- assertEquals("Aliases cleared", acceptor.configure(Arrays.asList("alias", "reset")));
-
- final Map<String,String> shownAliases = (Map<String,String>) acceptor.configure(Arrays.asList("alias", "show"));
- assertEquals(0, shownAliases.size());
- }
-
- @Test
- public void shouldAddOverwriteAndShowAliases() throws Exception {
- final Map<String,String> aliases = (Map<String,String>) acceptor.configure(Arrays.asList("alias", "g", "social", "graph", "main"));
- assertEquals(2, aliases.size());
- assertEquals("social", aliases.get("g"));
- assertEquals("main", aliases.get("graph"));
-
- final Map<String,String> resetAliases = (Map<String,String>) acceptor.configure(Arrays.asList("alias", "g", "main.social"));
- assertEquals(1, resetAliases.size());
- assertEquals("main.social", resetAliases.get("g"));
-
- final Map<String,String> shownAliases = (Map<String,String>) acceptor.configure(Arrays.asList("alias", "show"));
- assertEquals(1, shownAliases.size());
- assertEquals("main.social", shownAliases.get("g"));
- }
-
- @Test(expected = RemoteException.class)
- public void shouldNotConnectWithEmptyArgs() throws Exception {
- acceptor.connect(new ArrayList<>());
- }
-
- @Test(expected = RemoteException.class)
- public void shouldNotConnectWithTooManyArgs() throws Exception {
- acceptor.connect(Arrays.asList("two", "too", "many"));
- }
-
- @Test(expected = RemoteException.class)
- public void shouldNotConnectWithInvalidConfigFile() throws Exception {
- acceptor.connect(Arrays.asList("this-isnt-real.yaml"));
- }
-
- @Test
- public void shouldConfigureTimeoutToMax() throws Exception {
- acceptor.configure(Arrays.asList("timeout", "max"));
- assertEquals(Integer.MAX_VALUE, acceptor.getTimeout());
- }
-
- @Test
- public void shouldConfigureTimeoutToNone() throws Exception {
- acceptor.configure(Arrays.asList("timeout", "none"));
- assertEquals(DriverRemoteAcceptor.NO_TIMEOUT, acceptor.getTimeout());
- }
-
- @Test
- public void shouldConfigureTimeout() throws Exception {
- acceptor.configure(Arrays.asList("timeout", "123456"));
- assertEquals(123456, acceptor.getTimeout());
- }
-
- @Test(expected = RemoteException.class)
- public void shouldConfigureTimeoutNotLessThanNoTimeout() throws Exception {
- acceptor.configure(Arrays.asList("timeout", "-1"));
- }
-
- @Test
- public void shouldConnect() throws Exception {
- // there is no gremlin server running for this test, but gremlin-driver lazily connects so this should
- // be ok to just validate that a connection is created
- assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/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
deleted file mode 100644
index afda528..0000000
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.Mediator;
-import org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor;
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-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.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.ServerSocket;
-import java.util.Arrays;
-import java.util.Collections;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
-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.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(new Mediator(null));
- private static int port = pickOpenPort();
-
- 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(port);
-
- static {
- final Graph graph = TinkerFactory.createModern();
- groovysh.getInterp().getContext().setProperty("graph", graph);
- }
-
- @Before
- public void before() throws Exception {
- acceptor = new GephiRemoteAcceptor(groovysh, io);
- acceptor.configure(Arrays.asList("port", String.valueOf(port)));
- }
-
- @Test
- public void shouldConnectWithDefaults() throws RemoteException {
- assertThat(acceptor.connect(Collections.emptyList()).toString(), startsWith("Connection to Gephi - http://localhost:" + port + "/workspace1"));
- }
-
- @Test
- public void shouldSubmitGraph() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace1"))
- .withQueryParam("format", equalTo("JSON"))
- .withQueryParam("operation", equalTo("updateGraph"))
- .willReturn(aResponse()
- .withStatus(200)));
-
- stubFor(get(urlPathEqualTo("/workspace1"))
- .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(4, postRequestedFor(urlPathEqualTo("/workspace1")));
- wireMockRule.verify(1, getRequestedFor(urlPathEqualTo("/workspace1")));
- }
-
- @Test
- public void shouldSubmitTraversalAfterConfigWithDefaultG() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace1"))
- .withQueryParam("format", equalTo("JSON"))
- .withQueryParam("operation", equalTo("updateGraph"))
- .willReturn(aResponse()
- .withStatus(200)));
-
- acceptor.configure(Arrays.asList("visualTraversal", "graph"));
-
- // call iterate() as groovysh isn't rigged to auto-iterate
- acceptor.submit(Arrays.asList(
- "vg.V(2).in('knows').out('knows').has('age',org.apache.tinkerpop.gremlin.process.traversal.P.gt(30)).outE('created').has('weight',org.apache.tinkerpop.gremlin.process.traversal.P.gt(0.5d)).inV().iterate()"));
-
- wireMockRule.verify(18, postRequestedFor(urlPathEqualTo("/workspace1")));
- }
-
- @Test
- public void shouldSubmitTraversalAfterConfigWithDefinedG() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace1"))
- .withQueryParam("format", equalTo("JSON"))
- .withQueryParam("operation", equalTo("updateGraph"))
- .willReturn(aResponse()
- .withStatus(200)));
-
- acceptor.configure(Arrays.asList("visualTraversal", "graph", "x"));
-
- // call iterate() as groovysh isn't rigged to auto-iterate
- acceptor.submit(Arrays.asList(
- "x.V(2).in('knows').out('knows').has('age',org.apache.tinkerpop.gremlin.process.traversal.P.gt(30)).outE('created').has('weight',org.apache.tinkerpop.gremlin.process.traversal.P.gt(0.5d)).inV().iterate()"));
-
- wireMockRule.verify(18, postRequestedFor(urlPathEqualTo("/workspace1")));
- }
-
- @Test
- public void shouldSubmitTraversalOverRepeat() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace1"))
- .withQueryParam("format", equalTo("JSON"))
- .withQueryParam("operation", equalTo("updateGraph"))
- .willReturn(aResponse()
- .withStatus(200)));
-
- acceptor.configure(Arrays.asList("visualTraversal", "graph"));
-
- // call iterate() as groovysh isn't rigged to auto-iterate
- acceptor.submit(Arrays.asList(
- "vg.V(1).repeat(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.__().out()).times(2).iterate()"));
-
- wireMockRule.verify(13, postRequestedFor(urlPathEqualTo("/workspace1")));
- }
-
- @Test
- public void shouldClearGraph() throws RemoteException {
- stubFor(post(urlPathEqualTo("/workspace1"))
- .withQueryParam("format", equalTo("JSON"))
- .withQueryParam("operation", equalTo("updateGraph"))
- .withRequestBody(equalToJson("{\"dn\":{\"filter\":\"ALL\"}}"))
- .willReturn(aResponse()
- .withStatus(200)));
-
- acceptor.submit(Arrays.asList("clear"));
-
- wireMockRule.verify(1, postRequestedFor(urlPathEqualTo("/workspace1")));
- }
-
- private static int pickOpenPort() {
- try (final ServerSocket socket = new ServerSocket(0)) {
- return socket.getLocalPort();
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1cc19e9a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
deleted file mode 100644
index fb8f990..0000000
--- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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 org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.console.PluggedIn;
-import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer;
-import org.apache.tinkerpop.gremlin.jsr223.Customizer;
-import org.apache.tinkerpop.gremlin.jsr223.DefaultBindingsCustomizer;
-import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
-import org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin;
-import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin;
-import org.junit.Test;
-
-import javax.script.Bindings;
-import javax.script.SimpleBindings;
-import java.io.File;
-import java.time.DayOfWeek;
-import java.time.temporal.TemporalAccessor;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsCollectionContaining.hasItems;
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class GremlinPluginAdapterTest {
-
- @Test
- public void shouldAdaptForImportCustomizer() throws Exception {
- final ImportGremlinPlugin plugin = ImportGremlinPlugin.build()
- .classImports(java.awt.Color.class, java.sql.CallableStatement.class)
- .enumImports(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)
- .methodImports(DayOfWeek.class.getMethod("from", TemporalAccessor.class), DayOfWeek.class.getMethod("values")).create();
- final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, null, null);
-
- assertEquals(plugin.getName(), adapter.getName());
-
- final SpyPluginAcceptor spy = new SpyPluginAcceptor();
- adapter.pluginTo(spy);
-
- final Set<String> imports = spy.getImports();
- assertEquals(3, imports.size());
- assertThat(imports, hasItems("import " + java.awt.Color.class.getPackage().getName() + ".*",
- "import " + java.sql.CallableStatement.class.getPackage().getName() + ".*",
- "import static " + DayOfWeek.class.getCanonicalName() + ".*"));
- }
-
- @Test
- public void shouldAdaptForScriptCustomizer() throws Exception {
- final File scriptFile1 = TestHelper.generateTempFileFromResource(GremlinPluginAdapterTest.class, "script-customizer-1.groovy", ".groovy");
- final File scriptFile2 = TestHelper.generateTempFileFromResource(GremlinPluginAdapterTest.class, "script-customizer-2.groovy", ".groovy");
- final List<String> files = new ArrayList<>();
- files.add(scriptFile1.getAbsolutePath());
- files.add(scriptFile2.getAbsolutePath());
- final ScriptFileGremlinPlugin plugin = ScriptFileGremlinPlugin.build().files(files).create();
- final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, null, null);
-
- assertEquals(plugin.getName(), adapter.getName());
-
- final List<String> evals = new ArrayList<>();
- final SpyPluginAcceptor spy = new SpyPluginAcceptor(evals::add);
- adapter.pluginTo(spy);
-
- assertEquals("x = 1 + 1\n" +
- "y = 10 * x\n" +
- "z = 1 + x + y", evals.get(0));
- assertEquals("l = g.V(z).out()\n" +
- " .group().by('name')", evals.get(1));
- }
-
- @Test
- public void shouldAdaptForBindingsCustomizer() throws Exception {
- final Bindings bindings = new SimpleBindings();
- bindings.put("x", 1);
- bindings.put("y", "yes");
- bindings.put("z", true);
- final BindingsCustomizer bindingsCustomizer = new DefaultBindingsCustomizer(bindings);
- final GremlinPlugin plugin = new GremlinPlugin() {
- @Override
- public String getName() {
- return "anon-bindings";
- }
-
- @Override
- public Optional<Customizer[]> getCustomizers(final String scriptEngineName) {
- return Optional.of(new Customizer[]{bindingsCustomizer});
- }
- };
- final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, null, null);
-
- assertEquals(plugin.getName(), adapter.getName());
-
- final SpyPluginAcceptor spy = new SpyPluginAcceptor();
- adapter.pluginTo(spy);
-
- final Map<String,Object> bindingsFromSpy = spy.getBindings();
- assertEquals(1, bindingsFromSpy.get("x"));
- assertEquals("yes", bindingsFromSpy.get("y"));
- assertEquals(true, bindingsFromSpy.get("z"));
- }
-}