From f42e939afe9bb0c14cbaade43000e9992a5d3c70 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 24 Jan 2017 07:22:07 -0500 Subject: [PATCH 01/34] TINKERPOP-1612 WIP - first step to removal of gremlin-groovy-test --- gremlin-groovy-test/pom.xml | 64 --- .../groovy/util/SugarTestHelper.groovy | 37 -- .../step/branch/GroovyBranchTest.groovy | 58 --- .../step/branch/GroovyChooseTest.groovy | 67 --- .../step/branch/GroovyLocalTest.groovy | 91 ----- .../step/branch/GroovyOptionalTest.groovy | 59 --- .../step/branch/GroovyRepeatTest.groovy | 88 ---- .../step/branch/GroovyUnionTest.groovy | 77 ---- .../step/filter/GroovyAndTest.groovy | 52 --- .../step/filter/GroovyCoinTest.groovy | 41 -- .../step/filter/GroovyCyclicPathTest.groovy | 43 -- .../step/filter/GroovyDedupTest.groovy | 113 ------ .../step/filter/GroovyDropTest.groovy | 51 --- .../step/filter/GroovyFilterTest.groovy | 73 ---- .../step/filter/GroovyHasTest.groovy | 173 -------- .../traversal/step/filter/GroovyIsTest.groovy | 57 --- .../traversal/step/filter/GroovyOrTest.groovy | 47 --- .../step/filter/GroovyRangeTest.groovy | 127 ------ .../step/filter/GroovySampleTest.groovy | 58 --- .../step/filter/GroovySimplePathTest.groovy | 43 -- .../step/filter/GroovyTailTest.groovy | 92 ----- .../step/filter/GroovyWhereTest.groovy | 167 -------- .../step/map/GroovyAddEdgeTest.groovy | 85 ---- .../step/map/GroovyAddVertexTest.groovy | 101 ----- .../step/map/GroovyCoalesceTest.groovy | 59 --- .../step/map/GroovyConstantTest.groovy | 42 -- .../traversal/step/map/GroovyCountTest.groovy | 76 ---- .../step/map/GroovyFlatMapTest.groovy | 36 -- .../traversal/step/map/GroovyFoldTest.groovy | 46 --- .../traversal/step/map/GroovyGraphTest.groovy | 55 --- .../traversal/step/map/GroovyLoopsTest.groovy | 56 --- .../step/map/GroovyMapKeysTest.groovy | 43 -- .../traversal/step/map/GroovyMapTest.groovy | 62 --- .../step/map/GroovyMapValuesTest.groovy | 48 --- .../traversal/step/map/GroovyMatchTest.groovy | 381 ------------------ .../traversal/step/map/GroovyMaxTest.groovy | 47 --- .../traversal/step/map/GroovyMeanTest.groovy | 42 -- .../traversal/step/map/GroovyMinTest.groovy | 47 --- .../traversal/step/map/GroovyOrderTest.groovy | 140 ------- .../step/map/GroovyPageRankTest.groovy | 78 ---- .../traversal/step/map/GroovyPathTest.groovy | 63 --- .../step/map/GroovyPeerPressureTest.groovy | 48 --- .../step/map/GroovyProfileTest.groovy | 94 ----- .../step/map/GroovyProgramTest.groovy | 50 --- .../step/map/GroovyProjectTest.groovy | 42 -- .../step/map/GroovyPropertiesTest.groovy | 60 --- .../step/map/GroovySelectTest.groovy | 252 ------------ .../traversal/step/map/GroovySumTest.groovy | 42 -- .../step/map/GroovyUnfoldTest.groovy | 48 --- .../step/map/GroovyValueMapTest.groovy | 51 --- .../step/map/GroovyVertexTest.groovy | 187 --------- .../sideEffect/GroovyAggregateTest.groovy | 53 --- .../step/sideEffect/GroovyExplainTest.groovy | 35 -- .../sideEffect/GroovyGroupCountTest.groovy | 101 ----- .../step/sideEffect/GroovyGroupTest.groovy | 137 ------- .../sideEffect/GroovyGroupTestV3d0.groovy | 74 ---- .../step/sideEffect/GroovyInjectTest.groovy | 42 -- .../step/sideEffect/GroovySackTest.groovy | 84 ---- .../sideEffect/GroovySideEffectCapTest.groovy | 45 --- .../sideEffect/GroovySideEffectTest.groovy | 83 ---- .../step/sideEffect/GroovyStoreTest.groovy | 53 --- .../step/sideEffect/GroovySubgraphTest.groovy | 50 --- .../step/sideEffect/GroovyTreeTest.groovy | 69 ---- .../GroovyEnvironmentIntegrateSuite.java | 85 ---- .../groovy/GroovyEnvironmentSuite.java | 92 ----- .../util/TestableConsolePluginAcceptor.java | 79 ---- .../process/GroovyProcessComputerSuite.java | 204 ---------- .../process/GroovyProcessStandardSuite.java | 198 --------- .../services/javax.script.ScriptEngineFactory | 1 - .../groovy/engine/GremlinExecutorInit.groovy | 19 - gremlin-groovy/pom.xml | 6 + .../groovy/loaders/SugarLoaderTest.groovy | 48 ++- .../groovy/util/SugarTestHelper.groovy | 74 ++++ .../engine/GremlinExecutorOverGraphTest.java | 19 +- ...mlinGroovyScriptEngineFileSandboxTest.java | 34 +- ...remlinGroovyScriptEngineIntegrateTest.java | 14 +- ...remlinGroovyScriptEngineOverGraphTest.java | 93 +++-- ...oovyScriptEngineSandboxedStandardTest.java | 57 ++- ...roovyScriptEngineTinkerPopSandboxTest.java | 27 +- .../jsr223/GroovyScriptEngineSetup.java | 69 ++++ .../GroovyTranslatorComputerProvider.java | 7 +- .../GroovyTranslatorProcessComputerTest.java | 9 +- .../GroovyTranslatorProcessStandardTest.java | 9 +- .../jsr223/GroovyTranslatorProvider.java | 10 +- .../groovy/jsr223/GroovyTranslatorTest.java | 10 +- .../dsl/credential/CredentialGraphTest.java | 21 +- .../dsl/credential/CredentialGraphTest.java | 23 +- .../gremlin/util/TinkerGraphProvider.java | 206 ++++++++++ .../gremlin/groovy/jsr223/sandbox.yaml | 0 gremlin-python/pom.xml | 4 +- .../gremlin/python/jsr223/PythonProvider.java | 2 - .../gremlin-server-modern-secure-py.yaml | 6 +- .../conf/gremlin-server-classic.yaml | 9 +- gremlin-server/conf/gremlin-server-min.yaml | 2 - .../conf/gremlin-server-modern-py.yaml | 9 +- .../conf/gremlin-server-modern-readonly.yaml | 9 +- .../conf/gremlin-server-modern.yaml | 9 +- gremlin-server/conf/gremlin-server-neo4j.yaml | 9 +- .../conf/gremlin-server-rest-modern.yaml | 9 +- .../conf/gremlin-server-rest-secure.yaml | 15 +- .../conf/gremlin-server-secure.yaml | 15 +- gremlin-server/conf/gremlin-server-spark.yaml | 9 +- gremlin-server/conf/gremlin-server.yaml | 9 +- gremlin-server/pom.xml | 6 - .../server/GremlinServerIntegrateTest.java | 28 +- .../remote/gremlin-server-integration.yaml | 9 +- .../server/gremlin-server-integration.yaml | 9 +- .../gremlin/hadoop/structure/HadoopGraph.java | 2 - .../plugin/HadoopGremlinPluginCheck.java | 86 +++- neo4j-gremlin/pom.xml | 11 - .../groovy/plugin/Neo4jGremlinPlugin.java | 62 --- .../gremlin/neo4j/structure/Neo4jGraph.java | 3 - ...kerpop.gremlin.groovy.plugin.GremlinPlugin | 1 - ...taNeo4jGraphGroovyProcessStandardTest.java | 33 -- ...taNeo4jGraphGroovyProcessStandardTest.java | 34 -- .../structure/NativeNeo4jStructureCheck.java | 53 +-- pom.xml | 1 - tinkergraph-gremlin/pom.xml | 17 +- .../plugin/TinkerGraphGremlinPlugin.java | 57 --- .../tinkergraph/structure/TinkerGraph.java | 4 - ...kerpop.gremlin.groovy.plugin.GremlinPlugin | 1 - .../TinkerGraphGroovyProcessComputerTest.java | 33 -- .../TinkerGraphGroovyProcessStandardTest.java | 33 -- ...GraphGroovyTranslatorComputerProvider.java | 37 -- ...phGroovyTranslatorProcessComputerTest.java | 33 -- ...phGroovyTranslatorProcessStandardTest.java | 33 -- .../TinkerGraphJavaTranslatorProvider.java | 74 ---- ...erGraphGroovyEnvironmentIntegrateTest.java | 37 -- .../TinkerGraphGroovyEnvironmentTest.java | 37 -- .../TinkerGraphUUIDGroovyEnvironmentTest.java | 38 -- 130 files changed, 737 insertions(+), 6450 deletions(-) delete mode 100644 gremlin-groovy-test/pom.xml delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyBranchTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyLocalTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyOptionalTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyAndTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCoinTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCyclicPathTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDedupTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDropTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyFilterTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyIsTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyOrTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyRangeTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySampleTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySimplePathTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddEdgeTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddVertexTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCoalesceTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyConstantTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFlatMapTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFoldTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyGraphTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyLoopsTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapKeysTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapValuesTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMaxTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMeanTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMinTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyOrderTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPageRankTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPathTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPeerPressureTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProfileTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProgramTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProjectTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPropertiesTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySumTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyUnfoldTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyVertexTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyAggregateTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyExplainTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupCountTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTestV3d0.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyInjectTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectCapTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy delete mode 100644 gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyTreeTest.groovy delete mode 100644 gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java delete mode 100644 gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java delete mode 100644 gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/TestableConsolePluginAcceptor.java delete mode 100644 gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java delete mode 100644 gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java delete mode 100644 gremlin-groovy-test/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory delete mode 100644 gremlin-groovy-test/src/main/resources/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorInit.groovy rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy (78%) create mode 100644 gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java (87%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java (79%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java (88%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java (80%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java (66%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java (67%) create mode 100644 gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyScriptEngineSetup.java rename tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorComputerProvider.java => gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorComputerProvider.java (89%) rename tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessComputerTest.java => gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessComputerTest.java (83%) rename tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessStandardTest.java => gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessStandardTest.java (83%) rename tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java => gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java (88%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java (94%) rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java (83%) rename {gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy => gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin}/plugin/dsl/credential/CredentialGraphTest.java (82%) create mode 100644 gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java rename {gremlin-groovy-test/src/main => gremlin-groovy/src/test}/resources/org/apache/tinkerpop/gremlin/groovy/jsr223/sandbox.yaml (100%) delete mode 100644 neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java delete mode 100644 neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin delete mode 100644 neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/MultiMetaNeo4jGraphGroovyProcessStandardTest.java delete mode 100644 neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/NoMultiNoMetaNeo4jGraphGroovyProcessStandardTest.java delete mode 100644 tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/groovy/plugin/TinkerGraphGremlinPlugin.java delete mode 100644 tinkergraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessComputerTest.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessStandardTest.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorComputerProvider.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessComputerTest.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessStandardTest.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentIntegrateTest.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentTest.java delete mode 100644 tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphUUIDGroovyEnvironmentTest.java diff --git a/gremlin-groovy-test/pom.xml b/gremlin-groovy-test/pom.xml deleted file mode 100644 index 853b59f56c1..00000000000 --- a/gremlin-groovy-test/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - org.apache.tinkerpop - tinkerpop - 3.3.0-SNAPSHOT - - gremlin-groovy-test - Apache TinkerPop :: Gremlin Groovy Test - - - org.apache.tinkerpop - gremlin-test - ${project.version} - - - org.apache.tinkerpop - gremlin-groovy - ${project.version} - - - - ${basedir}/target - ${project.artifactId}-${project.version} - - - ${basedir}/src/main/resources - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy deleted file mode 100644 index 7ff0be86cb4..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy +++ /dev/null @@ -1,37 +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.groovy.util - -import org.apache.tinkerpop.gremlin.GraphProvider - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -final class SugarTestHelper { - - /** - * Clear the metaclass registry to "turn-off" sugar. - */ - public static void clearRegistry(final GraphProvider graphProvider) { - final Set implementationsToClear = new HashSet<>(GraphProvider.CORE_IMPLEMENTATIONS) - implementationsToClear.addAll(graphProvider.getImplementations()); - - MetaRegistryUtil.clearRegistry(implementationsToClear) - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyBranchTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyBranchTest.groovy deleted file mode 100644 index e602f4eb12a..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyBranchTest.groovy +++ /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.process.traversal.step.branch - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyBranchTest { - - public static class Traversals extends BranchTest { - - @Override - public Traversal get_g_V_branchXlabel_eq_person__a_bX_optionXa__ageX_optionXb__langX_optionXb__nameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.branch(__.label.is('person').count).option(1L, __.age).option(0L, __.lang).option(0L,__.name)"); - } - - @Override - public Traversal get_g_V_branchXlabel_isXpersonX_countX_optionX1__ageX_optionX0__langX_optionX0__nameX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.branch{it.label == 'person' ? 'a' : 'b'} - .option('a', __.age) - .option('b', __.lang) - .option('b', __.name) - """) - } - - @Override - public Traversal get_g_V_branchXlabel_isXpersonX_countX_optionX1__ageX_optionX0__langX_optionX0__nameX_optionXany__labelX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.branch(label().is("person").count) - .option(1L,__.age) - .option(0L,__.lang) - .option(0L,__.name) - .option(any,label()) - """) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy deleted file mode 100644 index 802c4275708..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyChooseTest.groovy +++ /dev/null @@ -1,67 +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.process.traversal.step.branch - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @author Joshua Shinavier (http://fortytwo.net) - */ -public abstract class GroovyChooseTest { - - public static class Traversals extends ChooseTest { - @Override - public Traversal get_g_V_chooseXout_countX_optionX2L__nameX_optionX3L__valueMapX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(__.out.count).option(2L, __.values('name')).option(3L, __.valueMap())") - } - - @Override - public Traversal get_g_V_chooseXlabel_eqXpersonX__outXknowsX__inXcreatedXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose({it.label() == 'person'}, out('knows'), __.in('created')).name") - } - - @Override - public Traversal get_g_V_chooseXhasLabelXpersonX_and_outXcreatedX__outXknowsX__identityX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(hasLabel('person').and().out('created'), out('knows'), identity()).name") - } - - @Override - public Traversal get_g_V_chooseXlabelX_optionXblah__outXknowsXX_optionXbleep__outXcreatedXX_optionXnone__identityX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.choose(label()) - .option("blah", out("knows")) - .option("bleep", out("created")) - .option(none, identity()).name - """) - } - - @Override - public Traversal get_g_V_chooseXoutXknowsX_count_isXgtX0XX__outXknowsXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(out('knows').count.is(gt(0)), out('knows')).name") - } - - @Override - public Traversal> get_g_V_hasLabelXpersonX_asXp1X_chooseXoutEXknowsX__outXknowsXX_asXp2X_selectXp1_p2X_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').as('p1').choose(outE('knows'), out('knows')).as('p2').select('p1', 'p2').by('name')"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyLocalTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyLocalTest.groovy deleted file mode 100644 index 0e2ef3e0cbe..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyLocalTest.groovy +++ /dev/null @@ -1,91 +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.process.traversal.step.branch - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyLocalTest { - - public static class Traversals extends LocalTest { - - @Override - public Traversal get_g_V_localXpropertiesXlocationX_order_byXvalueX_limitX2XX_value() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.local(__.properties('location').order.by(value,incr).limit(2)).value"); - } - - @Override - public Traversal> get_g_V_hasXlabel_personX_asXaX_localXoutXcreatedX_asXbXX_selectXa_bX_byXnameX_byXidX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has(T.label, 'person').as('a').local(__.out('created').as('b')).select('a', 'b').by('name').by(T.id)"); - } - - @Override - public Traversal get_g_V_localXoutE_countX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.local(__.outE.count())"); - } - - @Override - public Traversal get_g_VX1X_localXoutEXknowsX_limitX1XX_inV_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).local(__.outE('knows').limit(1)).inV.name", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_localXbothEXcreatedX_limitX1XX_otherV_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().local(__.bothE('created').limit(1)).otherV.name"); - } - - @Override - public Traversal get_g_VX4X_localXbothEX1_createdX_limitX1XX(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).local(__.bothE('created').limit(1))", "v4Id", v4Id); - } - - @Override - public Traversal get_g_VX4X_localXbothEXknows_createdX_limitX1XX(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).local(__.bothE('knows', 'created').limit(1))", "v4Id", v4Id); - } - - @Override - public Traversal get_g_VX4X_localXbothE_limitX1XX_otherV_name(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).local(__.bothE.limit(1)).otherV.name", "v4Id", v4Id); - } - - @Override - public Traversal get_g_VX4X_localXbothE_limitX2XX_otherV_name(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).local(__.bothE.limit(2)).otherV.name", "v4Id", v4Id); - } - - @Override - public Traversal get_g_V_localXinEXknowsX_limitX2XX_outV_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().local(__.inE('knows').limit(2).outV).name"); - } - - @Override - public Traversal> get_g_V_localXmatchXproject__created_person__person_name_nameX_selectXname_projectX_by_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", """g.V.local(match( - __.as('project').in('created').as('person'), - __.as('person').values('name').as('name'))). - select('name', 'project').by.by('name')""") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyOptionalTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyOptionalTest.groovy deleted file mode 100644 index f463a5ef0e9..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyOptionalTest.groovy +++ /dev/null @@ -1,59 +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.process.traversal.step.branch - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Pieter Martin - */ -public abstract class GroovyOptionalTest { - - public static class Traversals extends OptionalTest { - - @Override - public Traversal get_g_VX2X_optionalXoutXknowsXX(Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v2Id).optional(out('knows'))", "v2Id", v2Id) - } - - @Override - public Traversal get_g_VX2X_optionalXinXknowsXX(Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v2Id).optional(__.in('knows'))", "v2Id", v2Id) - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_optionalXoutXknowsX_optionalXoutXcreatedXXX_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('person').optional(out('knows').optional(out('created'))).path()") - } - - @Override - public Traversal get_g_V_optionalXout_optionalXoutXX_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.optional(out().optional(out())).path") - } - - @Override - public Traversal get_g_VX1X_optionalXaddVXdogXX_label(Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).optional(addV('dog')).label", "v1Id", v1Id) - } - } - -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy deleted file mode 100644 index c132e6c8391..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy +++ /dev/null @@ -1,88 +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.process.traversal.step.branch - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyRepeatTest { - - public static class Traversals extends RepeatTest { - - @Override - public Traversal get_g_V_repeatXoutX_timesX2X_emit_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out).times(2).emit.path") - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX2X_repeatXinX_timesX2X_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out).times(2).repeat(__.in).times(2).name") - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out).times(2)") - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX2X_emit() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out).times(2).emit") - } - - @Override - public Traversal get_g_VX1X_timesX2X_repeatXoutX_name(Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).times(2).repeat(__.out).name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_emit_repeatXoutX_timesX2X_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.emit.repeat(__.out).times(2).path") - } - - @Override - public Traversal get_g_V_emit_timesX2X_repeatXoutX_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.emit.times(2).repeat(__.out).path") - } - - @Override - public Traversal get_g_VX1X_emitXhasXlabel_personXX_repeatXoutX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).emit(has(T.label, 'person')).repeat(__.out).name", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_V_repeatXgroupCountXmX_byXnameX_outX_timesX2X_capXmX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(groupCount('m').by('name').out).times(2).cap('m')") - } - - @Override - public Traversal> get_g_V_repeatXbothX_timesX10X_asXaX_out_asXbX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(both()).times(10).as('a').out().as('b').select('a', 'b')"); - } - - @Override - public Traversal get_g_VX1X_repeatXoutX_untilXoutE_count_isX0XX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).repeat(out()).until(__.outE.count.is(0)).name", "v1Id", v1Id) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy deleted file mode 100644 index 5627cdce7dc..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyUnionTest.groovy +++ /dev/null @@ -1,77 +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.process.traversal.step.branch - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyUnionTest { - - public static class Traversals extends UnionTest { - - @Override - public Traversal get_g_V_unionXout__inX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.union(__.out, __.in).name") - } - - @Override - public Traversal get_g_VX1X_unionXrepeatXoutX_timesX2X__outX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).union(repeat(__.out).times(2), __.out).name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_chooseXlabel_is_person__unionX__out_lang__out_nameX__in_labelX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(__.label.is('person'), union(__.out.lang, __.out.name), __.in.label)") - } - - @Override - public Traversal> get_g_V_chooseXlabel_is_person__unionX__out_lang__out_nameX__in_labelX_groupCount() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(__.label.is('person'), union(__.out.lang, __.out.name), __.in.label).groupCount") - } - - @Override - public Traversal> get_g_V_unionXrepeatXunionXoutXcreatedX__inXcreatedXX_timesX2X__repeatXunionXinXcreatedX__outXcreatedXX_timesX2XX_label_groupCount() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.union( - repeat(union( - out('created'), - __.in('created'))).times(2), - repeat(union( - __.in('created'), - out('created'))).times(2)).label.groupCount() - """) - } - - @Override - public Traversal get_g_VX1_2X_unionXoutE_count__inE_count__outE_weight_sumX( - final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id, v2Id).union(outE().count, inE().count, outE().weight.sum)", "v1Id", v1Id, "v2Id", v2Id); - } - - @Override - public Traversal get_g_VX1_2X_localXunionXoutE_count__inE_count__outE_weight_sumXX( - final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id, v2Id).local(union(outE().count, inE().count, outE().weight.sum))", "v1Id", v1Id, "v2Id", v2Id); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyAndTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyAndTest.groovy deleted file mode 100644 index fb9d356c049..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyAndTest.groovy +++ /dev/null @@ -1,52 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyAndTest { - - public static class Traversals extends AndTest { - - @Override - public Traversal get_g_V_andXhasXage_gt_27X__outE_count_gte_2X_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.and(has('age',gt(27)), outE().count.is(gte(2l))).name") - } - - @Override - public Traversal get_g_V_andXoutE__hasXlabel_personX_and_hasXage_gte_32XX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.and(outE(), has(label, 'person') & has('age',gte(32))).name") - } - - @Override - public Traversal get_g_V_asXaX_outXknowsX_and_outXcreatedX_inXcreatedX_asXaX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('knows') & out('created').in('created').as('a').name") - } - - @Override - public Traversal get_g_V_asXaX_andXselectXaX_selectXaXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').and(__.select('a'), __.select('a'))"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCoinTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCoinTest.groovy deleted file mode 100644 index 0bdd3f655e1..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCoinTest.groovy +++ /dev/null @@ -1,41 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyCoinTest { - - public static class Traversals extends CoinTest { - @Override - public Traversal get_g_V_coinX1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.coin(1.0f)"); - } - - @Override - public Traversal get_g_V_coinX0X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.coin(0.0f)"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCyclicPathTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCyclicPathTest.groovy deleted file mode 100644 index 7479e21f7b7..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyCyclicPathTest.groovy +++ /dev/null @@ -1,43 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyCyclicPathTest { - - public static class Traversals extends CyclicPathTest { - - @Override - Traversal get_g_VX1X_outXcreatedX_inXcreatedX_cyclicPath(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').in('created').cyclicPath", "v1Id", v1Id); - } - - @Override - Traversal get_g_VX1X_outXcreatedX_inXcreatedX_cyclicPath_path(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').in('created').cyclicPath().path()", "v1Id", v1Id); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDedupTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDedupTest.groovy deleted file mode 100644 index a041fdb8803..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDedupTest.groovy +++ /dev/null @@ -1,113 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovyDedupTest { - - public static class Traversals extends DedupTest { - @Override - public Traversal get_g_V_out_in_valuesXnameX_fold_dedupXlocalX_unfold() { - return new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.in.values('name').fold.dedup(Scope.local).unfold"); - } - - @Override - public Traversal> get_g_V_out_asXxX_in_asXyX_selectXx_yX_byXnameX_fold_dedupXlocal_x_yX_unfold() { - return new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.as('x').in.as('y').select('x','y').by('name').fold.dedup(Scope.local,'x','y').unfold"); - } - - @Override - public Traversal get_g_V_both_dedup_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.dedup.name"); - } - - @Override - public Traversal>> get_g_V_group_byXlabelX_byXbothE_weight_dedup_foldX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group.by(label).by(__.bothE.weight.dedup.fold)"); - } - - @Override - public Traversal get_g_V_both_hasXlabel_softwareX_dedup_byXlangX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.has(label, 'software').dedup.by('lang').name"); - } - - @Override - public Traversal get_g_V_both_name_order_byXa_bX_dedup_value() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().both().properties('name').order.by { a, b -> a.value() <=> b.value() }.dedup.value"); - } - - @Override - public Traversal get_g_V_both_both_dedup() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.both.dedup") - } - - @Override - public Traversal get_g_V_both_both_dedup_byXlabelX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.both.dedup.by(label)") - } - - @Override - public Traversal get_g_V_both_both_name_dedup() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.both.name.dedup") - } - - @Override - public Traversal> get_g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').both.as('b').dedup('a', 'b').by(label).select('a','b')") - } - - @Override - public Traversal get_g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').as('b').in('created').as('c').dedup('a','b').path") - } - - @Override - Traversal get_g_V_outE_asXeX_inV_asXvX_selectXeX_order_byXweight_incrX_selectXvX_valuesXnameX_dedup() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.as('e').inV.as('v').select('e').order.by('weight', incr).select('v').values('name').dedup") - } - - @Override - public Traversal get_g_V_both_both_dedup_byXoutE_countX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.both.dedup.by(outE().count).name") - } - - @Override - public Traversal get_g_V_groupCount_selectXvaluesX_unfold_dedup() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.groupCount.select(values).unfold.dedup") - } - - @Override - public Traversal> get_g_V_asXaX_repeatXbothX_timesX3X_emit_name_asXbX_group_byXselectXaXX_byXselectXbX_dedup_order_foldX_selectXvaluesX_unfold_dedup() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').repeat(both()).times(3).emit.name.as('b').group.by(select('a')).by(select('b').dedup.order.fold).select(values).unfold.dedup") - } - - @Override - public Traversal get_g_V_repeatXdedupX_timesX2X_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(dedup()).times(2).count") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDropTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDropTest.groovy deleted file mode 100644 index 74bf3e43d4b..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyDropTest.groovy +++ /dev/null @@ -1,51 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalScriptHelper -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex -import org.apache.tinkerpop.gremlin.structure.VertexProperty - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyDropTest { - - public static class Traversals extends DropTest { - - @Override - public Traversal get_g_V_drop() { - new ScriptTraversal<>(g, "gremlin-groovy","g.V.drop") - } - - @Override - public Traversal get_g_V_outE_drop() { - new ScriptTraversal<>(g, "gremlin-groovy","g.V.outE.drop") - } - - @Override - public Traversal get_g_V_properties_drop() { - new ScriptTraversal<>(g, "gremlin-groovy","g.V.properties().drop") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyFilterTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyFilterTest.groovy deleted file mode 100644 index ec12486843a..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyFilterTest.groovy +++ /dev/null @@ -1,73 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyFilterTest { - - public static class Traversals extends FilterTest { - - @Override - public Traversal get_g_V_filterXfalseX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.filter { false }"); - } - - @Override - public Traversal get_g_V_filterXtrueX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.filter { true }"); - } - - @Override - public Traversal get_g_V_filterXlang_eq_javaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.filter { it.property('lang').orElse('none') == 'java' }"); - } - - @Override - public Traversal get_g_VX1X_filterXage_gt_30X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).filter { it.age > 30 }", "v1Id", v1Id); - } - - @Override - public Traversal get_g_VX1X_out_filterXage_gt_30X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.filter { it.property('age').orElse(0) > 30 }", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_filterXname_startsWith_m_OR_name_startsWith_pX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.filter { it.name.startsWith('m') || it.name.startsWith('p') }"); - } - - @Override - public Traversal get_g_E_filterXfalseX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E.filter { false }"); - } - - @Override - public Traversal get_g_E_filterXtrueX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E.filter { true }"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy deleted file mode 100644 index b5ca538ebc1..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy +++ /dev/null @@ -1,173 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyHasTest { - - public static class Traversals extends HasTest { - @Override - public Traversal get_g_EX11X_outV_outE_hasXid_10X(final Object e11Id, final Object e8Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E(e11Id).outV.outE.has(T.id, e8Id)", "e11Id", e11Id, "e8Id", e8Id); - } - - @Override - public Traversal get_g_V_outXcreatedX_hasXname__mapXlengthX_isXgtX3XXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').has('name',map{it.length()}.is(gt(3))).name"); - } - - @Override - public Traversal get_g_VX1X_hasXkeyX(final Object v1Id, final String key) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).has(k)", "v1Id", v1Id, "k", key); - } - - @Override - public Traversal get_g_VX1X_hasXname_markoX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).has('name', 'marko')", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_hasXname_markoX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name', 'marko')"); - } - - @Override - public Traversal get_g_V_hasXname_blahX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name', 'blah')"); - } - - @Override - public Traversal get_g_V_hasXblahX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('blah')"); - } - - @Override - public Traversal get_g_VX1X_hasXage_gt_30X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).has('age',gt(30))", "v1Id", v1Id); - } - - @Override - public Traversal get_g_VXv1X_hasXage_gt_30X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(g.V(v1Id).next()).has('age',gt(30))", "v1Id", v1Id); - } - - @Override - public Traversal get_g_VX1X_out_hasIdX2X(final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.hasId(v2Id)", "v1Id", v1Id, "v2Id", v2Id); - } - - @Override - public Traversal get_g_VX1X_out_hasIdX2_3X( - final Object v1Id, final Object v2Id, final Object v3Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.hasId(v2Id, v3Id)", "v1Id", v1Id, "v2Id", v2Id, "v3Id", v3Id); - } - - @Override - public Traversal get_g_VX1X_out_hasXid_lt_3X(final Object v1Id, final Object v3Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out().has(T.id, P.lt(v3Id))", "v1Id", v1Id, "v3Id", v3Id); - } - - @Override - public Traversal get_g_V_hasXage_gt_30X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age',gt(30))"); - } - - @Override - public Traversal get_g_V_hasXage_isXgt_30XX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age', __.is(gt(30)))"); - } - - @Override - public Traversal get_g_EX7X_hasLabelXknowsX(final Object e7Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E(e7Id).hasLabel('knows')", "e7Id", e7Id); - } - - @Override - public Traversal get_g_E_hasLabelXknowsX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E.hasLabel('knows')"); - } - - @Override - public Traversal get_g_E_hasLabelXuses_traversesX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E.hasLabel('uses', 'traverses')"); - } - - @Override - Traversal get_g_V_hasLabelXperson_software_blahX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person', 'software', 'blah')"); - } - - @Override - public Traversal get_g_V_hasXperson_name_markoX_age() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('person', 'name', 'marko').age"); - } - - @Override - public Traversal get_g_VX1X_outE_hasXweight_inside_0_06X_inV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE.has('weight', inside(0.0d, 0.6d)).inV", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_hasXlocationX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('location')") - } - - @Override - public Traversal get_g_VX1X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id)", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_hasIdX1X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasId(v1Id)", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1_2X(final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id, v2Id)", "v1Id", v1Id, "v2Id", v2Id) - } - - @Override - public Traversal get_g_V_hasIdX1_2X(final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasId(v1Id, v2Id)", "v1Id", v1Id, "v2Id", v2Id) - } - - @Override - public Traversal get_g_V_hasIdXwithinX1_2XX(final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasId(within(v1Id, v2Id))", "v1Id", v1Id, "v2Id", v2Id) - } - - @Override - public Traversal get_g_V_in_hasIdXneqX1XX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.in.hasId(neq(v1Id))", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').has('age', P.not(lte(10).and(P.not(between(11,20)))).and(lt(29).or(eq(35)))).name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyIsTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyIsTest.groovy deleted file mode 100644 index 6b7012500ce..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyIsTest.groovy +++ /dev/null @@ -1,57 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovyIsTest { - - public static class Traversals extends IsTest { - - @Override - public Traversal get_g_V_valuesXageX_isX32X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.is(32)") - } - - @Override - public Traversal get_g_V_valuesXageX_isXlte_30X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.is(lte(30))") - } - - @Override - public Traversal get_g_V_valuesXageX_isXgte_29X_isXlt_34X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.is(gte(29)).is(lt(34))") - } - - @Override - public Traversal get_g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.where(__.in('created').count.is(1)).name") - } - - @Override - public Traversal get_g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.where(__.in('created').count.is(gte(2l))).name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyOrTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyOrTest.groovy deleted file mode 100644 index 26b46bf1b80..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyOrTest.groovy +++ /dev/null @@ -1,47 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyOrTest { - - public static class Traversals extends OrTest { - - @Override - public Traversal get_g_V_orXhasXage_gt_27X__outE_count_gte_2X_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.or(has('age',gt(27)), outE().count.is(gte(2l))).name") - } - - @Override - public Traversal get_g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.or(outE('knows'), has(T.label, 'software') | has('age',gte(35))).name") - } - - @Override - public Traversal get_g_V_asXaX_orXselectXaX_selectXaXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').or(__.select('a'), __.select('a'))"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyRangeTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyRangeTest.groovy deleted file mode 100644 index 14d7282ac63..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyRangeTest.groovy +++ /dev/null @@ -1,127 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyRangeTest { - - public static class Traversals extends RangeTest { - - @Override - public Traversal get_g_VX1X_out_limitX2X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.limit(2)", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_localXoutE_limitX1X_inVX_limitX3X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.local(__.outE.limit(3)).inV.limit(3)") - } - - @Override - public Traversal get_g_VX1X_outXknowsX_outEXcreatedX_rangeX0_1X_inV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('knows').outE('created')[0].inV()", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outXknowsX_outXcreatedX_rangeX0_1X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('knows').out('created')[0]", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outXcreatedX_inXcreatedX_rangeX1_3X(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').in('created')[1..3]", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outXcreatedX_inEXcreatedX_rangeX1_3X_outV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').inE('created')[1..3].outV", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_repeatXbothX_timesX3X_rangeX5_11X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().repeat(__.both).times(3)[5..11]") - } - - @Override - public Traversal> get_g_V_asXaX_in_asXaX_in_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_limitXlocal_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').in().as('a').in().as('a').select(mixed,'a').by(unfold().values('name').fold).limit(local,2)") - } - - @Override - public Traversal get_g_V_asXaX_in_asXaX_in_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_limitXlocal_1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').in().as('a').in().as('a').select(mixed,'a').by(unfold().values('name').fold).limit(local,1)") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_3X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').out().as('a').out().as('a').select(mixed,'a').by(unfold().values('name').fold).range(local,1,3)") - } - - @Override - public Traversal get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').out().as('a').out().as('a').select(mixed,'a').by(unfold().values('name').fold).range(local,1,2)") - } - - @Override - public Traversal get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_rangeXlocal_4_5X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').out().as('a').out().as('a').select(mixed,'a').by(unfold().values('name').fold).range(local,4,5)") - } - - @Override - public Traversal> get_g_V_asXaX_in_asXbX_in_asXcX_selectXa_b_cX_byXnameX_limitXlocal_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').in.as('b').in.as('c').select('a','b','c').by('name').limit(local,2)") - } - - @Override - public Traversal> get_g_V_asXaX_in_asXbX_in_asXcX_selectXa_b_cX_byXnameX_limitXlocal_1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').in.as('b').in.as('c').select('a','b','c').by('name').limit(local,1)") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_rangeXlocal_1_3X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').out.as('c').select('a','b','c').by('name').range(local,1,3)") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_rangeXlocal_1_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').out.as('c').select('a','b','c').by('name').range(local,1,2)") - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_order_byXageX_valuesXnameX_skipX1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').order.by('age').values('name').skip(1)") - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_order_byXageX_skipX1X_valuesXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').order.by('age').skip(1).values('name')") - } - - @Override - public Traversal> get_g_V_outE_valuesXweightX_fold_orderXlocalX_skipXlocal_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.values('weight').fold.order(local).skip(local, 2)") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySampleTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySampleTest.groovy deleted file mode 100644 index 73f88d7a6e0..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySampleTest.groovy +++ /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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovySampleTest { - - public static class Traversals extends SampleTest { - - @Override - public Traversal get_g_E_sampleX1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E.sample(1)") - } - - @Override - public Traversal get_g_E_sampleX2X_byXweightX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E.sample(2).by('weight')") - } - - @Override - public Traversal get_g_V_localXoutE_sampleX1X_byXweightXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.local(__.outE.sample(1).by('weight'))") - } - - @Override - Traversal>> get_g_V_group_byXlabelX_byXbothE_weight_sampleX2X_foldX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().group().by(T.label).by(bothE().weight.sample(2).fold)") - } - - @Override - Traversal>> get_g_V_group_byXlabelX_byXbothE_weight_fold_sampleXlocal_5XX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().group().by(label).by(bothE().weight.fold().sample(local, 5))") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySimplePathTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySimplePathTest.groovy deleted file mode 100644 index e1206dfcc94..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovySimplePathTest.groovy +++ /dev/null @@ -1,43 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovySimplePathTest { - - public static class Traversals extends SimplePathTest { - - @Override - public Traversal get_g_VX1X_outXcreatedX_inXcreatedX_simplePath(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').in('created').simplePath", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_repeatXboth_simplePathX_timesX3X_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.both.simplePath).times(3).path()"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy deleted file mode 100644 index 38c2a1d46c4..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy +++ /dev/null @@ -1,92 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Matt Frantz (http://github.com/mhfrantz) - */ -public abstract class GroovyTailTest { - - public static class Traversals extends TailTest { - - @Override - public Traversal get_g_V_valuesXnameX_order_tailXglobal_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.values('name').order.tail(global, 2)") - } - - @Override - public Traversal get_g_V_valuesXnameX_order_tailX2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.values('name').order.tail(2)") - } - - @Override - public Traversal get_g_V_valuesXnameX_order_tail() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.values('name').order.tail") - } - - @Override - public Traversal get_g_V_valuesXnameX_order_tailX7X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.values('name').order.tail(7)") - } - - @Override - public Traversal get_g_V_repeatXbothX_timesX3X_tailX7X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(both()).times(3).tail(7)") - } - - @Override - public Traversal get_g_V_repeatXin_outX_timesX3X_tailX7X_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.in().out()).times(3).tail(7).count()") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('a').out.as('a').select(mixed,'a').by(unfold().values('name').fold).tail(local, 2)") - } - - @Override - public Traversal get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('a').out.as('a').select(mixed,'a').by(unfold().values('name').fold).tail(local, 1)") - } - - @Override - public Traversal get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocalX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('a').out.as('a').select(mixed,'a').by(unfold().values('name').fold).tail(local)") - } - - @Override - public Traversal get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXlimitXlocal_0XX_tailXlocal_1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('a').out.as('a').select(mixed,'a').by(limit(local, 0)).tail(local, 1)") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_tailXlocal_2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').out.as('c').select('a','b','c').by('name').tail(local, 2)") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_tailXlocal_1X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').out.as('c').select('a','b','c').by('name').tail(local, 1)") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy deleted file mode 100644 index 5a40b698873..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy +++ /dev/null @@ -1,167 +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.process.traversal.step.filter - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyWhereTest { - - public static class Traversals extends WhereTest { - - /// where(local) - - @Override - public Traversal> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_selectXa_bX_whereXa_eqXbXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').as('a').out.in.has('age').as('b').select('a','b').where('a', eq('b'))") - } - - @Override - public Traversal> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_selectXa_bX_whereXa_neqXbXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').as('a').out.in.has('age').as('b').select('a','b').where('a', neq('b'))") - } - - @Override - public Traversal> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_selectXa_bX_whereXb_hasXname_markoXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').as('a').out.in.has('age').as('b').select('a','b').where(__.as('b').has('name', 'marko'))") - } - - @Override - public Traversal> get_g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_selectXa_bX_whereXa_outXknowsX_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().has('age').as('a').out.in.has('age').as('b').select('a','b').where(__.as('a').out('knows').as('b'))") - } - - @Override - public Traversal get_g_V_asXaX_outXcreatedX_whereXasXaX_name_isXjoshXX_inXcreatedX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').where(__.as('a').name.is('josh')).in('created').name") - } - - /// where(global) - - @Override - public Traversal get_g_withSideEffectXa_josh_peterX_VX1X_outXcreatedX_inXcreatedX_name_whereXwithinXaXX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a', ['josh','peter']).V(v1Id).out('created').in('created').name.where(within('a'))", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXa_neqXbXX_name( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').in('created').as('b').where('a', neq('b')).name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXasXbX_outXcreatedX_hasXname_rippleXX_valuesXage_nameX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').in('created').as('b').where(__.as('b').out('created').has('name','ripple')).values('age','name')", "v1Id", v1Id) - } - - // except/retain functionality - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_inXcreatedX_whereXeqXaXX_name( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').in('created').where(eq('a')).name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_inXcreatedX_whereXneqXaXX_name( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').in('created').where(neq('a')).name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.aggregate('x').out.where(P.not(within('x')))", "v1Id", v1Id) - } - - @Override - public Traversal get_g_withSideEffectXa_graph_verticesX2XX_VX1X_out_whereXneqXaXX( - final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a'){g.V(v2Id).next()}.V(v1Id).out.where(neq('a'))", "graph", graph, "v1Id", v1Id, "v2Id", v2Id) - } - - @Override - public Traversal get_g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).repeat(__.bothE('created').where(without('e')).aggregate('e').otherV).emit.path", "v1Id", v1Id) - } - - // hasNot functionality - - @Override - public Traversal get_g_V_whereXnotXoutXcreatedXXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.where(__.not(out('created'))).name"); - } - - // complex and/or functionality - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').where(and(__.as('a').out('knows').as('b'),or(__.as('b').out('created').has('name','ripple'),__.as('b').in('knows').count.is(P.not(eq(0)))))).select('a','b')") - } - - @Override - public Traversal get_g_V_whereXoutXcreatedX_and_outXknowsX_or_inXknowsXX_valuesXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.where(out('created').and.out('knows').or.in('knows')).name") - } - - @Override - public Traversal> get_g_V_asXaX_outXcreatedX_asXbX_whereXandXasXbX_in__notXasXaX_outXcreatedX_hasXname_rippleXXX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').as('b').where(and(__.as('b').in,__.not(__.as('a').out('created').has('name','ripple')))).select('a','b')") - } - - - @Override - public Traversal> get_g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').as('b').in('created').as('c').both('knows').both('knows').as('d').where('c',P.not(eq('a').or(eq('d')))).select('a','b','c','d')") - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_whereXin_count_isXeqX3XX_or_whereXoutXcreatedX_and_hasXlabel_personXXX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').where(__.as('b').in.count.is(eq(3)).or.where(__.as('b').out('created').and.as('b').has(label,'person'))).select('a','b')") - } - - @Override - public Traversal> get_g_V_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXa_gtXbXX_byXageX_selectXa_bX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').in('created').as('b').where('a', gt('b')).by('age').select('a', 'b').by('name')") - } - - @Override - public Traversal> get_g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_whereXa_gtXbX_orXeqXbXXX_byXageX_byXweightX_byXweightX_selectXa_cX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').outE('created').as('b').inV().as('c').where('a', gt('b').or(eq('b'))).by('age').by('weight').by('weight').select('a', 'c').by('name')") - } - - @Override - public Traversal> get_g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').outE('created').as('b').inV().as('c').in('created').as('d').where('a', lt('b').or(gt('c')).and(neq('d'))).by('age').by('weight').by(__.in('created').values('age').min()).select('a', 'c', 'd').by('name')") - } - - @Override - public Traversal get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXageX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out.has('age').where(gt('a')).by('age').name", "v1Id", v1Id) - } - - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddEdgeTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddEdgeTest.groovy deleted file mode 100644 index b3d5f49fe93..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddEdgeTest.groovy +++ /dev/null @@ -1,85 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyAddEdgeTest { - - public static class Traversals extends AddEdgeTest { - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_addEXcreatedByX_toXaX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').addE('createdBy').to('a')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_addEXcreatedByX_toXaX_propertyXweight_2X( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').addE('createdBy').to('a').property('weight', 2.0d)", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_aggregateXxX_asXaX_selectXxX_unfold_addEXexistsWithX_toXaX_propertyXtime_nowX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.aggregate('x').as('a').select('x').unfold.addE('existsWith').to('a').property('time', 'now')"); - } - - @Override - public Traversal get_g_V_asXaX_outXcreatedX_inXcreatedX_whereXneqXaXX_asXbX_addEXcodeveloperX_fromXaX_toXbX_propertyXyear_2009X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').in('created').where(neq('a')).as('b').addE('codeveloper').from('a').to('b').property('year', 2009)"); - } - - @Override - public Traversal get_g_V_asXaX_inXcreatedX_addEXcreatedByX_fromXaX_propertyXyear_2009X_propertyXacl_publicX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').in('created').addE('createdBy').from('a').property('year', 2009).property('acl', 'public')"); - } - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_addOutEXcreatedBy_aX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').addOutE('createdBy', 'a')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXcreatedX_addOutEXcreatedBy_a_weight_2X( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('created').addOutE('createdBy', 'a', 'weight', 2.0d)", "v1Id", v1Id) - } - - @Override - public Traversal get_g_withSideEffectXx__g_V_toListX_addOutEXexistsWith_x_time_nowX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('x',g.V.toList()).V.addOutE('existsWith', 'x', 'time', 'now')"); - } - - @Override - public Traversal get_g_V_asXaX_outXcreatedX_inXcreatedX_whereXneqXaXX_asXbX_selectXa_bX_addInEXa_codeveloper_b_year_2009X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').in('created').where(neq('a')).as('b').select('a','b').addInE('a', 'codeveloper', 'b', 'year', 2009)"); - } - - @Override - public Traversal get_g_V_asXaX_inXcreatedX_addInEXcreatedBy_a_year_2009_acl_publicX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').in('created').addInE('createdBy', 'a', 'year', 2009, 'acl', 'public')"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddVertexTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddVertexTest.groovy deleted file mode 100644 index 00312faf4e9..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyAddVertexTest.groovy +++ /dev/null @@ -1,101 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyAddVertexTest { - - public static class Traversals extends AddVertexTest { - - @Override - public Traversal get_g_VX1X_addVXanimalX_propertyXage_selectXaX_byXageXX_propertyXname_puppyX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').addV('animal').property('age', select('a').by('age')).property('name', 'puppy')", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_addVXanimalX_propertyXage_0X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().addV('animal').property('age', 0)") - } - - @Override - public Traversal get_g_addVXpersonX_propertyXname_stephenX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.addV(label, 'person', 'name', 'stephen')") - } - - @Override - public Traversal get_g_addVXpersonX_propertyXname_stephenX_propertyXname_stephenmX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.addV('person').property('name', 'stephen').property('name', 'stephenm')") - } - - @Override - public Traversal get_g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenmX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.addV('person').property(VertexProperty.Cardinality.single, 'name', 'stephen').property(VertexProperty.Cardinality.single, 'name', 'stephenm')") - } - - @Override - public Traversal get_g_addVXpersonX_propertyXsingle_name_stephenX_propertyXsingle_name_stephenm_since_2010X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.addV('person').property(VertexProperty.Cardinality.single, 'name', 'stephen').property(VertexProperty.Cardinality.single, 'name', 'stephenm', 'since', 2010)") - } - - @Override - public Traversal get_g_V_hasXname_markoX_propertyXfriendWeight_outEXknowsX_weight_sum__acl_privateX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name', 'marko').property('friendWeight', outE('knows').weight.sum(), 'acl', 'private')") - } - - @Override - public Traversal get_g_addVXanimalX_propertyXname_mateoX_propertyXname_gateoX_propertyXname_cateoX_propertyXage_5X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.addV('animal').property('name', 'mateo').property('name', 'gateo').property('name', 'cateo').property('age', 5)") - } - - @Override - public Traversal get_g_V_addVXanimalX_propertyXname_valuesXnameXX_propertyXname_an_animalX_propertyXvaluesXnameX_labelX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.addV('animal').property('name', values('name')).property('name', 'an animal').property(values('name'), label())") - } - - @Override - public Traversal>> get_g_withSideEffectXa_testX_V_hasLabelXsoftwareX_propertyXtemp_selectXaXX_valueMapXname_tempX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a', 'test').V.hasLabel('software').property('temp', select('a')).valueMap('name', 'temp')") - } - - @Override - public Traversal get_g_withSideEffectXa_markoX_addV_propertyXname_selectXaXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a', 'marko').addV().property('name', select('a')).name") - } - - ///////// DEPRECATED BELOW - - @Override - public Traversal get_g_V_addVXlabel_animal_age_0X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.addV(label, 'animal', 'age', 0)") - } - - @Override - public Traversal get_g_addVXlabel_person_name_stephenX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.addV(label, 'person', 'name', 'stephen')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCoalesceTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCoalesceTest.groovy deleted file mode 100644 index e6765f50121..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCoalesceTest.groovy +++ /dev/null @@ -1,59 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovyCoalesceTest { - - public static class Traversals extends CoalesceTest { - - @Override - public Traversal get_g_V_coalesceXoutXfooX_outXbarXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().coalesce(out('foo'), out('bar'))") - } - - @Override - public Traversal get_g_VX1X_coalesceXoutXknowsX_outXcreatedXX_valuesXnameX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).coalesce(out('knows'), out('created')).values('name')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_coalesceXoutXcreatedX_outXknowsXX_valuesXnameX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).coalesce(out('created'), out('knows')).values('name')", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_V_coalesceXoutXlikesX_outXknowsX_inXcreatedXX_groupCount_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().coalesce(out('likes'), out('knows'), out('created')).groupCount().by('name')") - } - - @Override - Traversal get_g_V_coalesceXoutEXknowsX_outEXcreatedXX_otherV_path_byXnameX_byXlabelX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.coalesce(outE('knows'), outE('created')).otherV.path.by('name').by(T.label)") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyConstantTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyConstantTest.groovy deleted file mode 100644 index 1fa03c0a413..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyConstantTest.groovy +++ /dev/null @@ -1,42 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Matt Frantz (http://github.com/mhfrantz) - */ -public abstract class GroovyConstantTest { - - public static class Traversals extends ConstantTest { - @Override - public Traversal get_g_V_constantX123X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.constant(123)") - } - - @Override - public Traversal get_g_V_chooseXhasLabelXpersonX_valuesXnameX_constantXinhumanXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(hasLabel('person'), values('name'), constant('inhuman'))") - } - - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy deleted file mode 100644 index f6267f9e136..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyCountTest.groovy +++ /dev/null @@ -1,76 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyCountTest { - - public static class Traversals extends CountTest { - @Override - public Traversal get_g_V_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.count()") - } - - @Override - public Traversal get_g_V_out_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.count") - } - - @Override - public Traversal get_g_V_both_both_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.both.count()") - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX3X_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().repeat(__.out).times(3).count()") - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX8X_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out).times(8).count()") - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(out()).times(5).as('a').out('writtenBy').as('b').select('a', 'b').count()") - } - - @Override - public Traversal get_g_V_hasXnoX_count() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('no').count") - } - - @Override - public Traversal get_g_V_fold_countXlocalX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.fold.count(local)") - } - - @Override - public Traversal get_g_V_whereXinXknowsX_outXcreatedX_count_is_0XX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.where(__.in('knows').out('created').count.is(0)).name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFlatMapTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFlatMapTest.groovy deleted file mode 100644 index 712b9bf60f1..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFlatMapTest.groovy +++ /dev/null @@ -1,36 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Matt Frantz (http://github.com/mhfrantz) - */ -public abstract class GroovyFlatMapTest { - - public static class Traversals extends FlatMapTest { - @Override - public Traversal get_g_V_asXaX_flatMapXselectXaXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').flatMap(select('a'))") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFoldTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFoldTest.groovy deleted file mode 100644 index c8ee43d7eab..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyFoldTest.groovy +++ /dev/null @@ -1,46 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyFoldTest { - - public static class Traversals extends FoldTest { - @Override - public Traversal> get_g_V_fold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.fold") - } - - @Override - public Traversal get_g_V_fold_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.fold.unfold") - } - - @Override - public Traversal get_g_V_age_foldX0_plusX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.fold(0,sum)") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyGraphTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyGraphTest.groovy deleted file mode 100644 index cff3e651406..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyGraphTest.groovy +++ /dev/null @@ -1,55 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyGraphTest { - - public static class Traversals extends GraphTest { - - @Override - public Traversal get_g_VX1X_V_valuesXnameX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).V.name", "v1Id", v1Id); - } - - @Override - public Traversal get_g_V_outXknowsX_V_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('knows').V.name") - } - - @Override - public Traversal get_g_V_hasXname_GarciaX_inXsungByX_asXsongX_V_hasXname_Willie_DixonX_inXwrittenByX_whereXeqXsongXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name','Garcia').in('sungBy').as('song').V.has('name','Willie_Dixon').in('writtenBy').where(eq('song')).name") - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_asXpX_VXsoftwareX_addInEXuses_pX() { - def software = g.V().hasLabel("software").toList() - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('person').as('p').V(software).addE('uses').from('p')", "software", software) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyLoopsTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyLoopsTest.groovy deleted file mode 100644 index 58c9ca911ae..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyLoopsTest.groovy +++ /dev/null @@ -1,56 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovyLoopsTest { - - public static class Traversals extends LoopsTest { - - @Override - Traversal get_g_VX1X_repeatXboth_simplePathX_untilXhasXname_peterX_or_loops_isX3XX_hasXname_peterX_path_byXnameX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).repeat(__.both.simplePath).until(has('name', 'peter').or.loops.is(3)).has('name', 'peter').path.by('name')", "v1Id", v1Id) - } - - @Override - Traversal get_g_VX1X_repeatXboth_simplePathX_untilXhasXname_peterX_or_loops_isX2XX_hasXname_peterX_path_byXnameX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).repeat(__.both.simplePath).until(has('name', 'peter').or.loops.is(2)).has('name', 'peter').path.by('name')", "v1Id", v1Id) - } - - @Override - Traversal get_g_VX1X_repeatXboth_simplePathX_untilXhasXname_peterX_and_loops_isX3XX_hasXname_peterX_path_byXnameX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).repeat(__.both.simplePath).until(has('name', 'peter').and.loops.is(3)).has('name', 'peter').path.by('name')", "v1Id", v1Id) - } - - @Override - Traversal get_g_V_emitXhasXname_markoX_or_loops_isX2XX_repeatXoutX_valuesXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.emit(has('name', 'marko').or.loops.is(2)).repeat(__.out).name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapKeysTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapKeysTest.groovy deleted file mode 100644 index 14301475327..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapKeysTest.groovy +++ /dev/null @@ -1,43 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovyMapKeysTest { - - public static class Traversals extends MapKeysTest { - - @Override - public Traversal get_g_V_outE_valuesXweightX_groupCount_mapKeys() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE().weight.groupCount().mapKeys()") - } - - @Override - public Traversal get_g_V_outE_valuesXweightX_groupCount_unfold_mapKeys() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE().weight.groupCount().unfold().mapKeys()") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapTest.groovy deleted file mode 100644 index 59eb1ceb8a1..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapTest.groovy +++ /dev/null @@ -1,62 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public abstract class GroovyMapTest { - - public static class Traversals extends MapTest { - - @Override - public Traversal get_g_VX1X_mapXnameX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).map { v -> v.name }", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outE_label_mapXlengthX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE.label.map { l -> l.length() }", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_mapXnameX_mapXlengthX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.map { v -> v.name }.map { n -> n.length() }", "v1Id", v1Id) - } - - @Override - public Traversal get_g_withPath_V_asXaX_out_mapXa_nameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withPath().V.as('a').out.map { v -> v.path('a').name }") - } - - @Override - public Traversal get_g_withPath_V_asXaX_out_out_mapXa_name_it_nameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withPath().V().as('a').out.out().map { v -> v.path('a').name + v.name }") - } - - @Override - public Traversal get_g_V_mapXselectXaXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').map(select('a'))") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapValuesTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapValuesTest.groovy deleted file mode 100644 index 5adf0ee1044..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMapValuesTest.groovy +++ /dev/null @@ -1,48 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovyMapValuesTest { - - public static class Traversals extends MapValuesTest { - - @Override - public Traversal get_g_V_outE_valuesXweightX_groupCount_mapValues() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE().weight.groupCount().mapValues()") - } - - @Override - public Traversal get_g_V_outE_valuesXweightX_groupCount_unfold_mapValues() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE().weight.groupCount().unfold().mapValues()") - } - - @Override - public Traversal get_g_V_outE_valuesXweightX_groupCount_mapValues_groupCount_mapValues() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE().weight.groupCount().mapValues().groupCount().mapValues()") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy deleted file mode 100644 index 8c36d262faf..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy +++ /dev/null @@ -1,381 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex -import org.junit.Before - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyMatchTest { - - public static class GreedyMatchTraversals extends Traversals { - @Before - public void setupTest() { - super.setupTest(); - g = graphProvider.traversal(graph, MatchAlgorithmStrategy.build().algorithm(MatchStep.GreedyMatchAlgorithm.class).create()); - } - } - - public static class CountMatchTraversals extends Traversals { - @Before - public void setupTest() { - super.setupTest(); - g = graphProvider.traversal(graph, MatchAlgorithmStrategy.build().algorithm(MatchStep.CountMatchAlgorithm.class).create()); - } - } - - public abstract static class Traversals extends MatchTest { - - @Override - public Traversal> get_g_V_valueMap_matchXa_selectXnameX_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap.match(__.as('a').select('name').as('b'))") - } - - @Override - public Traversal> get_g_V_matchXa_out_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.match(__.as('a').out.as('b'))") - } - - @Override - public Traversal get_g_V_matchXa_out_bX_selectXb_idX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.match( __.as('a').out.as('b')).select('b').by(id)") - } - - @Override - public Traversal> get_g_V_matchXa_knows_b__b_created_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('knows').as('b'), - __.as('b').out('created').as('c')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_knows_b__a_created_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('knows').as('b'), - __.as('a').out('created').as('c')) - """) - } - - @Override - public Traversal> get_g_V_matchXd_0knows_a__d_hasXname_vadasX__a_knows_b__b_created_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('d').in('knows').as('a'), - __.as('d').has('name', 'vadas'), - __.as('a').out('knows').as('b'), - __.as('b').out('created').as('c')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('created').as('b'), - __.as('a').repeat(__.out).times(2).as('b')).select('a', 'b') - """) - } - - @Override - public Traversal> get_g_V_matchXa_created_lop_b__b_0created_29_c__c_whereXrepeatXoutX_timesX2XXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('created').has('name', 'lop').as('b'), - __.as('b').in('created').has('age', 29).as('c'), - __.as('c').where(repeat(__.out).times(2))) - """) - } - - @Override - public Traversal get_g_V_out_out_matchXa_0created_b__b_0knows_cX_selectXcX_outXcreatedX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.out.out.match( - __.as('a').in('created').as('b'), - __.as('b').in('knows').as('c')).select('c').out('created').name - """) - } - - @Override - public Traversal> get_g_V_matchXa_created_b__b_0created_aX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('created').as('b'), - __.as('b').in('created').as('a')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_knows_b__c_knows_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V().match( - __.as('a').out('knows').as('b'), - __.as('c').out('knows').as('b')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_knows_b__b_created_lop__b_matchXb_created_d__d_0created_cX_selectXcX_cX_selectXa_b_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as("a").out("knows").as("b"), - __.as("b").out("created").has("name", "lop"), - __.as("b").match( - __.as("b").out("created").as("d"), - __.as("d").in("created").as("c")).select("c").as("c")).select('a','b','c') - """) - } - - @Override - public Traversal> get_g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__a_0sungBy_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').has('name', 'Garcia'), - __.as('a').in('writtenBy').as('b'), - __.as('a').in('sungBy').as('b')); - """) - } - - @Override - public Traversal> get_g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').in('sungBy').as('b'), - __.as('a').in('sungBy').as('c'), - __.as('b').out('writtenBy').as('d'), - __.as('c').out('writtenBy').as('e'), - __.as('d').has('name', 'George_Harrison'), - __.as('e').has('name', 'Bob_Marley')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').in('sungBy').as('b'), - __.as('a').in('writtenBy').as('c'), - __.as('b').out('writtenBy').as('d'), - __.as('c').out('sungBy').as('d'), - __.as('d').has('name', 'Garcia')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_dX_whereXc_sungBy_dX_whereXd_hasXname_GarciaXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').in('sungBy').as('b'), - __.as('a').in('writtenBy').as('c'), - __.as('b').out('writtenBy').as('d')) - .where(__.as('c').out('sungBy').as('d')) - .where(__.as('d').has('name', 'Garcia')); - """) - } - - @Override - public Traversal> get_g_V_matchXa_created_lop_b__b_0created_29_cX_whereXc_repeatXoutX_timesX2XX_selectXa_b_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as("a").out("created").has("name", "lop").as("b"), - __.as("b").in("created").has("age", 29).as("c")) - .where(__.as("c").repeat(__.out).times(2)) - .select('a','b','c') - """) - } - - @Override - public Traversal> get_g_V_matchXa_created_b__b_0created_cX_whereXa_neq_cX_selectXa_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('created').as('b'), - __.as('b').in('created').as('c')) - .where('a', neq('c')) - .select('a', 'c') - """) - } - - @Override - public Traversal> get_g_V_matchXa_created_b__c_created_bX_selectXa_b_cX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('created').as('b'), - __.as('c').out('created').as('b')).select('a','b','c').by('name') - """) - } - - @Override - public Traversal get_g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V().out().as("c").match( - __.as("b").out("knows").as("a"), - __.as("c").out("created").as("e")).select("c") - """) - } - - @Override - public Traversal> get_g_V_matchXa_whereXa_neqXcXX__a_created_b__orXa_knows_vadas__a_0knows_and_a_hasXlabel_personXX__b_0created_c__b_0created_count_isXgtX1XXX_selectXa_b_cX_byXidX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - where('a', neq('c')), - __.as('a').out('created').as('b'), - or( - __.as('a').out('knows').has('name', 'vadas'), - __.as('a').in('knows').and.as('a').has(label, 'person') - ), - __.as('b').in('created').as('c'), - __.as('b').in('created').count.is(gt(1))) - .select('a','b','c').by(id); - """) - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_matchXa_out_count_c__b_in_count_cX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.as('a').out.as('b').match(__.as('a').out.count.as('c'), __.as('b').in.count.as('c')) - """) - } - - @Override - public Traversal> get_g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').has('name', 'Garcia'), - __.as('a').in('writtenBy').as('b'), - __.as('b').out('followedBy').as('c'), - __.as('c').out('writtenBy').as('d'), - where('d', neq('a'))) - """) - } - - @Override - public Traversal> get_g_V_matchXa_knows_b__andXa_created_c__b_created_c__andXb_created_count_d__a_knows_count_dXXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out('knows').as('b'), - and( - __.as('a').out('created').as('c'), - __.as('b').out('created').as('c'), - and( - __.as('b').out('created').count.as('d'), - __.as('a').out('knows').count.as('d') - ) - )) - """) - } - - public Traversal> get_g_V_asXaX_out_asXbX_matchXa_out_count_c__orXa_knows_b__b_in_count_c__and__c_isXgtX2XXXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.as('a').out.as('b'). - match( - __.as('a').out.count.as('c'), - or( - __.as('a').out('knows').as('b'), - __.as('b').in.count.as('c').and.as('c').is(gt(2)) - ) - ) - """) - } - - @Override - public Traversal> get_g_V_matchXa__a_out_b__notXa_created_bXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').out.as('b'), - __.not(__.as('a').out('created').as('b'))); - """) - } - - @Override - public Traversal> get_g_V_matchXwhereXandXa_created_b__b_0created_count_isXeqX3XXXX__a_both_b__whereXb_inXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - where(and( - __.as('a').out('created').as('b'), - __.as('b').in('created').count.is(eq(3)))), - __.as('a').both.as('b'), - where(__.as('b').in())); - """) - } - - @Override - public Traversal> get_g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').both.as('b'), - __.as('b').both.as('c')).dedup('a','b') - """) - } - - @Override - public Traversal> get_g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as('a').both.as('b'), - __.as('b').both.as('c')).dedup('a','b').by(label) - """) - } - - @Override - public Traversal get_g_V_hasLabelXsongsX_matchXa_name_b__a_performances_cX_selectXb_cX_count() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.hasLabel('song').match( - __.as('a').values('name').as('b'), - __.as('a').values('performances').as('c') - ).select('b', 'c').count(); - """) - } - - @Override - public Traversal get_g_V_matchXa_knows_count_bX_selectXbX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.match(__.as('a').out('knows').count.as('b')).select('b')") - } - - @Override - public Traversal get_g_V_matchXa_knows_b__b_created_c__a_created_cX_dedupXa_b_cX_selectXaX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.match(__.as('a').out('knows').as('b'), __.as('b').out('created').as('c'), __.as('a').out('created').as('c')).dedup('a', 'b', 'c').select('a').by('name')") - } - - @Override - public Traversal get_g_V_notXmatchXa_age_b__a_name_cX_whereXb_eqXcXX_selectXaXX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.not(match( - __.as('a').age.as('b'), - __.as('a').name.as('c')). - where('b', eq('c')).select('a')).name - """) - } - - @Override - public Traversal get_g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.match( - __.as("a").out("followedBy").count.is(gt(10)).as("b"), - __.as("a").in("followedBy").count().is(gt(10)).as("b")).count; - """) - } - } -} \ No newline at end of file diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMaxTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMaxTest.groovy deleted file mode 100644 index ef7376b1873..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMaxTest.groovy +++ /dev/null @@ -1,47 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyMaxTest { - - public static class Traversals extends MaxTest { - - @Override - public Traversal get_g_V_age_max() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.max") - } - - @Override - public Traversal get_g_V_repeatXbothX_timesX5X_age_max() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.both).times(5).age.max") - } - - @Override - public Traversal> get_g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_maxX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('software').group().by('name').by(bothE().weight.max)") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMeanTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMeanTest.groovy deleted file mode 100644 index 67762876607..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMeanTest.groovy +++ /dev/null @@ -1,42 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyMeanTest { - - public static class Traversals extends MeanTest { - - @Override - public Traversal get_g_V_age_mean() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.mean") - } - - @Override - public Traversal> get_g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_meanX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('software').group().by('name').by(bothE().weight.mean)") - } - } -} \ No newline at end of file diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMinTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMinTest.groovy deleted file mode 100644 index f35b7ef97c5..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMinTest.groovy +++ /dev/null @@ -1,47 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyMinTest { - - public static class Traversals extends MinTest { - - @Override - public Traversal get_g_V_age_min() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.min") - } - - @Override - public Traversal get_g_V_repeatXbothX_timesX5X_age_min() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.both).times(5).age.min") - } - - @Override - public Traversal> get_g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_minX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('software').group().by('name').by(bothE().weight.min())") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyOrderTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyOrderTest.groovy deleted file mode 100644 index de33944ae04..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyOrderTest.groovy +++ /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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyOrderTest { - - public static class Traversals extends OrderTest { - - @Override - public Traversal get_g_V_name_order() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().name.order()") - } - - @Override - public Traversal get_g_V_name_order_byXa1_b1X_byXb2_a2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.name.order.by { a, b -> a[1] <=> b[1] }.by { a, b -> b[2] <=> a[2] }") - } - - @Override - public Traversal get_g_V_order_byXname_incrX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.order.by('name', incr).name") - } - - @Override - public Traversal get_g_V_order_byXnameX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.order.by('name').name") - } - - @Override - public Traversal get_g_V_outE_order_byXweight_decrX_weight() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.order.by('weight', Order.decr).weight") - } - - @Override - public Traversal get_g_V_order_byXname_a1_b1X_byXname_b2_a2X_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.order.by('name', { a, b -> a[1].compareTo(b[1]) }).by('name', { a, b -> b[2].compareTo(a[2]) }).name") - } - - @Override - public Traversal> get_g_V_asXaX_outXcreatedX_asXbX_order_byXshuffleX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('created').as('b').order.by(shuffle).select('a','b')") - } - - @Override - public Traversal> get_g_VX1X_hasXlabel_personX_mapXmapXint_ageXX_orderXlocalX_byXvalues_decrX_byXkeys_incrX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", """g.V(v1Id).hasLabel("person").map { - final Map map = [:]; - map[1] = it.age; - map[2] = it.age * 2; - map[3] = it.age * 3; - map[4] = it.age; - return map; - }.order(local).by(values,decr).by(keys,incr)""", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_order_byXoutE_count__decrX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.order.by(__.outE.count, decr)") - } - - @Override - public Traversal>> get_g_V_group_byXlabelX_byXname_order_byXdecrX_foldX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group.by(label).by(values('name').order().by(decr).fold())") - } - - @Override - public Traversal> get_g_V_localXbothE_weight_foldX_order_byXsumXlocalX_decrX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.local(__.bothE.weight.fold).order.by(sum(local), decr)") - } - - @Override - public Traversal> get_g_V_asXvX_mapXbothE_weight_foldX_sumXlocalX_asXsX_selectXv_sX_order_byXselectXsX_decrX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('v').map(__.bothE.weight.fold).sum(local).as('s').select('v', 's').order.by(select('s'),decr)") - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_order_byXageX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').order.by('age')") - } - - @Override - public Traversal> get_g_V_hasLabelXpersonX_fold_orderXlocalX_byXageX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').fold.order(local).by('age')") - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_order_byXvalueXageX__decrX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').order.by({it.age},decr).name") - } - - @Override - public Traversal get_g_V_properties_order_byXkey_decrX_key() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.properties().order.by(key, decr).key") - } - - @Override - public Traversal get_g_V_hasXsong_name_OHBOYX_outXfollowedByX_outXfollowedByX_order_byXperformancesX_byXsongType_incrX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('song', 'name', 'OH BOY').out('followedBy').out('followedBy').order.by('performances').by('songType',decr)") - } - - @Override - public Traversal get_g_V_both_hasLabelXpersonX_order_byXage_decrX_limitX5X_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.hasLabel('person').order.by('age',decr).limit(5).name") - } - - @Override - public Traversal get_g_V_both_hasLabelXpersonX_order_byXage_decrX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.hasLabel('person').order.by('age',decr).name") - } - - @Override - public Traversal get_g_V_hasLabelXsongX_order_byXperfomances_decrX_byXnameX_rangeX110_120X_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('song').order.by('performances',decr).by('name').range(110, 120).name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPageRankTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPageRankTest.groovy deleted file mode 100644 index 13787cc413c..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPageRankTest.groovy +++ /dev/null @@ -1,78 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyPageRankTest { - - public static class Traversals extends PageRankTest { - - @Override - public Traversal get_g_V_pageRank() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.pageRank") - } - - @Override - public Traversal>> get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.pageRank.by(outE('knows')).by('friendRank').valueMap('name','friendRank')") - } - - @Override - public Traversal get_g_V_pageRank_order_byXpageRank_decrX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.pageRank.order.by(PageRankVertexProgram.PAGE_RANK, decr).name") - } - - @Override - public Traversal get_g_V_pageRank_order_byXpageRank_decrX_name_limitX2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.pageRank.order.by(PageRankVertexProgram.PAGE_RANK, decr).name.limit(2)") - } - - @Override - public Traversal>> get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').pageRank.by('pageRank').order.by('pageRank').valueMap('name', 'pageRank')") - } - - @Override - public Traversal> get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.pageRank.by('pageRank').as('a').out('knows').values('pageRank').as('b').select('a', 'b')") - } - - @Override - public Traversal>> get_g_V_hasLabelXsoftwareX_hasXname_rippleX_pageRankX1X_byXinEXcreatedXX_timesX1X_byXpriorsX_inXcreatedX_unionXboth__identityX_valueMapXname_priorsX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('software').has('name', 'ripple').pageRank(1.0).by(inE('created')).times(1).by('priors').in('created').union(identity(),both()).valueMap('name', 'priors')") - } - - @Override - public Traversal>> get_g_V_outXcreatedX_groupXmX_byXlabelX_pageRankX1X_byXpageRankX_byXinEX_timesX1X_inXcreatedX_groupXmX_byXpageRankX_capXmX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').group('m').by(label).pageRank(1.0).by('pageRank').by(inE()).times(1).in('created').group('m').by('pageRank').cap('m')") - } - - @Override - public Traversal>> get_g_V_outXcreatedX_pageRank_byXbothEX_byXprojectRankX_timesX0X_valueMapXname_projectRankX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').pageRank().by(bothE()).by('projectRank').times(0).valueMap('name','projectRank')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPathTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPathTest.groovy deleted file mode 100644 index 15c499a9e81..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPathTest.groovy +++ /dev/null @@ -1,63 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyPathTest { - - public static class Traversals extends PathTest { - - @Override - public Traversal get_g_VX1X_name_path(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).name.path", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_path_byXageX_byXnameX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.path.by('age').by('name')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_repeatXoutX_timesX2X_path_by_byXnameX_byXlangX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out).times(2).path.by.by('name').by('lang')") - } - - @Override - public Traversal get_g_V_out_out_path_byXnameX_byXageX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.out.path.by('name').by('age')") - } - - @Override - public Traversal get_g_V_asXaX_hasXname_markoX_asXbX_hasXage_29X_asXcX_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').has('name', 'marko').as('b').has('age', 29).as('c').path") - } - - @Override - public Traversal get_g_VX1X_outEXcreatedX_inV_inE_outV_path(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('created').inV.inE.outV.path()", "v1Id", v1Id) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPeerPressureTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPeerPressureTest.groovy deleted file mode 100644 index 6ec0750b89e..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPeerPressureTest.groovy +++ /dev/null @@ -1,48 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyPeerPressureTest { - - public static class Traversals extends PeerPressureTest { - - @Override - public Traversal get_g_V_peerPressure() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.peerPressure") - } - - @Override - public Traversal> get_g_V_peerPressure_byXclusterX_byXoutEXknowsXX_pageRankX1X_byXrankX_byXoutEXknowsXX_timesX2X_group_byXclusterX_byXrank_sumX_limitX100X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.peerPressure.by('cluster').by(outE('knows')).pageRank(1.0).by('rank').by(outE('knows')).times(1).group.by('cluster').by(values('rank').sum).limit(100)") - } - - @Override - public Traversal>> get_g_V_hasXname_rippleX_inXcreatedX_peerPressure_byXoutEX_byXclusterX_repeatXunionXidentity__bothX_timesX2X_dedup_valueMapXname_clusterX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name', 'ripple').in('created').peerPressure.by(outE()).by('cluster').repeat(union(identity(), both())).times(2).dedup.valueMap('name', 'cluster')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProfileTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProfileTest.groovy deleted file mode 100644 index f2dbfbf6e8f..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProfileTest.groovy +++ /dev/null @@ -1,94 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Bob Briody (http://bobbriody.com - */ -public abstract class GroovyProfileTest { - - public static class Traversals extends ProfileTest { - - @Override - public Traversal get_g_V_out_out_profile() { - g.V.out.out.profile() // locked traversal - } - - @Override - public Traversal get_g_V_repeatXbothX_timesX3X_profile() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.both()).times(3).profile()"); - } - - @Override - public Traversal get_g_V_whereXinXcreatedX_count_isX1XX_name_profile() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().where(__.in('created').count().is(1l)).values('name').profile()"); - } - - @Override - public Traversal get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().sideEffect{Thread.sleep(10)}.sideEffect{Thread.sleep(5)}.profile()") - } - - @Override - public Traversal get_g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profile() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.match(__.as('a').out('created').as('b'), __.as('b').in.count.is(eq(1))).select('a', 'b').profile()") - } - - @Override - public Traversal get_g_V_out_out_profileXmetricsX() { - g.V.out.out.profile('metrics') // locked traversal - } - - @Override - public Traversal get_g_V_repeatXbothX_timesX3X_profileXmetricsX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.both()).times(3).profile('metrics')"); - } - - @Override - public Traversal get_g_V_whereXinXcreatedX_count_isX1XX_name_profileXmetricsX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().where(__.in('created').count().is(1l)).values('name').profile('metrics')"); - } - - @Override - public Traversal get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().sideEffect{Thread.sleep(10)}.sideEffect{Thread.sleep(5)}.profile('metrics')") - } - - @Override - public Traversal> get_g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profileXmetricsX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.match(__.as('a').out('created').as('b'), __.as('b').in.count.is(eq(1))).select('a', 'b').profile('metrics')") - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_pageRank_byXrankX_byXbothEX_rank_profile() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').pageRank.by('rank').by(bothE()).rank.profile()") - } - - @Override - public Traversal get_g_V_groupXmX_profile() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group('m').profile") - } - } -} - diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProgramTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProgramTest.groovy deleted file mode 100644 index 7abe11350ec..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProgramTest.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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyProgramTest { - - public static class Traversals extends ProgramTest { - - @Override - public Traversal get_g_V_programXpageRankX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.program(PageRankVertexProgram.build().create(graph))") - } - - @Override - public Traversal>> get_g_V_hasLabelXpersonX_programXpageRank_rankX_order_byXrank_incrX_valueMapXname_rankX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').program(PageRankVertexProgram.build().property('rank').create(graph)).order.by('rank',incr).valueMap('name','rank')"); - } - - @Override - public Traversal> get_g_V_outXcreatedX_aggregateXxX_byXlangX_groupCount_programXTestProgramX_asXaX_selectXa_xX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').aggregate('x').by('lang').groupCount.program(new ${ProgramTest.TestProgram.class.getCanonicalName()}()).as('a').select('a', 'x')"); - } - } -} - - diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProjectTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProjectTest.groovy deleted file mode 100644 index c20867c8ca8..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyProjectTest.groovy +++ /dev/null @@ -1,42 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyProjectTest { - - public static class Traversals extends ProjectTest { - @Override - public Traversal> get_g_V_hasLabelXpersonX_projectXa_bX_byXoutE_countX_byXageX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').project('a','b').by(outE().count).by('age')") - } - - @Override - public Traversal get_g_V_outXcreatedX_projectXa_bX_byXnameX_byXinXcreatedX_countX_order_byXselectXbX__decrX_selectXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').project('a', 'b').by('name').by(__.in('created').count).order.by(select('b'),decr).select('a')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPropertiesTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPropertiesTest.groovy deleted file mode 100644 index c74e8231ca5..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyPropertiesTest.groovy +++ /dev/null @@ -1,60 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex -import org.apache.tinkerpop.gremlin.structure.VertexProperty - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyPropertiesTest { - - public static class Traversals extends PropertiesTest { - - @Override - public Traversal get_g_V_hasXageX_propertiesXname_ageX_value() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').properties('name', 'age').value") - } - - @Override - public Traversal get_g_V_hasXageX_propertiesXage_nameX_value() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').properties('age', 'name').value") - } - - @Override - public Traversal get_g_V_hasXageX_properties_hasXid_nameIdX_value(final Object nameId) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').properties().has(T.id, nameId).value()", "nameId", nameId) - } - - @Override - public Traversal> get_g_V_hasXageX_propertiesXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').properties('name')") - } - - @Override - public Traversal, String> get_g_injectXg_VX1X_propertiesXnameX_nextX_value( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.inject(g.V(v1Id).properties('name').next()).value()", "v1Id", v1Id) - } - } - -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy deleted file mode 100644 index 89fc691f863..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySelectTest.groovy +++ /dev/null @@ -1,252 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Pop -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovySelectTest { - - public static class Traversals extends SelectTest { - - @Override - public Traversal get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXfirst_aX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').repeat(__.out().as('a')).times(2).select(Pop.first, 'a')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_repeatXout_asXaXX_timesX2X_selectXlast_aX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').repeat(__.out().as('a')).times(2).select(Pop.last, 'a')", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('knows').as('b').select('a','b')", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('knows').as('b').select('a','b').by('name')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXknowsX_asXbX_selectXaX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('knows').as('b').select('a')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_asXaX_outXknowsX_asXbX_selectXaX_byXnameX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out('knows').as('b').select('a').by('name')", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_V_asXaX_out_asXbX_selectXa_bX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.as('b').select('a','b').by('name')") - } - - @Override - public Traversal> get_g_V_asXaX_out_aggregateXxX_asXbX_selectXa_bX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out.aggregate('x').as('b').select('a','b').by('name')") - } - - @Override - public Traversal> get_g_V_asXaX_name_order_asXbX_selectXa_bX_byXnameX_by_XitX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').name.order().as('b').select('a','b').by('name').by") - } - - @Override - public Traversal> get_g_V_hasXname_gremlinX_inEXusesX_order_byXskill_incrX_asXaX_outV_asXbX_selectXa_bX_byXskillX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name', 'gremlin').inE('uses').order.by('skill', Order.incr).as('a').outV.as('b').select('a','b').by('skill').by('name')") - } - - @Override - public Traversal get_g_V_hasXname_isXmarkoXX_asXaX_selectXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('name',__.is('marko')).as('a').select('a')") - } - - @Override - public Traversal> get_g_V_label_groupCount_asXxX_selectXxX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().label().groupCount().as('x').select('x')") - } - - @Override - public Traversal> get_g_V_hasLabelXpersonX_asXpX_mapXbothE_label_groupCountX_asXrX_selectXp_rX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').as('p').map(__.bothE.label.groupCount()).as('r').select('p','r')") - } - - @Override - public Traversal get_g_V_chooseXoutE_count_isX0X__asXaX__asXbXX_chooseXselectXaX__selectXaX__selectXbXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.choose(__.outE().count().is(0L), __.as('a'), __.as('b')).choose(select('a'),select('a'),select('b'))") - } - - // below are original back()-tests - - @Override - public Traversal get_g_VX1X_asXhereX_out_selectXhereX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('here').out.select('here')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).out.as('here').has('lang', 'java').select('here')", "v4Id", v4Id) - } - - @Override - public Traversal get_g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX_name( - final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).out.as('here').has('lang', 'java').select('here').name", "v4Id", v4Id) - } - - @Override - public Traversal get_g_VX1X_outE_asXhereX_inV_hasXname_vadasX_selectXhereX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE.as('here').inV.has('name', 'vadas').select('here')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outEXknowsX_hasXweight_1X_asXhereX_inV_hasXname_joshX_selectXhereX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('knows').has('weight', 1.0d).as('here').inV.has('name', 'josh').select('here')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outEXknowsX_asXhereX_hasXweight_1X_inV_hasXname_joshX_selectXhereX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('knows').as('here').has('weight', 1.0d).inV.has('name', 'josh').select('here')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outEXknowsX_asXhereX_hasXweight_1X_asXfakeX_inV_hasXname_joshX_selectXhereX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('knows').as('here').has('weight', 1.0d).as('fake').inV.has('name', 'josh').select('here')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_asXhereXout_name_selectXhereX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('here').out.name.select('here')") - } - - - @Override - public Traversal> get_g_V_outXcreatedX_unionXasXprojectX_inXcreatedX_hasXname_markoX_selectXprojectX__asXprojectX_inXcreatedX_inXknowsX_hasXname_markoX_selectXprojectXX_groupCount_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", """g.V.out('created') - .union(__.as('project').in('created').has('name', 'marko').select('project'), - __.as('project').in('created').in('knows').has('name', 'marko').select('project')).groupCount().by('name')""") - } - - @Override - public Traversal> get_g_V_asXaX_hasXname_markoX_asXbX_asXcX_selectXa_b_cX_by_byXnameX_byXageX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').has('name', 'marko').as('b').as('c').select('a','b','c').by().by('name').by('age')") - } - - @Override - public Traversal> get_g_V_hasLabelXsoftwareX_asXnameX_asXlanguageX_asXcreatorsX_selectXname_language_creatorsX_byXnameX_byXlangX_byXinXcreatedX_name_fold_orderXlocalXX() { - new ScriptTraversal<>(g, "gremlin-groovy", """g.V.hasLabel('software').as('name').as('language').as('creators').select('name','language','creators').by('name').by('lang'). - by(__.in('created').values('name').fold().order(local))""") - } - - // TINKERPOP-619: select should not throw - - @Override - public Traversal get_g_V_selectXaX(final Pop pop) { - final String root = "g.V." - new ScriptTraversal<>(g, "gremlin-groovy", root + (null == pop ? "select('a')" : "select(${pop}, 'a')")) - } - - @Override - public Traversal> get_g_V_selectXa_bX(final Pop pop) { - final String root = "g.V." - new ScriptTraversal<>(g, "gremlin-groovy", root + (null == pop ? "select('a', 'b')" : "select(${pop}, 'a', 'b')")) - } - - @Override - public Traversal get_g_V_valueMap_selectXpop_aX(final Pop pop) { - final String root = "g.V.valueMap." - new ScriptTraversal<>(g, "gremlin-groovy", root + (null == pop ? "select('a')" : "select(${pop}, 'a')")) - } - - @Override - public Traversal> get_g_V_valueMap_selectXpop_a_bX(final Pop pop) { - final String root = "g.V.valueMap." - new ScriptTraversal<>(g, "gremlin-groovy", root + (null == pop ? "select('a', 'b')" : "select(${pop}, 'a', 'b')")) - } - - // when labels don't exist - - @Override - public Traversal get_g_V_untilXout_outX_repeatXin_asXaXX_selectXaX_byXtailXlocalX_nameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.until(__.out.out).repeat(__.in.as('a')).select('a').by(tail(local).name)") - } - - @Override - public Traversal> get_g_V_untilXout_outX_repeatXin_asXaX_in_asXbXX_selectXa_bX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.until(__.out.out).repeat(__.in.as('a').in.as('b')).select('a','b').by('name')") - } - - @Override - public Traversal get_g_V_asXaX_whereXoutXknowsXX_selectXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').where(out('knows')).select('a')") - } - - // select column tests - - @Override - public Traversal get_g_V_outE_weight_groupCount_selectXvaluesX_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.weight.groupCount.select(values).unfold") - } - - @Override - public Traversal get_g_V_outE_weight_groupCount_unfold_selectXvaluesX_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.weight.groupCount.unfold.select(values).unfold") - } - - @Override - public Traversal get_g_V_outE_weight_groupCount_selectXvaluesX_unfold_groupCount_selectXvaluesX_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.weight.groupCount.select(values).unfold.groupCount.select(values).unfold") - } - - @Override - public Traversal get_g_V_outE_weight_groupCount_selectXkeysX_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.weight.groupCount.select(keys).unfold") - } - - @Override - public Traversal get_g_V_outE_weight_groupCount_unfold_selectXkeysX_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.weight.groupCount.unfold.select(keys).unfold") - } - - @Override - public Traversal>> get_g_V_asXa_bX_out_asXcX_path_selectXkeysX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a','b').out.as('c').path.select(keys)") - } - - @Override - public Traversal> get_g_V_asXaX_outXknowsX_asXbX_localXselectXa_bX_byXnameXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.as('a').out('knows').as('b').local(select('a', 'b').by('name'))") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySumTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySumTest.groovy deleted file mode 100644 index f863398fa63..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovySumTest.groovy +++ /dev/null @@ -1,42 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Daniel Kuppitz (http://gremlin.guru) - */ -public abstract class GroovySumTest { - - public static class Traversals extends SumTest { - - @Override - public Traversal get_g_V_valuesXageX_sum() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.age.sum") - } - - @Override - public Traversal> get_g_V_hasLabelXsoftwareX_group_byXnameX_byXbothE_weight_sumX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('software').group().by('name').by(bothE().weight.sum)") - } - } -} \ No newline at end of file diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyUnfoldTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyUnfoldTest.groovy deleted file mode 100644 index 8f8058ef4ce..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyUnfoldTest.groovy +++ /dev/null @@ -1,48 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyUnfoldTest { - - public static class Traversals extends UnfoldTest { - - @Override - public Traversal get_g_V_localXoutE_foldX_unfold() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.local(__.outE.fold).unfold") - } - - @Override - public Traversal get_g_V_valueMap_unfold_mapXkeyX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap.unfold.map { it.key }") - } - - @Override - Traversal get_g_VX1X_repeatXboth_simplePathX_untilXhasIdX6XX_path_byXnameX_unfold(Object v1Id, Object v6Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).repeat(__.both.simplePath).until(hasId(v6Id)).path.by('name').unfold", "v1Id", v1Id, "v6Id", v6Id) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy deleted file mode 100644 index 6e339f90c6d..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyValueMapTest.groovy +++ /dev/null @@ -1,51 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyValueMapTest { - - public static class Traversals extends ValueMapTest { - @Override - public Traversal> get_g_V_valueMap() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap"); - } - - @Override - public Traversal> get_g_V_valueMapXname_ageX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.valueMap('name', 'age')") - } - - @Override - public Traversal>> get_g_VX1X_outXcreatedX_valueMap(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('created').valueMap", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_V_hasLabelXpersonX_filterXoutEXcreatedXX_valueMapXtrueX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().hasLabel('person').filter(__.outE('created')).valueMap(true)") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyVertexTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyVertexTest.groovy deleted file mode 100644 index ce5fe6f6280..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyVertexTest.groovy +++ /dev/null @@ -1,187 +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.process.traversal.step.map - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyVertexTest { - - public static class Traversals extends VertexTest { - - @Override - public Traversal get_g_VXlistXv1_v2_v3XX_name( - final Vertex v1, final Vertex v2, final Vertex v3) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(ids).name", "ids", [v1, v2, v3]) - } - - @Override - public Traversal get_g_VXlistX1_2_3XX_name( - final Object v1Id, final Object v2Id, final Object v3Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(ids).name", "ids", [v1Id, v2Id, v3Id]) - } - - @Override - public Traversal get_g_V() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V") - } - - @Override - public Traversal get_g_VX1X_out(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out", "v1Id", v1Id); - } - - @Override - public Traversal get_g_VX2X_in(final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v2Id).in", "v2Id", v2Id); - } - - @Override - public Traversal get_g_VX4X_both(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).both", "v4Id", v4Id); - } - - @Override - public Traversal get_g_E() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E") - } - - @Override - public Traversal get_g_EX11X(final Object e11Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.E(e11Id)", "e11Id", e11Id) - } - - @Override - public Traversal get_g_VX1X_outE(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE", "v1Id", v1Id); - } - - @Override - public Traversal get_g_VX2X_inE(final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v2Id).inE", "v2Id", v2Id); - } - - @Override - public Traversal get_g_VX4X_bothE(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).bothE", "v4Id", v4Id); - } - - @Override - public Traversal get_g_VX4X_bothEXcreatedX(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).bothE('created')", "v4Id", v4Id); - } - - @Override - public Traversal get_g_VX1X_outE_inV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE.inV", "v1Id", v1Id); - } - - @Override - public Traversal get_g_VX2X_inE_outV(final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v2Id).inE.outV", "v2Id", v2Id); - } - - @Override - public Traversal get_g_V_outE_hasXweight_1X_outV() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.outE.has('weight', 1.0d).outV") - } - - @Override - public Traversal get_g_V_out_outE_inV_inE_inV_both_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.outE.inV.inE.inV.both.name") - } - - @Override - public Traversal get_g_VX1X_outEXknowsX_bothV_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('knows').bothV.name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outXknowsX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('knows')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outXknows_createdX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out('knows', 'created')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outEXknowsX_inV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('knows').inV()", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outEXknows_createdX_inV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE('knows', 'created').inV", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_out_out() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out().out()") - } - - @Override - public Traversal get_g_VX1X_out_out_out(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.out.out", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.name", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_outE_otherV(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).outE.otherV", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX4X_bothE_otherV(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).bothE.otherV", "v4Id", v4Id) - } - - @Override - public Traversal get_g_VX4X_bothE_hasXweight_lt_1X_otherV(final Object v4Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v4Id).bothE.has('weight', lt(1.0d)).otherV", "v4Id", v4Id) - } - - @Override - public Traversal get_g_VX1X_to_XOUT_knowsX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).to(Direction.OUT, 'knows')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1_2_3_4X_name( - final Object v1Id, final Object v2Id, final Object v3Id, final Object v4Id) { - g.V(v3Id).drop().iterate(); - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id, v2Id, v4Id, v3Id).name", "v1Id", v1Id, "v2Id", v2Id, "v3Id", v3Id, "v4Id", v4Id) - } - - @Override - public Traversal get_g_V_hasLabelXpersonX_V_hasLabelXsoftwareX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').V.hasLabel('software').name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyAggregateTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyAggregateTest.groovy deleted file mode 100644 index d9d4a0407bf..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyAggregateTest.groovy +++ /dev/null @@ -1,53 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyAggregateTest { - - public static class Traversals extends AggregateTest { - - @Override - public Traversal> get_g_V_name_aggregateXxX_capXxX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.name.aggregate('x').cap('x')") - } - - @Override - public Traversal> get_g_V_aggregateXxX_byXnameX_capXxX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.aggregate('x').by('name').cap('x')") - } - - @Override - public Traversal get_g_V_out_aggregateXaX_path() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.aggregate('a').path") - } - - @Override - public Traversal> get_g_V_hasLabelXpersonX_aggregateXxX_byXageX_capXxX_asXyX_selectXyX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('person').aggregate('x').by('age').cap('x').as('y').select('y')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyExplainTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyExplainTest.groovy deleted file mode 100644 index c284e0f46f1..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyExplainTest.groovy +++ /dev/null @@ -1,35 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyExplainTest { - - public static class Traversals extends ExplainTest { - - public TraversalExplanation get_g_V_outE_identity_inV_explain() { - g.V().outE().identity().inV().explain() - } - } -} \ No newline at end of file diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupCountTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupCountTest.groovy deleted file mode 100644 index 77ba1c14305..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupCountTest.groovy +++ /dev/null @@ -1,101 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyGroupCountTest { - - public static class Traversals extends GroupCountTest { - - @Override - public Traversal> get_g_V_outXcreatedX_groupCount_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').groupCount.by('name')") - } - - @Override - public Traversal> get_g_V_outXcreatedX_groupCountXaX_byXnameX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').groupCount('a').by('name').cap('a')") - } - - @Override - public Traversal> get_g_V_outXcreatedX_name_groupCount() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').name.groupCount") - } - - @Override - public Traversal> get_g_V_outXcreatedX_groupCountXxX_capXxX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').groupCount('x').cap('x')") - } - - @Override - public Traversal> get_g_V_outXcreatedX_name_groupCountXaX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('created').name.groupCount('a').cap('a')") - } - - @Override - public Traversal> get_g_V_hasXnoX_groupCount() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('no').groupCount") - } - - @Override - public Traversal> get_g_V_hasXnoX_groupCountXaX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('no').groupCount('a').cap('a')") - } - - @Override - public Traversal> get_g_V_repeatXout_groupCountXaX_byXnameXX_timesX2X_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out.groupCount('a').by('name')).times(2).cap('a')") - } - - @Override - public Traversal> get_g_V_unionXrepeatXoutX_timesX2X_groupCountXmX_byXlangXX__repeatXinX_timesX2X_groupCountXmX_byXnameXX_capXmX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.union( - __.repeat(__.out).times(2).groupCount('m').by('lang'), - __.repeat(__.in).times(2).groupCount('m').by('name')).cap('m') - """) - } - - @Override - public Traversal> get_g_V_groupCount_byXbothE_countX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.groupCount.by(bothE().count)") - } - - @Override - public Traversal get_g_V_unionXoutXknowsX__outXcreatedX_inXcreatedXX_groupCount_selectXvaluesX_unfold_sum() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.union(out('knows'), out('created').in('created')).groupCount.select(values).unfold.sum") - } - - @Override - public Traversal> get_g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.groupCount('a').out.cap('a').select(keys).unfold.both.groupCount('a').cap('a')") - } - - @Override - public Traversal get_g_V_both_groupCountXaX_byXlabelX_asXbX_barrier_whereXselectXaX_selectXsoftwareX_isXgtX2XXX_selectXbX_name() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.both.groupCount('a').by(label).as('b').barrier.where(select('a').select('software').is(gt(2))).select('b').name") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy deleted file mode 100644 index fc0c55d4d5c..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy +++ /dev/null @@ -1,137 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyGroupTest { - - public static class Traversals extends GroupTest { - - @Override - public Traversal>> get_g_V_group_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group.by('name')") - } - - @Override - public Traversal>> get_g_V_group_byXnameX_by() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group.by('name').by") - } - - @Override - public Traversal>> get_g_V_groupXaX_byXnameX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group('a').by('name').cap('a')") - } - - @Override - public Traversal>> get_g_V_hasXlangX_groupXaX_byXlangX_byXnameX_out_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('lang').group('a').by('lang').by('name').out.cap('a')") - } - - @Override - public Traversal> get_g_V_hasXlangX_group_byXlangX_byXcountX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('lang').group.by('lang').by(count())") - } - - @Override - public Traversal> get_g_V_repeatXout_groupXaX_byXnameX_byXcountX_timesX2X_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out.group('a').by('name').by(count())).times(2).cap('a')") - } - - @Override - public Traversal>> get_g_V_group_byXoutE_countX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group.by(__.outE.count).by('name')") - } - - @Override - public Traversal> get_g_V_groupXaX_byXlabelX_byXoutE_weight_sumX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group('a').by(label).by(outE().weight.sum).cap('a')"); - } - - @Override - public Traversal> get_g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(both('followedBy')).times(2).group.by('songType').by(count())") - } - - @Override - public Traversal> get_g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(both('followedBy')).times(2).group('a').by('songType').by(count()).cap('a')") - } - - @Override - public Traversal> get_g_V_group_byXname_substring_1X_byXconstantX1XX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group.by{it.name[0]}.by(constant(1l))") - } - - @Override - public Traversal> get_g_V_groupXaX_byXname_substring_1X_byXconstantX1XX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group('a').by{it.name[0]}.by(constant(1l)).cap('a')") - } - - @Override - public Traversal get_g_V_out_group_byXlabelX_selectXpersonX_unfold_outXcreatedX_name_limitX2X() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.group.by(label).select('person').unfold.out('created').name.limit(2)") - } - - @Override - public Traversal>> get_g_V_hasLabelXsongX_group_byXnameX_byXproperties_groupCount_byXlabelXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('song').group.by('name').by(__.properties().groupCount.by(label))") - } - - @Override - public Traversal>> get_g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('song').group('a').by('name').by(__.properties().groupCount.by(label)).out.cap('a')") - } - - @Override - public Traversal>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(union(out('knows').group('a').by('age'), out('created').group('b').by('name').by(count())).group('a').by('name')).times(2).cap('a', 'b')") - } - - @Override - public Traversal>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group().by(bothE().count).by(group().by(label))") - } - - @Override - public Traversal>> get_g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('followedBy').group.by('songType').by(bothE().group.by(label).by(values('weight').sum))") - } - - @Override - public Traversal> get_g_V_groupXmX_byXnameX_byXinXknowsX_nameX_capXmX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group('m').by('name').by(__.in('knows').name).cap('m')") - } - - @Override - public Traversal> get_g_V_group_byXlabelX_byXbothE_groupXaX_byXlabelX_byXweight_sumX_weight_sumX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group().by(label).by(bothE().group('a').by(label).by(values('weight').sum).weight.sum)") - } - - @Override - public Traversal>> get_g_withSideEffectXa__marko_666_noone_blahX_V_groupXaX_byXnameX_byXoutE_label_foldX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a', map).V().group('a').by('name').by(outE().label.fold).cap('a')", "map", new HashMap<>(["marko": [666], "noone": ["blah"]])); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTestV3d0.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTestV3d0.groovy deleted file mode 100644 index d8e970608ad..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTestV3d0.groovy +++ /dev/null @@ -1,74 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@Deprecated -public abstract class GroovyGroupTestV3d0 { - - public static class Traversals extends GroupTestV3d0 { - - @Override - public Traversal>> get_g_V_group_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.groupV3d0.by('name')") - } - - @Override - public Traversal>> get_g_V_groupXaX_byXnameX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.groupV3d0('a').by('name').cap('a')") - } - - @Override - public Traversal>> get_g_V_hasXlangX_groupXaX_byXlangX_byXnameX_out_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('lang').groupV3d0('a').by('lang').by('name').out.cap('a')") - } - - @Override - public Traversal> get_g_V_hasXlangX_group_byXlangX_byX1X_byXcountXlocalXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('lang').groupV3d0.by('lang').by(__.inject(1)).by(__.count(Scope.local))") - } - - @Override - public Traversal> get_g_V_repeatXout_groupXaX_byXnameX_by_byXcountXlocalXX_timesX2X_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(__.out.groupV3d0('a').by('name').by.by(__.count(Scope.local))).times(2).cap('a')") - } - - @Override - public Traversal>> get_g_V_group_byXoutE_countX_byXnameX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.groupV3d0.by(__.outE.count).by('name')") - } - - @Override - public Traversal> get_g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byX1X_byXcountXlocalXX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(both('followedBy')).times(2).groupV3d0.by('songType').by(inject(1)).by(count(local))") - } - - @Override - public Traversal> get_g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byX1X_byXcountXlocalXX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(both('followedBy')).times(2).groupV3d0('a').by('songType').by(inject(1)).by(count(local)).cap('a')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyInjectTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyInjectTest.groovy deleted file mode 100644 index fb8efb2ebcb..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyInjectTest.groovy +++ /dev/null @@ -1,42 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Path -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyInjectTest { - - public static class Traversals extends InjectTest { - @Override - public Traversal get_g_VX1X_out_injectXv2X_name(final Object v1Id, final Object v2Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.inject(g.V(v2Id).next()).name", "v1Id", v1Id, "v2Id", v2Id); - } - - @Override - public Traversal get_g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out().name.inject('daniel').as('a').map { it.length() }.path", "v1Id", v1Id); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy deleted file mode 100644 index a478f6f0179..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy +++ /dev/null @@ -1,84 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovySackTest { - - public static class Traversals extends SackTest { - - @Override - public Traversal get_g_withSackXhelloX_V_outE_sackXassignX_byXlabelX_inV_sack() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack('hello').V.outE.sack(assign).by(label).inV.sack") - } - - @Override - public Traversal get_g_withSackX0X_V_outE_sackXsumX_byXweightX_inV_sack_sum() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(0.0d).V.outE.sack(sum).by('weight').inV.sack.sum()") - } - - @Override - public Traversal get_g_withSackX0X_V_repeatXoutE_sackXsumX_byXweightX_inVX_timesX2X_sack() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(0.0d).V.repeat(__.outE.sack(sum).by('weight').inV).times(2).sack()") - } - - @Override - public Traversal get_g_withSackX0X_V_outE_sackXsum_weightX_inV_sack_sum() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(0.0d).V().outE.sack(sum, 'weight').inV.sack.sum()") - } - - @Override - public Traversal get_g_withSackX0X_V_repeatXoutE_sackXsum_weightX_inVX_timesX2X_sack() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(0.0d).V.repeat(__.outE.sack(sum, 'weight').inV).times(2).sack") - } - - @Override - public Traversal get_g_withSackXmap__map_cloneX_V_out_out_sackXmap_a_nameX_sack() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack{[:]}{ it.clone() }.V.out().out().sack { m, v -> m['a'] = v.name; m }.sack()") - } - - @Override - public Traversal get_g_withSackX1_sumX_VX1X_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(1.0d,sum).V(v1Id).local(out('knows').barrier(normSack)).in('knows').barrier.sack", "v1Id", v1Id) - } - - @Override - public Traversal get_g_withBulkXfalseX_withSackX1_sumX_V_out_barrier_sack() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withBulk(false).withSack(1, sum).V.out.barrier.sack") - } - - @Override - public Traversal get_g_withBulkXfalseX_withSackX1_sumX_VX1X_localXoutEXknowsX_barrierXnormSackX_inVX_inXknowsX_barrier_sack( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withBulk(false).withSack(1.0d, sum).V(v1Id).local(outE('knows').barrier(normSack).inV).in('knows').barrier.sack", "v1Id", v1Id) - } - - @Override - Traversal get_g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(BigInteger.TEN.pow(1000), assign).V.local(out('knows').barrier(normSack)).in('knows').barrier.sack") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectCapTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectCapTest.groovy deleted file mode 100644 index ea69e2fab5a..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectCapTest.groovy +++ /dev/null @@ -1,45 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovySideEffectCapTest { - - public static class Traversals extends SideEffectCapTest { - @Override - public Traversal> get_g_V_hasXageX_groupCountXaX_byXnameX_out_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.has('age').groupCount('a').by('name').out.cap('a')") - } - - @Override - public Traversal>> get_g_V_chooseXlabel_person__age_groupCountXaX__name_groupCountXbXX_capXa_bX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.V.choose(__.has(T.label, 'person'), - __.age.groupCount('a'), - __.values("name").groupCount('b')).cap('a', 'b') - """) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy deleted file mode 100644 index 03e1590314e..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy +++ /dev/null @@ -1,83 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovySideEffectTest { - - public static class Traversals extends SideEffectTest { - - @Override - public Traversal get_g_VX1X_sideEffectXstore_aX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", """g.withSideEffect('a') { [] }.V(v1Id).sideEffect { - it.sideEffects('a').clear(); - it.sideEffects('a').add(it.get()); - }.name""", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_sideEffectXincr_cX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", """g.withSideEffect('c') { [0] }.V(v1Id).out.sideEffect { - temp = it.sideEffects('c')[0]; - it.sideEffects('c').clear(); - it.sideEffects('c').add(temp + 1); - }.name""", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_sideEffectXX_name(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out().sideEffect {}.name", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_withSideEffectXa__linkedhashmapX_V_out_groupCountXaX_byXlabelX_out_out_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a'){[:] as LinkedHashMap}.V.out.groupCount('a').by(label).out.out.cap('a')"); - } - - @Override - public Traversal> get_g_withSideEffectsXa__linkedhashmapX_withSideEffectXb__arraylist__addAllX_withSideEffectXc__arrayList__addAllX_V_groupXaX_byXlabelX_byXcountX_sideEffectXb__1_2_3X_out_out_out_sideEffectXc__bob_danielX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", """ - g.withSideEffect('a'){[:] as LinkedHashMap} - .withSideEffect('b',{[:] as ArrayList},addAll) - .withSideEffect('c',{[:] as ArrayList},addAll) - .V.group('a').by(label).by(count()) - .sideEffect{it.sideEffects('b', [1,2,3] as LinkedList)} - .out.out.out - .sideEffect{it.sideEffect('c',['bob','daniel'] as LinkedList)} - .cap('a'); - """); - } - - @Override - public Traversal get_g_withSideEffectXa_0_sumX_V_out_sideEffectXsideEffectsXa_bulkXX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a', 0, sum).V.out.sideEffect{it.sideEffects('a', it.bulk() as int)}.cap('a')") - } - - @Override - public Traversal get_g_withSideEffectXa_0X_V_out_sideEffectXsideEffectsXa_1XX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a', 0).V.out.sideEffect{it.sideEffects('a', 1)}.cap('a')") - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy deleted file mode 100644 index 5a24f07cd11..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyStoreTest.groovy +++ /dev/null @@ -1,53 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyStoreTest { - - public static class Traversals extends StoreTest { - - @Override - public Traversal get_g_V_storeXaX_byXnameX_out_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V().store('a').by('name').out().cap('a')") - } - - @Override - public Traversal get_g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX( - final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).store('a').by('name').out().store('a').by('name').name.cap('a')", "v1Id", v1Id) - } - - @Override - public Traversal> get_g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a'){[] as Set}.V.both.name.store('a').cap('a')"); - } - - @Override - public Traversal get_g_V_storeXaX_byXoutEXcreatedX_countX_out_out_storeXaX_byXinEXcreatedX_weight_sumX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.store('a').by(__.outE('created').count).out.out.store('a').by(__.inE('created').weight.sum).cap('a')"); - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy deleted file mode 100644 index 7e3765ab8ea..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Graph -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovySubgraphTest { - - public static class Traversals extends SubgraphTest { - - @Override - public Traversal get_g_V_withSideEffectXsgX_outEXknowsX_subgraphXsgX_name_capXsgX( - final Object v1Id, final Graph subgraph) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('sg') { subgraph }.V(v1Id).outE('knows').subgraph('sg').name.cap('sg')", "v1Id", v1Id, "subgraph", subgraph) - } - - @Override - public Traversal get_g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup( - final Graph subgraph) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('sg') { subgraph }.V.repeat(__.bothE('created').subgraph('sg').outV).times(5).name.dedup", "subgraph", subgraph) - } - - @Override - public Traversal get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(final Graph subgraph) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('sg') { subgraph }.V.has('name','daniel').outE.subgraph('sg').inV", "subgraph", subgraph) - } - } -} diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyTreeTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyTreeTest.groovy deleted file mode 100644 index f1a6f831844..00000000000 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyTreeTest.groovy +++ /dev/null @@ -1,69 +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.process.traversal.step.sideEffect - -import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree -import org.apache.tinkerpop.gremlin.process.traversal.util.ScriptTraversal -import org.apache.tinkerpop.gremlin.structure.Vertex - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class GroovyTreeTest { - - public static class Traversals extends TreeTest { - - @Override - public Traversal get_g_V_out_out_tree_byXidX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.out.tree.by(id)") - } - - @Override - public Traversal get_g_V_out_out_treeXaX_byXidX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.out.tree('a').by(id).cap('a')") - } - - @Override - public Traversal get_g_V_out_out_tree() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.out.tree()") - } - - @Override - public Traversal get_g_V_out_out_treeXaX_capXaX() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.out.tree('a').cap('a')") - } - - @Override - public Traversal get_g_VX1X_out_out_treeXaX_byXnameX_both_both_capXaX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.out.tree('a').by('name').both.both.cap('a')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_VX1X_out_out_tree_byXnameX(final Object v1Id) { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out.out.tree.by('name')", "v1Id", v1Id) - } - - @Override - public Traversal get_g_V_out_out_out_tree() { - new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out.out.out.tree") - } - - } -} diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java deleted file mode 100644 index ecd481f299a..00000000000 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java +++ /dev/null @@ -1,85 +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.groovy; - -import org.apache.tinkerpop.gremlin.AbstractGremlinSuite; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.GraphManager; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineIntegrateTest; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.RunnerBuilder; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * The {@code GroovyEnvironmentIntegrateSuite} is a JUnit test runner that executes the Gremlin Test Suite over a - * {@link Graph} implementation. This test suite covers ensures that a vendor implementation is compliant with - * the Groovy "environment" which will typically ensure that the {@link Graph} will work as expected in the Gremlin - * Console, Gremlin Server, and other Groovy environments. - *

- * Note that this suite contains "long-run" tests. At this time, this suite can be considered optional to providers. - *

- * For more information on the usage of this suite, please see {@link StructureStandardSuite}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced as a test suite that Graph Providers need to implement. - */ -@Deprecated -public class GroovyEnvironmentIntegrateSuite extends AbstractGremlinSuite { - - /** - * This list of tests in the suite that will be executed. Gremlin developers should add to this list - * as needed to enforce tests upon implementations. - */ - private static final Class[] allTests = new Class[]{ - GremlinGroovyScriptEngineIntegrateTest.class - }; - - public GroovyEnvironmentIntegrateSuite(final Class klass, final RunnerBuilder builder) throws InitializationError { - super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD); - } - - @Override - public boolean beforeTestExecution(final Class testClass) { - unloadSugar(); - SugarLoader.load(); - return true; - } - - @Override - public void afterTestExecution(final Class testClass) { - unloadSugar(); - } - - private void unloadSugar() { - try { - SugarTestHelper.clearRegistry(GraphManager.getGraphProvider()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java deleted file mode 100644 index 7fda6f900ef..00000000000 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java +++ /dev/null @@ -1,92 +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.groovy; - -import org.apache.tinkerpop.gremlin.AbstractGremlinSuite; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.GraphManager; -import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutorOverGraphTest; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFileSandboxTest; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineOverGraphTest; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineSandboxedStandardTest; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineTinkerPopSandboxTest; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslatorTest; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoaderTest; -import org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphTest; -import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.RunnerBuilder; - -/** - * The {@code GroovyEnvironmentSuite} is a JUnit test runner that executes the Gremlin Test Suite over a - * {@link Graph} implementation. This test suite covers ensures that a vendor implementation is compliant with - * the Groovy "environment" which will typically ensure that the {@link Graph} will work as expected in the Gremlin - * Console, Gremlin Server, and other Groovy environments. - *

- * For more information on the usage of this suite, please see {@link StructureStandardSuite}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced as a test suite that Graph Providers need to implement. - */ -@Deprecated -public class GroovyEnvironmentSuite extends AbstractGremlinSuite { - - /** - * This list of tests in the suite that will be executed. Gremlin developers should add to this list - * as needed to enforce tests upon implementations. - */ - private static final Class[] allTests = new Class[]{ - CredentialGraphTest.class, - GremlinGroovyScriptEngineOverGraphTest.class, - GremlinGroovyScriptEngineSandboxedStandardTest.class, - GremlinGroovyScriptEngineTinkerPopSandboxTest.class, - GremlinGroovyScriptEngineFileSandboxTest.class, - GremlinExecutorOverGraphTest.class, - GroovyTranslatorTest.class, - SugarLoaderTest.class, - }; - - public GroovyEnvironmentSuite(final Class klass, final RunnerBuilder builder) throws InitializationError { - super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD); - } - - @Override - public boolean beforeTestExecution(final Class testClass) { - unloadSugar(); - SugarLoader.load(); - return true; - } - - @Override - public void afterTestExecution(final Class testClass) { - unloadSugar(); - } - - private void unloadSugar() { - try { - SugarTestHelper.clearRegistry(GraphManager.getGraphProvider()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/TestableConsolePluginAcceptor.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/TestableConsolePluginAcceptor.java deleted file mode 100644 index 89bccaf6e42..00000000000 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/TestableConsolePluginAcceptor.java +++ /dev/null @@ -1,79 +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.groovy.util; - -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; -import org.codehaus.groovy.tools.shell.Groovysh; -import org.codehaus.groovy.tools.shell.IO; - -import javax.script.ScriptException; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class TestableConsolePluginAcceptor implements PluginAcceptor { - - public static final String ENVIRONMENT_NAME = "console"; - public static final String ENVIRONMENT_SHELL = "ConsolePluginAcceptor.shell"; - public static final String ENVIRONMENT_IO = "ConsolePluginAcceptor.io"; - - private Groovysh shell = new Groovysh(new IO(System.in, new OutputStream() { - @Override - public void write(int b) throws IOException { - - } - }, System.err)); - - @Override - public void addImports(final Set importStatements) { - importStatements.forEach(this.shell::execute); - } - - @Override - public void addBinding(final String key, final Object val) { - this.shell.getInterp().getContext().setVariable(key, val); - } - - @Override - public Map getBindings() { - return Collections.unmodifiableMap(this.shell.getInterp().getContext().getVariables()); - } - - @Override - public Object eval(final String script) throws ScriptException { - return this.shell.execute(script); - } - - @Override - public Map environment() { - final Map env = new HashMap<>(); - env.put(GremlinPlugin.ENVIRONMENT, ENVIRONMENT_NAME); - env.put(ENVIRONMENT_IO, this.shell.getIo()); - env.put(ENVIRONMENT_SHELL, this.shell); - return env; - } - -} diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java deleted file mode 100644 index d408da6c541..00000000000 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java +++ /dev/null @@ -1,204 +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.process; - -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.GraphManager; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper; -import org.apache.tinkerpop.gremlin.process.computer.GraphComputer; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyBranchTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyChooseTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyOptionalTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyLocalTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyRepeatTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyUnionTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyAndTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyCoinTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyCyclicPathTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyDedupTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyFilterTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyHasTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyIsTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyOrTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyRangeTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovySampleTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovySimplePathTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyTailTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyWhereTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyAddEdgeTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCoalesceTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyConstantTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyFlatMapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyFoldTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyGraphTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyLoopsTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMapKeysTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMapValuesTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMaxTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMeanTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMinTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyOrderTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPageRankTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPathTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPeerPressureTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProfileTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProgramTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProjectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPropertiesTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovySelectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovySumTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyUnfoldTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyValueMapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyVertexTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyAggregateTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyExplainTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupCountTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTestV3d0; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyInjectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySackTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySideEffectCapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySideEffectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyStoreTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySubgraphTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyTreeTest; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.RunnerBuilder; - -/** - * The {@code GroovyProcessComputerSuite} is a JUnit test runner that executes the Gremlin Test Suite over a - * {@link Graph} implementation. This test suite covers traversal operations around {@link GraphComputer} and should - * be implemented by providers to validate that their implementations are compliant with the Groovy flavor of the - * Gremlin language. Implementations that use this test suite should return {@code true} for - * {@link Graph.Features.GraphFeatures#supportsComputer()}. - *

- * For more information on the usage of this suite, please see {@link StructureStandardSuite}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced as a test suite that Graph Providers need to implement. - */ -@Deprecated -public class GroovyProcessComputerSuite extends ProcessComputerSuite { - - /** - * This list of tests in the suite that will be executed. Gremlin developers should add to this list - * as needed to enforce tests upon implementations. - */ - private static final Class[] allTests = new Class[]{ - - //branch - GroovyBranchTest.Traversals.class, - GroovyChooseTest.Traversals.class, - GroovyOptionalTest.Traversals.class, - GroovyLocalTest.Traversals.class, - GroovyRepeatTest.Traversals.class, - GroovyUnionTest.Traversals.class, - - // filter - GroovyAndTest.Traversals.class, - GroovyCoinTest.Traversals.class, - GroovyCyclicPathTest.Traversals.class, - GroovyDedupTest.Traversals.class, - GroovyFilterTest.Traversals.class, - GroovyHasTest.Traversals.class, - GroovyIsTest.Traversals.class, - GroovyOrTest.Traversals.class, - GroovyRangeTest.Traversals.class, - GroovySampleTest.Traversals.class, - GroovySimplePathTest.Traversals.class, - GroovyTailTest.Traversals.class, - GroovyWhereTest.Traversals.class, - - // map - GroovyCoalesceTest.Traversals.class, - GroovyConstantTest.Traversals.class, - GroovyCountTest.Traversals.class, - GroovyFlatMapTest.Traversals.class, - GroovyFoldTest.Traversals.class, - GroovyGraphTest.Traversals.class, - GroovyLoopsTest.Traversals.class, - GroovyMapTest.Traversals.class, - GroovyMapKeysTest.Traversals.class, - GroovyMapValuesTest.Traversals.class, - GroovyMatchTest.CountMatchTraversals.class, - GroovyMatchTest.GreedyMatchTraversals.class, - GroovyMaxTest.Traversals.class, - GroovyMeanTest.Traversals.class, - GroovyMinTest.Traversals.class, - GroovyOrderTest.Traversals.class, - GroovyPageRankTest.Traversals.class, - GroovyPathTest.Traversals.class, - GroovyPeerPressureTest.Traversals.class, - GroovyProfileTest.Traversals.class, - GroovyProjectTest.Traversals.class, - GroovyProgramTest.Traversals.class, - GroovyPropertiesTest.Traversals.class, - GroovySelectTest.Traversals.class, - GroovySumTest.Traversals.class, - GroovyUnfoldTest.Traversals.class, - GroovyValueMapTest.Traversals.class, - GroovyVertexTest.Traversals.class, - - // sideEffect - GroovyAddEdgeTest.Traversals.class, - GroovyAggregateTest.Traversals.class, - GroovyExplainTest.Traversals.class, - GroovyGroupTest.Traversals.class, - GroovyGroupTestV3d0.Traversals.class, - GroovyGroupCountTest.Traversals.class, - GroovyInjectTest.Traversals.class, - GroovyProfileTest.Traversals.class, - GroovySackTest.Traversals.class, - GroovySideEffectCapTest.Traversals.class, - GroovySideEffectTest.Traversals.class, - GroovyStoreTest.Traversals.class, - GroovySubgraphTest.Traversals.class, - GroovyTreeTest.Traversals.class, - }; - - public GroovyProcessComputerSuite(final Class klass, final RunnerBuilder builder) throws InitializationError { - super(klass, builder, allTests); - } - - @Override - public boolean beforeTestExecution(final Class testClass) { - unloadSugar(); - SugarLoader.load(); - return true; - } - - @Override - public void afterTestExecution(final Class testClass) { - unloadSugar(); - } - - private void unloadSugar() { - try { - SugarTestHelper.clearRegistry(GraphManager.getGraphProvider()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java deleted file mode 100644 index 45aea91ad68..00000000000 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java +++ /dev/null @@ -1,198 +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.process; - -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.GraphManager; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper; -import org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyBranchTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyChooseTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyOptionalTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyLocalTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyRepeatTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyUnionTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyAndTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyCoinTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyCyclicPathTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyDedupTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyDropTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyFilterTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyHasTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyIsTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyOrTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyRangeTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovySampleTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovySimplePathTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyTailTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.filter.GroovyWhereTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyAddEdgeTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyAddVertexTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCoalesceTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyConstantTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyFlatMapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyFoldTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyGraphTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyLoopsTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMapKeysTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMapValuesTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMaxTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMeanTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMinTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyOrderTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPathTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProfileTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProjectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPropertiesTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovySelectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovySumTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyUnfoldTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyValueMapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyVertexTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyAggregateTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyExplainTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupCountTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTestV3d0; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyInjectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySackTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySideEffectCapTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySideEffectTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyStoreTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovySubgraphTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyTreeTest; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.RunnerBuilder; - -/** - * The {@code GroovyProcessStandardSuite} is a JUnit test runner that executes the Gremlin Test Suite over a - * {@link Graph} implementation. This test suite covers traversal operations and should be implemented by providers - * to validate that their implementations are compliant with the Groovy flavor of the Gremlin language. - *

- * For more information on the usage of this suite, please see {@link StructureStandardSuite}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced as a test suite that Graph Providers need to implement. - */ -@Deprecated -public class GroovyProcessStandardSuite extends ProcessStandardSuite { - - /** - * This list of tests in the suite that will be executed. Gremlin developers should add to this list - * as needed to enforce tests upon implementations. - */ - private static final Class[] allTests = new Class[]{ - // branch - GroovyBranchTest.Traversals.class, - GroovyChooseTest.Traversals.class, - GroovyOptionalTest.Traversals.class, - GroovyLocalTest.Traversals.class, - GroovyRepeatTest.Traversals.class, - GroovyUnionTest.Traversals.class, - // filter - GroovyAndTest.Traversals.class, - GroovyCoinTest.Traversals.class, - GroovyCyclicPathTest.Traversals.class, - GroovyDedupTest.Traversals.class, - GroovyDropTest.Traversals.class, - GroovyFilterTest.Traversals.class, - GroovyHasTest.Traversals.class, - GroovyIsTest.Traversals.class, - GroovyOrTest.Traversals.class, - GroovyRangeTest.Traversals.class, - GroovySampleTest.Traversals.class, - GroovySimplePathTest.Traversals.class, - GroovyTailTest.Traversals.class, - GroovyWhereTest.Traversals.class, - // map - GroovyAddEdgeTest.Traversals.class, - GroovyAddVertexTest.Traversals.class, - GroovyCoalesceTest.Traversals.class, - GroovyConstantTest.Traversals.class, - GroovyCountTest.Traversals.class, - GroovyFoldTest.Traversals.class, - GroovyFlatMapTest.Traversals.class, - GroovyGraphTest.Traversals.class, - GroovyLoopsTest.Traversals.class, - GroovyMapTest.Traversals.class, - GroovyMapKeysTest.Traversals.class, - GroovyMapValuesTest.Traversals.class, - GroovyMatchTest.CountMatchTraversals.class, - GroovyMatchTest.GreedyMatchTraversals.class, - GroovyMaxTest.Traversals.class, - GroovyMeanTest.Traversals.class, - GroovyMinTest.Traversals.class, - GroovyOrderTest.Traversals.class, - GroovyProfileTest.Traversals.class, - GroovyProjectTest.Traversals.class, - GroovyPathTest.Traversals.class, - GroovyPropertiesTest.Traversals.class, - GroovySelectTest.Traversals.class, - GroovySumTest.Traversals.class, - GroovyUnfoldTest.Traversals.class, - GroovyValueMapTest.Traversals.class, - GroovyVertexTest.Traversals.class, - // sideEffect - GroovyAggregateTest.Traversals.class, - GroovyExplainTest.Traversals.class, - GroovyGroupTest.Traversals.class, - GroovyGroupTestV3d0.Traversals.class, - GroovyGroupCountTest.Traversals.class, - GroovyInjectTest.Traversals.class, - GroovySackTest.Traversals.class, - GroovySideEffectCapTest.Traversals.class, - GroovySideEffectTest.Traversals.class, - GroovyStoreTest.Traversals.class, - GroovySubgraphTest.Traversals.class, - GroovyTreeTest.Traversals.class, - - // compliance - CoreTraversalTest.class, - }; - - public GroovyProcessStandardSuite(final Class klass, final RunnerBuilder builder) throws InitializationError { - super(klass, builder, allTests); - } - - @Override - public boolean beforeTestExecution(final Class testClass) { - unloadSugar(); - SugarLoader.load(); - return true; - } - - @Override - public void afterTestExecution(final Class testClass) { - unloadSugar(); - } - - private void unloadSugar() { - try { - SugarTestHelper.clearRegistry(GraphManager.getGraphProvider()); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/gremlin-groovy-test/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/gremlin-groovy-test/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory deleted file mode 100644 index 24c8a755f09..00000000000 --- a/gremlin-groovy-test/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory +++ /dev/null @@ -1 +0,0 @@ -org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory diff --git a/gremlin-groovy-test/src/main/resources/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorInit.groovy b/gremlin-groovy-test/src/main/resources/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorInit.groovy deleted file mode 100644 index c320195cc9c..00000000000 --- a/gremlin-groovy-test/src/main/resources/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorInit.groovy +++ /dev/null @@ -1,19 +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. - */ -def add(x, y) { x + y } \ No newline at end of file diff --git a/gremlin-groovy/pom.xml b/gremlin-groovy/pom.xml index 9bf45dbf146..75b21a5253a 100644 --- a/gremlin-groovy/pom.xml +++ b/gremlin-groovy/pom.xml @@ -71,6 +71,12 @@ limitations under the License. 0.4 + + org.apache.tinkerpop + tinkergraph-gremlin + ${project.version} + test + org.slf4j slf4j-log4j12 diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy b/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy similarity index 78% rename from gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy rename to gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy index dc973c4aa04..dd0e5f14839 100644 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy +++ b/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy @@ -18,38 +18,33 @@ */ package org.apache.tinkerpop.gremlin.groovy.loaders -import org.apache.tinkerpop.gremlin.AbstractGremlinTest -import org.apache.tinkerpop.gremlin.LoadGraphWith import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper import org.apache.tinkerpop.gremlin.process.traversal.Traversal -import org.apache.tinkerpop.gremlin.structure.Edge -import org.apache.tinkerpop.gremlin.structure.Graph -import org.apache.tinkerpop.gremlin.structure.Property -import org.apache.tinkerpop.gremlin.structure.Vertex -import org.apache.tinkerpop.gremlin.structure.VertexProperty +import org.apache.tinkerpop.gremlin.structure.* import org.apache.tinkerpop.gremlin.structure.util.StringFactory +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory +import org.junit.Before import org.junit.Test import static org.apache.tinkerpop.gremlin.process.traversal.P.eq -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertTrue -import static org.junit.Assert.fail +import static org.junit.Assert.* /** * @author Marko A. Rodriguez (http://markorodriguez.com) * @author Stephen Mallette (http://stephen.genoprime.com) */ -class SugarLoaderTest extends AbstractGremlinTest { +class SugarLoaderTest { - @Override - protected void afterLoadGraphWith(final Graph g) throws Exception { - SugarTestHelper.clearRegistry(graphProvider) + @Before + public void setup() throws Exception { + SugarTestHelper.clearRegistry() } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldNotAllowSugar() { - SugarTestHelper.clearRegistry(graphProvider) + def graph = TinkerFactory.createModern() + def g = graph.traversal() + SugarTestHelper.clearRegistry() try { g.V fail("Without sugar loaded, the traversal should fail"); @@ -79,13 +74,14 @@ class SugarLoaderTest extends AbstractGremlinTest { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldAllowSugar() { + def graph = TinkerFactory.createModern() + def g = graph.traversal() SugarLoader.load() assertEquals(6, g.V.count.next()) assertEquals(6, g.V.out.count.next()) assertEquals(6, g.V.out.name.count.next()) - assertEquals(2, g.V(convertToVertexId("marko")).out.out.name.count.next()); + assertEquals(2, g.V(convertToVertexId(graph, "marko")).out.out.name.count.next()); final Object markoId = convertToVertexId(graph, "marko"); g.V(markoId).next().name = 'okram' assertEquals('okram', g.V(markoId).next().name); @@ -97,8 +93,9 @@ class SugarLoaderTest extends AbstractGremlinTest { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldUseTraverserCategoryCorrectly() { + def graph = TinkerFactory.createModern() + def g = graph.traversal() SugarLoader.load() final Traversal t = g.V.as('a').out.as('x').name.as('b').select('x').has('age').map { [it.path().a, it.path().b, it.age] @@ -112,8 +109,9 @@ class SugarLoaderTest extends AbstractGremlinTest { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldHaveProperToStringOfMixins() { + def graph = TinkerFactory.createModern() + def g = graph.traversal() SugarLoader.load(); final Vertex vertex = graph.vertices().next(); final Edge edge = graph.edges().next(); @@ -128,7 +126,15 @@ class SugarLoaderTest extends AbstractGremlinTest { //assertEquals(StringFactory.traversalSourceString(g.withPath()), g.withPath().toString()); assertEquals(StringFactory.traversalString(g.V().out().asAdmin()), g.V().out().toString()); assertEquals(StringFactory.traversalString(g.V.out), g.V.out.toString()); - assertEquals(convertToVertex(graph, "marko").toString(), g.V(convertToVertexId("marko")).next().toString()) + assertEquals(convertToVertex(graph, "marko").toString(), g.V(convertToVertexId(graph, "marko")).next().toString()) + } + + private Object convertToVertexId(final Graph graph, final String vertexName) { + return convertToVertex(graph, vertexName).id(); + } + private Vertex convertToVertex(final Graph graph, final String vertexName) { + // all test graphs have "name" as a unique id which makes it easy to hardcode this...works for now + return graph.traversal().V().has("name", vertexName).next(); } } diff --git a/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy b/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy new file mode 100644 index 00000000000..cf2db11c2e6 --- /dev/null +++ b/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy @@ -0,0 +1,74 @@ +/* + * 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.groovy.util + +import org.apache.tinkerpop.gremlin.GraphProvider +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ +import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_LP_O_P_S_SE_SL_Traverser +import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_LP_O_S_SE_SL_Traverser +import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_S_SE_SL_Traverser +import org.apache.tinkerpop.gremlin.process.traversal.traverser.B_O_Traverser +import org.apache.tinkerpop.gremlin.process.traversal.traverser.O_Traverser +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +final class SugarTestHelper { + + public static final Set CORE_IMPLEMENTATIONS = new HashSet() {{ + add(__.class); + add(DefaultGraphTraversal.class); + add(GraphTraversalSource.class); + add(B_O_S_SE_SL_Traverser.class); + add(B_LP_O_P_S_SE_SL_Traverser.class); + add(B_LP_O_S_SE_SL_Traverser.class); + add(B_O_Traverser.class); + add(O_Traverser.class); + }}; + + + private static final Set IMPLEMENTATION = new HashSet() {{ + add(TinkerEdge.class); + add(TinkerElement.class); + add(TinkerGraph.class); + add(TinkerGraphVariables.class); + add(TinkerProperty.class); + add(TinkerVertex.class); + add(TinkerVertexProperty.class); + }}; + + /** + * Clear the metaclass registry to "turn-off" sugar. + */ + public static void clearRegistry() { + final Set implementationsToClear = new HashSet<>(CORE_IMPLEMENTATIONS) + implementationsToClear.addAll(IMPLEMENTATION); + + MetaRegistryUtil.clearRegistry(implementationsToClear) + } +} diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java similarity index 87% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java index ca700a5c596..295ca74b31e 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java @@ -19,10 +19,10 @@ package org.apache.tinkerpop.gremlin.groovy.engine; import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.junit.Test; import java.util.HashMap; @@ -38,12 +38,14 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class GremlinExecutorOverGraphTest extends AbstractGremlinTest { +public class GremlinExecutorOverGraphTest { private final BasicThreadFactory testingThreadFactory = new BasicThreadFactory.Builder().namingPattern("test-gremlin-executor-%d").build(); @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldAllowTraversalToIterateInDifferentThreadThanOriginallyEvaluatedWithAutoCommit() throws Exception { + final TinkerGraph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); + // this test sort of simulates Gremlin Server interaction where a Traversal is eval'd in one Thread, but // then iterated in another. note that Gremlin Server configures the script engine to auto-commit // after evaluation. this basically tests the state of the Gremlin Server GremlinExecutor when @@ -51,9 +53,9 @@ public void shouldAllowTraversalToIterateInDifferentThreadThanOriginallyEvaluate final ExecutorService evalExecutor = Executors.newSingleThreadExecutor(testingThreadFactory); final GremlinExecutor gremlinExecutor = GremlinExecutor.build() .afterSuccess(b -> { - final GraphTraversalSource g = (GraphTraversalSource) b.get("g"); - if (g.getGraph().features().graph().supportsTransactions()) - g.tx().commit(); + final GraphTraversalSource ig = (GraphTraversalSource) b.get("g"); + if (ig.getGraph().features().graph().supportsTransactions()) + ig.tx().commit(); }) .executorService(evalExecutor).create(); @@ -80,6 +82,9 @@ public void shouldAllowTraversalToIterateInDifferentThreadThanOriginallyEvaluate @Test @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldAllowTraversalToIterateInDifferentThreadThanOriginallyEvaluatedWithoutAutoCommit() throws Exception { + final TinkerGraph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); + // this test sort of simulates Gremlin Server interaction where a Traversal is eval'd in one Thread, but // then iterated in another. this basically tests the state of the Gremlin Server GremlinExecutor when // being used in session mode diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java similarity index 79% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java index 3ee130605f8..6018a488162 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java @@ -18,20 +18,22 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.TestHelper; import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.FileSandboxExtension; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.codehaus.groovy.control.MultipleCompilationErrorsException; -import org.hamcrest.MatcherAssert; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import javax.script.Bindings; - import java.io.File; import java.util.Arrays; @@ -45,12 +47,17 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class GremlinGroovyScriptEngineFileSandboxTest extends AbstractGremlinTest { +public class GremlinGroovyScriptEngineFileSandboxTest { + + private Graph graph; + private GraphTraversalSource g; + @Before public void setup() throws Exception { - super.setup(); + graph = TinkerFactory.createModern(); + g = graph.traversal(); if (System.getProperty(FileSandboxExtension.GREMLIN_SERVER_SANDBOX) == null) { - final File f = TestHelper.generateTempFileFromResource(graph.getClass(), GremlinGroovyScriptEngineFileSandboxTest.class, "sandbox.yaml", ".yaml"); + final File f = TestHelper.generateTempFileFromResource(TinkerGraph.class, GremlinGroovyScriptEngineFileSandboxTest.class, "sandbox.yaml", ".yaml"); System.setProperty(FileSandboxExtension.GREMLIN_SERVER_SANDBOX, f.getAbsolutePath()); } } @@ -112,9 +119,18 @@ public void shouldEvalOnGAsTheMethodIsWhiteListed() throws Exception { try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()", bindings)); - assertEquals(g.V(convertToVertexId("marko")).out("created").count().next(), engine.eval("g.V(marko).out(\"created\").count().next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(g.V(convertToVertexId(graph, "marko")).next(), engine.eval("g.V(marko).next()", bindings)); + assertEquals(g.V(convertToVertexId(graph, "marko")).out("created").count().next(), engine.eval("g.V(marko).out(\"created\").count().next()", bindings)); } } + + private Object convertToVertexId(final Graph graph, final String vertexName) { + return convertToVertex(graph, vertexName).id(); + } + + private Vertex convertToVertex(final Graph graph, final String vertexName) { + // all test graphs have "name" as a unique id which makes it easy to hardcode this...works for now + return graph.traversal().V().has("name", vertexName).next(); + } } diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java similarity index 88% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java index 1cb73fcbc0e..273be12657d 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineIntegrateTest.java @@ -18,9 +18,9 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.LoadGraphWith; -import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,18 +28,18 @@ import javax.script.Bindings; import javax.script.ScriptException; -import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN; import static org.junit.Assert.fail; /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class GremlinGroovyScriptEngineIntegrateTest extends AbstractGremlinTest { +public class GremlinGroovyScriptEngineIntegrateTest { private static final Logger logger = LoggerFactory.getLogger(GremlinGroovyScriptEngineIntegrateTest.class); @Test - @LoadGraphWith(MODERN) public void shouldNotBlowTheHeapParameterized() throws ScriptException { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); final String[] gremlins = new String[]{ @@ -55,7 +55,7 @@ public void shouldNotBlowTheHeapParameterized() throws ScriptException { for (int ix = 0; ix < 50001; ix++) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("xxx", graphProvider.convertId((ix % 4) + 1, Vertex.class)); + bindings.put("xxx", (ix % 4) + 1); engine.eval(gremlins[ix % 4], bindings); if (ix > 0 && ix % 5000 == 0) { diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java similarity index 80% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java index 17e1cf0aa57..84542e10caf 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java @@ -20,15 +20,18 @@ import groovy.lang.MissingPropertyException; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.FeatureRequirementSet; -import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider; +import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Direction; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.apache.tinkerpop.gremlin.util.config.YamlConfiguration; import org.junit.Assert; import org.junit.Test; @@ -54,16 +57,17 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class GremlinGroovyScriptEngineOverGraphTest extends AbstractGremlinTest { +public class GremlinGroovyScriptEngineOverGraphTest { @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldDoSomeGremlin() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final ScriptEngine engine = new GremlinGroovyScriptEngine(); final List list = new ArrayList(); final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); + bindings.put("marko", convertToVertexId(graph, "marko")); bindings.put("temp", list); assertEquals(list.size(), 0); engine.eval("g.V(marko).out().fill(temp)",bindings); @@ -71,8 +75,9 @@ public void shouldDoSomeGremlin() throws Exception { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldLoadImports() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final ScriptEngine engineNoImports = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); try { engineNoImports.eval("Vertex.class.getName()"); @@ -92,8 +97,9 @@ public void shouldLoadImports() throws Exception { @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldLoadStandardImportsAndThenAddToThem() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) new DefaultImportCustomizerProvider()); engine.put("g", g); assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()")); @@ -120,12 +126,13 @@ public void shouldLoadStandardImportsAndThenAddToThem() throws Exception { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.CLASSIC) public void shouldProperlyHandleBindings() throws Exception { + final Graph graph = TinkerFactory.createClassic(); + final GraphTraversalSource g = graph.traversal(); final ScriptEngine engine = new GremlinGroovyScriptEngine(); engine.put("g", g); - engine.put("marko", convertToVertexId("marko")); - Assert.assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()")); + engine.put("marko", convertToVertexId(graph, "marko")); + Assert.assertEquals(g.V(convertToVertexId(graph, "marko")).next(), engine.eval("g.V(marko).next()")); final Bindings bindings = engine.createBindings(); bindings.put("g", g); @@ -136,27 +143,28 @@ public void shouldProperlyHandleBindings() throws Exception { bindings.put("l", 100l); bindings.put("d", 1.55555d); - assertEquals(engine.eval("g.E().has('weight',f).next()", bindings), g.E(convertToEdgeId("marko", "knows", "vadas")).next()); - assertEquals(engine.eval("g.V().has('name',s).next()", bindings), g.V(convertToVertexId("marko")).next()); - assertEquals(engine.eval("g.V().sideEffect{it.get().property('bbb',it.get().value('name')=='marko')}.iterate();g.V().has('bbb',b).next()", bindings), g.V(convertToVertexId("marko")).next()); - assertEquals(engine.eval("g.V().sideEffect{it.get().property('iii',it.get().value('name')=='marko'?1:0)}.iterate();g.V().has('iii',i).next()", bindings), g.V(convertToVertexId("marko")).next()); - assertEquals(engine.eval("g.V().sideEffect{it.get().property('lll',it.get().value('name')=='marko'?100l:0l)}.iterate();g.V().has('lll',l).next()", bindings), g.V(convertToVertexId("marko")).next()); - assertEquals(engine.eval("g.V().sideEffect{it.get().property('ddd',it.get().value('name')=='marko'?1.55555d:0)}.iterate();g.V().has('ddd',d).next()", bindings), g.V(convertToVertexId("marko")).next()); + assertEquals(engine.eval("g.E().has('weight',f).next()", bindings), g.E(convertToEdgeId(graph, "marko", "knows", "vadas")).next()); + assertEquals(engine.eval("g.V().has('name',s).next()", bindings), g.V(convertToVertexId(graph, "marko")).next()); + assertEquals(engine.eval("g.V().sideEffect{it.get().property('bbb',it.get().value('name')=='marko')}.iterate();g.V().has('bbb',b).next()", bindings), g.V(convertToVertexId(graph, "marko")).next()); + assertEquals(engine.eval("g.V().sideEffect{it.get().property('iii',it.get().value('name')=='marko'?1:0)}.iterate();g.V().has('iii',i).next()", bindings), g.V(convertToVertexId(graph, "marko")).next()); + assertEquals(engine.eval("g.V().sideEffect{it.get().property('lll',it.get().value('name')=='marko'?100l:0l)}.iterate();g.V().has('lll',l).next()", bindings), g.V(convertToVertexId(graph, "marko")).next()); + assertEquals(engine.eval("g.V().sideEffect{it.get().property('ddd',it.get().value('name')=='marko'?1.55555d:0)}.iterate();g.V().has('ddd',d).next()", bindings), g.V(convertToVertexId(graph, "marko")).next()); } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldClearBindingsBetweenEvals() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final ScriptEngine engine = new GremlinGroovyScriptEngine(); engine.put("g", g); - engine.put("marko", convertToVertexId("marko")); - assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()")); + engine.put("marko", convertToVertexId(graph, "marko")); + assertEquals(g.V(convertToVertexId(graph, "marko")).next(), engine.eval("g.V(marko).next()")); final Bindings bindings = engine.createBindings(); bindings.put("g", g); bindings.put("s", "marko"); - assertEquals(engine.eval("g.V().has('name',s).next()", bindings), g.V(convertToVertexId("marko")).next()); + assertEquals(engine.eval("g.V().has('name',s).next()", bindings), g.V(convertToVertexId(graph, "marko")).next()); try { engine.eval("g.V().has('name',s).next()"); @@ -170,8 +178,9 @@ public void shouldClearBindingsBetweenEvals() throws Exception { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldBeThreadSafe() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final ScriptEngine engine = new GremlinGroovyScriptEngine(); int runs = 500; @@ -206,8 +215,9 @@ public void run() { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldBeThreadSafeOnCompiledScript() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); final CompiledScript script = engine.compile("t = g.V().has('name',name); if(t.hasNext()) { t } else { null }"); @@ -244,14 +254,15 @@ public void run() { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldEvalGlobalClosuresEvenAfterEvictionOfClass() throws ScriptException { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); - bindings.put("vadas", convertToVertexId("vadas")); + bindings.put("marko", convertToVertexId(graph, "marko")); + bindings.put("vadas", convertToVertexId(graph, "vadas")); // strong referenced global closure engine.eval("def isVadas(v){v.value('name')=='vadas'}", bindings); @@ -285,18 +296,19 @@ public void shouldEvalGlobalClosuresEvenAfterEvictionOfClass() throws ScriptExce } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldAllowFunctionsUsedInClosure() throws ScriptException { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); final Bindings bindings = engine.createBindings(); bindings.put("g", g); bindings.put("#jsr223.groovy.engine.keep.globals", "phantom"); - bindings.put("vadas", convertToVertexId("vadas")); + bindings.put("vadas", convertToVertexId(graph, "vadas")); // this works on its own when the function and the line that uses it is in one "script". this is the // current workaround - assertEquals(g.V(convertToVertexId("vadas")).next(), engine.eval("def isVadas(v){v.value('name')=='vadas'};g.V().filter{isVadas(it.get())}.next()", bindings)); + assertEquals(g.V(convertToVertexId(graph, "vadas")).next(), engine.eval("def isVadas(v){v.value('name')=='vadas'};g.V().filter{isVadas(it.get())}.next()", bindings)); // let's reset this piece and make sure isVadas is not hanging around. engine.reset(); @@ -319,18 +331,19 @@ public void shouldAllowFunctionsUsedInClosure() throws ScriptException { assertEquals(true, engine.eval("isVadas(g.V(vadas).next())", bindings)); // make sure the function works in a closure...this generates a StackOverflowError - assertEquals(g.V(convertToVertexId("vadas")).next(), engine.eval("g.V().filter{isVadas(it.get())}.next()", bindings)); + assertEquals(g.V(convertToVertexId(graph, "vadas")).next(), engine.eval("g.V().filter{isVadas(it.get())}.next()", bindings)); } @Test @org.junit.Ignore - @LoadGraphWith(LoadGraphWith.GraphData.CLASSIC) public void shouldAllowUseOfClasses() throws ScriptException { + final Graph graph = TinkerFactory.createClassic(); + final GraphTraversalSource g = graph.traversal(); GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("vadas", convertToVertexId("vadas")); + bindings.put("vadas", convertToVertexId(graph, "vadas")); // works when it's all defined together assertEquals(true, engine.eval("class c { static def isVadas(v){v.value('name')=='vadas'}};c.isVadas(g.V(vadas).next())", bindings)); @@ -363,8 +376,9 @@ public void shouldAllowUseOfClasses() throws ScriptException { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldProcessUTF8Query() throws Exception { + final Graph graph = TinkerGraph.open(); + final GraphTraversalSource g = graph.traversal(); final Vertex nonUtf8 = graph.addVertex("name", "marko", "age", 29); final Vertex utf8Name = graph.addVertex("name", "轉注", "age", 32); @@ -376,4 +390,17 @@ public void shouldProcessUTF8Query() throws Exception { eval = (Traversal) engine.eval("g.V().has('name','轉注')"); assertEquals(utf8Name, eval.next()); } + + private Object convertToVertexId(final Graph graph, final String vertexName) { + return convertToVertex(graph, vertexName).id(); + } + + private Vertex convertToVertex(final Graph graph, final String vertexName) { + // all test graphs have "name" as a unique id which makes it easy to hardcode this...works for now + return graph.traversal().V().has("name", vertexName).next(); + } + + private Object convertToEdgeId(final Graph graph, final String outVertexName, String edgeLabel, final String inVertexName) { + return graph.traversal().V().has("name", outVertexName).outE(edgeLabel).as("e").inV().has("name", inVertexName).select("e").next().id(); + } } diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java similarity index 66% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java index b9fd1be5bcf..349fcd5dccf 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java @@ -18,19 +18,21 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; +import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.codehaus.groovy.control.MultipleCompilationErrorsException; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import javax.script.Bindings; - import java.util.Arrays; import static org.hamcrest.Matchers.containsString; @@ -42,7 +44,7 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ @RunWith(Parameterized.class) -public class GremlinGroovyScriptEngineSandboxedStandardTest extends AbstractGremlinTest { +public class GremlinGroovyScriptEngineSandboxedStandardTest { @Parameterized.Parameters(name = "{0}") public static Iterable data() { return Arrays.asList(new Object[][]{ @@ -60,19 +62,20 @@ public static Iterable data() { public CompilerCustomizerProvider sandboxed; @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldEvalGraphTraversalSource() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine()) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(g.V(convertToVertexId(graph, "marko")).next(), engine.eval("g.V(marko).next()", bindings)); } try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(notSandboxed)) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); + bindings.put("marko", convertToVertexId(graph, "marko")); engine.eval("g.V(marko).next()", bindings); fail("Type checking should have forced an error as 'g' is not defined"); } catch (Exception ex) { @@ -83,27 +86,28 @@ public void shouldEvalGraphTraversalSource() throws Exception { try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(sandboxed)) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()", bindings)); - assertEquals(g.V(convertToVertexId("marko")).out("created").count().next(), engine.eval("g.V(marko).out(\"created\").count().next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(g.V(convertToVertexId(graph, "marko")).next(), engine.eval("g.V(marko).next()", bindings)); + assertEquals(g.V(convertToVertexId(graph, "marko")).out("created").count().next(), engine.eval("g.V(marko).out(\"created\").count().next()", bindings)); } } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldEvalGraph() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine()) { final Bindings bindings = engine.createBindings(); bindings.put("graph", graph); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(graph.vertices(convertToVertexId("marko")).next(), engine.eval("graph.vertices(marko).next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(marko).next()", bindings)); } try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(notSandboxed)) { final Bindings bindings = engine.createBindings(); bindings.put("graph", graph); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(graph.vertices(convertToVertexId("marko")).next(), engine.eval("graph.vertices(marko).next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(marko).next()", bindings)); fail("Type checking should have forced an error as 'graph' is not defined"); } catch (Exception ex) { assertEquals(MultipleCompilationErrorsException.class, ex.getCause().getClass()); @@ -113,8 +117,8 @@ public void shouldEvalGraph() throws Exception { try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(notSandboxed)) { final Bindings bindings = engine.createBindings(); bindings.put("graph", graph); - bindings.put("x", convertToVertexId("marko")); - assertEquals(graph.vertices(convertToVertexId("marko")).next(), engine.eval("graph.vertices(x).next()", bindings)); + bindings.put("x", convertToVertexId(graph, "marko")); + assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(x).next()", bindings)); fail("Type checking should have forced an error as 'graph' is not defined"); } catch (Exception ex) { assertEquals(MultipleCompilationErrorsException.class, ex.getCause().getClass()); @@ -124,15 +128,24 @@ public void shouldEvalGraph() throws Exception { try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(sandboxed)) { final Bindings bindings = engine.createBindings(); bindings.put("graph", graph); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(graph.vertices(convertToVertexId("marko")).next(), engine.eval("graph.vertices(marko).next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(marko).next()", bindings)); } try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(sandboxed)) { final Bindings bindings = engine.createBindings(); bindings.put("graph", graph); - bindings.put("x", convertToVertexId("marko")); - assertEquals(graph.vertices(convertToVertexId("marko")).next(), engine.eval("graph.vertices(x).next()", bindings)); + bindings.put("x", convertToVertexId(graph, "marko")); + assertEquals(graph.vertices(convertToVertexId(graph, "marko")).next(), engine.eval("graph.vertices(x).next()", bindings)); } } + + private Object convertToVertexId(final Graph graph, final String vertexName) { + return convertToVertex(graph, vertexName).id(); + } + + private Vertex convertToVertex(final Graph graph, final String vertexName) { + // all test graphs have "name" as a unique id which makes it easy to hardcode this...works for now + return graph.traversal().V().has("name", vertexName).next(); + } } diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java similarity index 67% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java index 5adca8ca1b5..0ff2706213d 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java @@ -18,11 +18,14 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; +import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TinkerPopSandboxExtension; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.codehaus.groovy.control.MultipleCompilationErrorsException; import org.junit.Test; @@ -36,7 +39,7 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class GremlinGroovyScriptEngineTinkerPopSandboxTest extends AbstractGremlinTest { +public class GremlinGroovyScriptEngineTinkerPopSandboxTest { @Test public void shouldNotEvalAsTheMethodIsNotWhiteListed() throws Exception { final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(TinkerPopSandboxExtension.class.getName()); @@ -50,15 +53,25 @@ public void shouldNotEvalAsTheMethodIsNotWhiteListed() throws Exception { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldEvalOnGAsTheMethodIsWhiteListed() throws Exception { + final Graph graph = TinkerFactory.createModern(); + final GraphTraversalSource g = graph.traversal(); final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(TinkerPopSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); - bindings.put("marko", convertToVertexId("marko")); - assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()", bindings)); - assertEquals(g.V(convertToVertexId("marko")).out("created").count().next(), engine.eval("g.V(marko).out(\"created\").count().next()", bindings)); + bindings.put("marko", convertToVertexId(graph, "marko")); + assertEquals(g.V(convertToVertexId(graph, "marko")).next(), engine.eval("g.V(marko).next()", bindings)); + assertEquals(g.V(convertToVertexId(graph, "marko")).out("created").count().next(), engine.eval("g.V(marko).out(\"created\").count().next()", bindings)); } } + + private Object convertToVertexId(final Graph graph, final String vertexName) { + return convertToVertex(graph, vertexName).id(); + } + + private Vertex convertToVertex(final Graph graph, final String vertexName) { + // all test graphs have "name" as a unique id which makes it easy to hardcode this...works for now + return graph.traversal().V().has("name", vertexName).next(); + } } diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyScriptEngineSetup.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyScriptEngineSetup.java new file mode 100644 index 00000000000..a9ef68edb37 --- /dev/null +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyScriptEngineSetup.java @@ -0,0 +1,69 @@ +/* + * 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.groovy.jsr223; + +import org.apache.tinkerpop.gremlin.jsr223.CoreImports; +import org.apache.tinkerpop.gremlin.jsr223.ScriptEngineCache; + +import javax.script.ScriptEngine; +import javax.script.ScriptException; +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class GroovyScriptEngineSetup { + + private GroovyScriptEngineSetup() { + } + + public static void setup() { + setup(ScriptEngineCache.get("groovy")); + } + + public static ScriptEngine setup(final ScriptEngine groovyScriptEngine) { + try { + for (Class c : CoreImports.getClassImports()) { + groovyScriptEngine.eval("import " + c.getName()); + } + + final Set> staticImports = new HashSet<>(); + + for (Enum e : CoreImports.getEnumImports()) { + staticImports.add(e.getDeclaringClass()); + } + + for (Method m : CoreImports.getMethodImports()) { + staticImports.add(m.getDeclaringClass()); + } + + for (Class c : staticImports) { + groovyScriptEngine.eval("import static " + c.getName() + ".*"); + } + + return groovyScriptEngine; + } catch (final ScriptException ex) { + throw new IllegalStateException(ex.getMessage(), ex); + } + } +} diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorComputerProvider.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorComputerProvider.java similarity index 89% rename from tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorComputerProvider.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorComputerProvider.java index a12210ad3ef..c24021cce31 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorComputerProvider.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorComputerProvider.java @@ -16,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -package org.apache.tinkerpop.gremlin.tinkergraph.process.jsr223; +package org.apache.tinkerpop.gremlin.groovy.jsr223; import org.apache.tinkerpop.gremlin.GraphProvider; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; @@ -28,10 +27,10 @@ * @author Marko A. Rodriguez (http://markorodriguez.com) */ @GraphProvider.Descriptor(computer = TinkerGraphComputer.class) -public class TinkerGraphJavaTranslatorComputerProvider extends TinkerGraphJavaTranslatorProvider { +public class GroovyTranslatorComputerProvider extends GroovyTranslatorProvider { @Override public GraphTraversalSource traversal(final Graph graph) { return super.traversal(graph).withComputer(); } -} +} \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessComputerTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessComputerTest.java similarity index 83% rename from tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessComputerTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessComputerTest.java index 08ba513ff8f..7d092371c54 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessComputerTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessComputerTest.java @@ -16,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -package org.apache.tinkerpop.gremlin.tinkergraph.process.jsr223; +package org.apache.tinkerpop.gremlin.groovy.jsr223; import org.apache.tinkerpop.gremlin.GraphProviderClass; import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite; @@ -28,6 +27,6 @@ * @author Marko A. Rodriguez (http://markorodriguez.com) */ @RunWith(ProcessComputerSuite.class) -@GraphProviderClass(provider = TinkerGraphJavaTranslatorComputerProvider.class, graph = TinkerGraph.class) -public class TinkerGraphJavaTranslatorProcessComputerTest { -} +@GraphProviderClass(provider = GroovyTranslatorComputerProvider.class, graph = TinkerGraph.class) +public class GroovyTranslatorProcessComputerTest { +} \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessStandardTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessStandardTest.java similarity index 83% rename from tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessStandardTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessStandardTest.java index c01718215fc..8794fa025d0 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProcessStandardTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProcessStandardTest.java @@ -16,8 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - -package org.apache.tinkerpop.gremlin.tinkergraph.process.jsr223; +package org.apache.tinkerpop.gremlin.groovy.jsr223; import org.apache.tinkerpop.gremlin.GraphProviderClass; import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite; @@ -28,6 +27,6 @@ * @author Marko A. Rodriguez (http://markorodriguez.com) */ @RunWith(ProcessStandardSuite.class) -@GraphProviderClass(provider = TinkerGraphJavaTranslatorProvider.class, graph = TinkerGraph.class) -public class TinkerGraphJavaTranslatorProcessStandardTest { -} +@GraphProviderClass(provider = GroovyTranslatorProvider.class, graph = TinkerGraph.class) +public class GroovyTranslatorProcessStandardTest { +} \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java similarity index 88% rename from tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java index f7e8cc48360..c56e7069049 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProvider.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorProvider.java @@ -16,23 +16,19 @@ * specific language governing permissions and limitations * under the License. */ - -package org.apache.tinkerpop.gremlin.tinkergraph.process.groovy.jsr223; +package org.apache.tinkerpop.gremlin.groovy.jsr223; import org.apache.tinkerpop.gremlin.LoadGraphWith; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator; import org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest; import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest; import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest; import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest; import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest; import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy; import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider; +import org.apache.tinkerpop.gremlin.util.TinkerGraphProvider; import java.util.Arrays; import java.util.HashSet; @@ -42,7 +38,7 @@ /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class TinkerGraphGroovyTranslatorProvider extends TinkerGraphProvider { +public class GroovyTranslatorProvider extends TinkerGraphProvider { private static Set SKIP_TESTS = new HashSet<>(Arrays.asList( "testProfileStrategyCallback", diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java similarity index 94% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java index 59903ac8d72..654cb00b4ad 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java @@ -27,18 +27,18 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy; import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.apache.tinkerpop.gremlin.util.function.Lambda; import org.junit.Test; import javax.script.Bindings; import javax.script.SimpleBindings; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -48,11 +48,11 @@ /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class GroovyTranslatorTest extends AbstractGremlinTest { +public class GroovyTranslatorTest { @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldHandleStrategies() throws Exception { + final TinkerGraph graph = TinkerFactory.createModern(); GraphTraversalSource g = graph.traversal(); g = g.withStrategies(SubgraphStrategy.create(new MapConfiguration(new HashMap() {{ put(SubgraphStrategy.VERTICES, __.has("name", "marko")); @@ -75,8 +75,8 @@ public void shouldHandleStrategies() throws Exception { } @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldSupportStringSupplierLambdas() throws Exception { + final TinkerGraph graph = TinkerFactory.createModern(); GraphTraversalSource g = graph.traversal(); g = g.withStrategies(new TranslationStrategy(g, GroovyTranslator.of("g"))); GraphTraversal.Admin t = g.withSideEffect("lengthSum", 0).withSack(1) diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java similarity index 83% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java index e3a713d63b6..3fef17e71e8 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java @@ -18,11 +18,9 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.FeatureRequirement; -import org.apache.tinkerpop.gremlin.FeatureRequirementSet; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -37,11 +35,11 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class CredentialGraphTest extends AbstractGremlinTest { +public class CredentialGraphTest { @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldCreateUser() { + final Graph graph = TinkerGraph.open(); final Vertex v = credentials(graph).createUser("stephen", "secret"); assertEquals("stephen", v.value("username")); assertEquals("user", v.label()); @@ -50,9 +48,8 @@ public void shouldCreateUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) - @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES) public void shouldRemoveUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("stephen", "secret"); MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); @@ -62,8 +59,8 @@ public void shouldRemoveUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldNotRemoveUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("stephen", "secret"); MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); @@ -73,8 +70,8 @@ public void shouldNotRemoveUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldFindUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("marko", "secret"); final Vertex stephen = credentials(graph).createUser("stephen", "secret"); @@ -85,8 +82,8 @@ public void shouldFindUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldNotFindUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("marko", "secret"); credentials(graph).createUser("stephen", "secret"); @@ -97,8 +94,8 @@ public void shouldNotFindUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldCountUsers() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("marko", "secret"); credentials(graph).createUser("stephen", "secret"); @@ -109,8 +106,8 @@ public void shouldCountUsers() { } @Test(expected = IllegalStateException.class) - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldThrowIfFindingMultipleUsers() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("stephen", "secret"); credentials(graph).createUser("stephen", "secret"); diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java similarity index 82% rename from gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java index 7cdf329e62b..0ea9b2b78c7 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java @@ -16,13 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential; +package org.apache.tinkerpop.gremlin.plugin.dsl.credential; -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.FeatureRequirement; -import org.apache.tinkerpop.gremlin.FeatureRequirementSet; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -37,11 +35,11 @@ /** * @author Stephen Mallette (http://stephen.genoprime.com) */ -public class CredentialGraphTest extends AbstractGremlinTest { +public class CredentialGraphTest { @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldCreateUser() { + final Graph graph = TinkerGraph.open(); final Vertex v = credentials(graph).createUser("stephen", "secret"); assertEquals("stephen", v.value("username")); assertEquals("user", v.label()); @@ -50,9 +48,8 @@ public void shouldCreateUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) - @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES) public void shouldRemoveUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("stephen", "secret"); MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); @@ -62,8 +59,8 @@ public void shouldRemoveUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldNotRemoveUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("stephen", "secret"); MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); @@ -73,8 +70,8 @@ public void shouldNotRemoveUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldFindUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("marko", "secret"); final Vertex stephen = credentials(graph).createUser("stephen", "secret"); @@ -85,8 +82,8 @@ public void shouldFindUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldNotFindUser() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("marko", "secret"); credentials(graph).createUser("stephen", "secret"); @@ -97,8 +94,8 @@ public void shouldNotFindUser() { } @Test - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldCountUsers() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("marko", "secret"); credentials(graph).createUser("stephen", "secret"); @@ -109,8 +106,8 @@ public void shouldCountUsers() { } @Test(expected = IllegalStateException.class) - @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) public void shouldThrowIfFindingMultipleUsers() { + final Graph graph = TinkerGraph.open(); MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); credentials(graph).createUser("stephen", "secret"); credentials(graph).createUser("stephen", "secret"); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java new file mode 100644 index 00000000000..c71a31b327c --- /dev/null +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/util/TinkerGraphProvider.java @@ -0,0 +1,206 @@ +/* + * 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.util; + +import org.apache.commons.configuration.Configuration; +import org.apache.tinkerpop.gremlin.AbstractGraphProvider; +import org.apache.tinkerpop.gremlin.LoadGraphWith; +import org.apache.tinkerpop.gremlin.TestHelper; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.GraphTest; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; +import org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest; +import org.apache.tinkerpop.gremlin.structure.io.IoVertexTest; +import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest; +import org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerEdge; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerElement; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraphVariables; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty; + +import java.io.File; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class TinkerGraphProvider extends AbstractGraphProvider { + + private static final Set IMPLEMENTATION = new HashSet() {{ + add(TinkerEdge.class); + add(TinkerElement.class); + add(TinkerGraph.class); + add(TinkerGraphVariables.class); + add(TinkerProperty.class); + add(TinkerVertex.class); + add(TinkerVertexProperty.class); + }}; + + @Override + public Map getBaseConfiguration(final String graphName, final Class test, final String testMethodName, + final LoadGraphWith.GraphData loadGraphWith) { + final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith); + final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromTest(test, testMethodName) : idManager).name(); + return new HashMap() {{ + put(Graph.GRAPH, TinkerGraph.class.getName()); + put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker); + put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker); + put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker); + if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName)) + put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); + if (requiresPersistence(test, testMethodName)) { + put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo"); + final File tempDir = TestHelper.makeTestDataPath(test, "temp"); + put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, + tempDir.getAbsolutePath() + File.separator + testMethodName + ".kryo"); + } + }}; + } + + @Override + public void clear(final Graph graph, final Configuration configuration) throws Exception { + if (graph != null) + graph.close(); + + // in the even the graph is persisted we need to clean up + final String graphLocation = configuration.getString(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null); + if (graphLocation != null) { + final File f = new File(graphLocation); + f.delete(); + } + } + + @Override + public Set getImplementations() { + return IMPLEMENTATION; + } + + /** + * Determines if a test requires TinkerGraph persistence to be configured with graph location and format. + */ + protected static boolean requiresPersistence(final Class test, final String testMethodName) { + return test == GraphTest.class && testMethodName.equals("shouldPersistDataOnClose"); + } + + /** + * Determines if a test requires a different cardinality as the default or not. + */ + protected static boolean requiresListCardinalityAsDefault(final LoadGraphWith.GraphData loadGraphWith, + final Class test, final String testMethodName) { + return loadGraphWith == LoadGraphWith.GraphData.CREW + || (test == StarGraphTest.class && testMethodName.equals("shouldAttachWithCreateMethod")) + || (test == DetachedGraphTest.class && testMethodName.equals("testAttachableCreateMethod")); + } + + /** + * Some tests require special configuration for TinkerGraph to properly configure the id manager. + */ + protected TinkerGraph.DefaultIdManager selectIdMakerFromTest(final Class test, final String testMethodName) { + if (test.equals(GraphTest.class)) { + final Set testsThatNeedLongIdManager = new HashSet(){{ + add("shouldIterateVerticesWithNumericIdSupportUsingDoubleRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingDoubleRepresentations"); + add("shouldIterateVerticesWithNumericIdSupportUsingIntegerRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingIntegerRepresentations"); + add("shouldIterateVerticesWithNumericIdSupportUsingFloatRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingFloatRepresentations"); + add("shouldIterateVerticesWithNumericIdSupportUsingStringRepresentation"); + add("shouldIterateVerticesWithNumericIdSupportUsingStringRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingDoubleRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingDoubleRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingIntegerRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingIntegerRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingFloatRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingFloatRepresentations"); + add("shouldIterateEdgesWithNumericIdSupportUsingStringRepresentation"); + add("shouldIterateEdgesWithNumericIdSupportUsingStringRepresentations"); + }}; + + final Set testsThatNeedUuidIdManager = new HashSet(){{ + add("shouldIterateVerticesWithUuidIdSupportUsingStringRepresentation"); + add("shouldIterateVerticesWithUuidIdSupportUsingStringRepresentations"); + add("shouldIterateEdgesWithUuidIdSupportUsingStringRepresentation"); + add("shouldIterateEdgesWithUuidIdSupportUsingStringRepresentations"); + }}; + + if (testsThatNeedLongIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.LONG; + else if (testsThatNeedUuidIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.UUID; + } else if (test.equals(IoEdgeTest.class)) { + final Set testsThatNeedLongIdManager = new HashSet(){{ + add("shouldReadWriteEdge[graphson-v1]"); + add("shouldReadWriteDetachedEdgeAsReference[graphson-v1]"); + add("shouldReadWriteDetachedEdge[graphson-v1]"); + add("shouldReadWriteEdge[graphson-v2]"); + add("shouldReadWriteDetachedEdgeAsReference[graphson-v2]"); + add("shouldReadWriteDetachedEdge[graphson-v2]"); + }}; + + if (testsThatNeedLongIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.LONG; + } else if (test.equals(IoVertexTest.class)) { + final Set testsThatNeedLongIdManager = new HashSet(){{ + add("shouldReadWriteVertexWithBOTHEdges[graphson-v1]"); + add("shouldReadWriteVertexWithINEdges[graphson-v1]"); + add("shouldReadWriteVertexWithOUTEdges[graphson-v1]"); + add("shouldReadWriteVertexNoEdges[graphson-v1]"); + add("shouldReadWriteDetachedVertexNoEdges[graphson-v1]"); + add("shouldReadWriteDetachedVertexAsReferenceNoEdges[graphson-v1]"); + add("shouldReadWriteVertexMultiPropsNoEdges[graphson-v1]"); + add("shouldReadWriteVertexWithBOTHEdges[graphson-v2]"); + add("shouldReadWriteVertexWithINEdges[graphson-v2]"); + add("shouldReadWriteVertexWithOUTEdges[graphson-v2]"); + add("shouldReadWriteVertexNoEdges[graphson-v2]"); + add("shouldReadWriteDetachedVertexNoEdges[graphson-v2]"); + add("shouldReadWriteDetachedVertexAsReferenceNoEdges[graphson-v2]"); + add("shouldReadWriteVertexMultiPropsNoEdges[graphson-v2]"); + }}; + + if (testsThatNeedLongIdManager.contains(testMethodName)) + return TinkerGraph.DefaultIdManager.LONG; + } + + return TinkerGraph.DefaultIdManager.ANY; + } + + /** + * Test that load with specific graph data can be configured with a specific id manager as the data type to + * be used in the test for that graph is known. + */ + protected TinkerGraph.DefaultIdManager selectIdMakerFromGraphData(final LoadGraphWith.GraphData loadGraphWith) { + if (null == loadGraphWith) return TinkerGraph.DefaultIdManager.ANY; + if (loadGraphWith.equals(LoadGraphWith.GraphData.CLASSIC)) + return TinkerGraph.DefaultIdManager.INTEGER; + else if (loadGraphWith.equals(LoadGraphWith.GraphData.MODERN)) + return TinkerGraph.DefaultIdManager.INTEGER; + else if (loadGraphWith.equals(LoadGraphWith.GraphData.CREW)) + return TinkerGraph.DefaultIdManager.INTEGER; + else if (loadGraphWith.equals(LoadGraphWith.GraphData.GRATEFUL)) + return TinkerGraph.DefaultIdManager.INTEGER; + else + throw new IllegalStateException(String.format("Need to define a new %s for %s", TinkerGraph.IdManager.class.getName(), loadGraphWith.name())); + } +} diff --git a/gremlin-groovy-test/src/main/resources/org/apache/tinkerpop/gremlin/groovy/jsr223/sandbox.yaml b/gremlin-groovy/src/test/resources/org/apache/tinkerpop/gremlin/groovy/jsr223/sandbox.yaml similarity index 100% rename from gremlin-groovy-test/src/main/resources/org/apache/tinkerpop/gremlin/groovy/jsr223/sandbox.yaml rename to gremlin-groovy/src/test/resources/org/apache/tinkerpop/gremlin/groovy/jsr223/sandbox.yaml diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml index 5c8ffaa04f5..f3dd338b9db 100644 --- a/gremlin-python/pom.xml +++ b/gremlin-python/pom.xml @@ -488,7 +488,7 @@ if (${skipTests}) return log.info("Starting Gremlin Server instances for native testing of gremlin-python") def settings = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern-py.yaml") settings.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties" -settings.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] +settings.scriptEngines["gremlin-groovy"].plugins["org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin"].files = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] settings.port = 45940 def server = new GremlinServer(settings) @@ -499,7 +499,7 @@ log.info("Gremlin Server with no authentication started on port 45940") def settingsSecure = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern-py.yaml") settingsSecure.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties" -settingsSecure.scriptEngines["gremlin-groovy"].scripts = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] +settings.scriptEngines["gremlin-groovy"].plugins["org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin"].files = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] settingsSecure.port = 45941 settingsSecure.authentication.className = "org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator" settingsSecure.authentication.config = [credentialsDb: "${gremlin.server.dir}/conf/tinkergraph-credentials.properties"] diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java index 30a507e6b61..4a6dc4de8be 100644 --- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java +++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonProvider.java @@ -88,7 +88,6 @@ public class PythonProvider extends AbstractGraphProvider { @Override public Map getBaseConfiguration(final String graphName, final Class test, final String testMethodName, final LoadGraphWith.GraphData loadGraphWith) { - final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith); final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromGraphData(loadGraphWith) : idManager).name(); return new HashMap() {{ @@ -151,5 +150,4 @@ public GraphTraversalSource traversal(final Graph graph) { return g.withStrategies(new TranslationStrategy(g, new PythonGraphSONJavaTranslator<>(PythonTranslator.of("g", IMPORT_STATICS), JavaTranslator.of(g)))); } } - } diff --git a/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml b/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml index fe32c6ed18b..c846cf48c51 100644 --- a/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml +++ b/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml @@ -30,13 +30,13 @@ port: 45940 scriptEvaluationTimeout: 30000 graphs: { graph: src/test/resources/org/apache/tinkerpop/gremlin/python/driver/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { imports: [java.lang.Math], staticImports: [java.lang.Math.PI], - scripts: [src/test/resources/org/apache/tinkerpop/gremlin/python/driver/generate-modern.groovy]}, + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [src/test/resources/org/apache/tinkerpop/gremlin/python/driver/generate-modern.groovy]}}}, gremlin-jython: {}, gremlin-python: {} } diff --git a/gremlin-server/conf/gremlin-server-classic.yaml b/gremlin-server/conf/gremlin-server-classic.yaml index ed256b51a3f..00d304f821f 100644 --- a/gremlin-server/conf/gremlin-server-classic.yaml +++ b/gremlin-server/conf/gremlin-server-classic.yaml @@ -20,13 +20,12 @@ port: 8182 scriptEvaluationTimeout: 30000 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-classic.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-classic.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/conf/gremlin-server-min.yaml b/gremlin-server/conf/gremlin-server-min.yaml index 9ce6b5ee088..2b8738cff87 100644 --- a/gremlin-server/conf/gremlin-server-min.yaml +++ b/gremlin-server/conf/gremlin-server-min.yaml @@ -19,7 +19,5 @@ host: localhost port: 8182 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph metrics: { slf4jReporter: {enabled: true, interval: 180000}} diff --git a/gremlin-server/conf/gremlin-server-modern-py.yaml b/gremlin-server/conf/gremlin-server-modern-py.yaml index d030832f73c..1e2491445f9 100644 --- a/gremlin-server/conf/gremlin-server-modern-py.yaml +++ b/gremlin-server/conf/gremlin-server-modern-py.yaml @@ -32,13 +32,12 @@ gremlinPool: 8 scriptEvaluationTimeout: 30000 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-modern.groovy]}, + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-modern.groovy]}}}, gremlin-jython: {}, gremlin-python: {} } diff --git a/gremlin-server/conf/gremlin-server-modern-readonly.yaml b/gremlin-server/conf/gremlin-server-modern-readonly.yaml index d4ff8d43ac3..7750ad3090f 100644 --- a/gremlin-server/conf/gremlin-server-modern-readonly.yaml +++ b/gremlin-server/conf/gremlin-server-modern-readonly.yaml @@ -20,13 +20,12 @@ port: 8182 scriptEvaluationTimeout: 30000 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-modern-readonly.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-modern-readonly.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/conf/gremlin-server-modern.yaml b/gremlin-server/conf/gremlin-server-modern.yaml index 08096f65d77..5d0a67d2076 100644 --- a/gremlin-server/conf/gremlin-server-modern.yaml +++ b/gremlin-server/conf/gremlin-server-modern.yaml @@ -20,13 +20,12 @@ port: 8182 scriptEvaluationTimeout: 30000 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-modern.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-modern.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/conf/gremlin-server-neo4j.yaml b/gremlin-server/conf/gremlin-server-neo4j.yaml index 1d4003e85f1..0ca8b9c24d5 100644 --- a/gremlin-server/conf/gremlin-server-neo4j.yaml +++ b/gremlin-server/conf/gremlin-server-neo4j.yaml @@ -31,13 +31,12 @@ scriptEvaluationTimeout: 30000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer graphs: { graph: conf/neo4j-empty.properties} -plugins: - - tinkerpop.neo4j scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.neo4j.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/conf/gremlin-server-rest-modern.yaml b/gremlin-server/conf/gremlin-server-rest-modern.yaml index e39e497b90e..a2d4327ed18 100644 --- a/gremlin-server/conf/gremlin-server-rest-modern.yaml +++ b/gremlin-server/conf/gremlin-server-rest-modern.yaml @@ -21,13 +21,12 @@ scriptEvaluationTimeout: 30000 channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-modern.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-modern.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} # application/vnd.gremlin-v1.0+json - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }} # application/vnd.gremlin-v2.0+json diff --git a/gremlin-server/conf/gremlin-server-rest-secure.yaml b/gremlin-server/conf/gremlin-server-rest-secure.yaml index e3d9330d494..6aa4de79a1c 100644 --- a/gremlin-server/conf/gremlin-server-rest-secure.yaml +++ b/gremlin-server/conf/gremlin-server-rest-secure.yaml @@ -29,18 +29,13 @@ scriptEvaluationTimeout: 30000 channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample-secure.groovy], - config: { - compilerCustomizerProviders: { - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider":[], - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000], - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {enableThreadInterrupt: true, timedInterrupt: 10000, compilation: COMPILE_STATIC, extensions: org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample-secure.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} # application/vnd.gremlin-v1.0+json - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }} # application/vnd.gremlin-v2.0+json diff --git a/gremlin-server/conf/gremlin-server-secure.yaml b/gremlin-server/conf/gremlin-server-secure.yaml index e4b6049d452..05ea0e65895 100644 --- a/gremlin-server/conf/gremlin-server-secure.yaml +++ b/gremlin-server/conf/gremlin-server-secure.yaml @@ -29,18 +29,13 @@ scriptEvaluationTimeout: 30000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample-secure.groovy], - config: { - compilerCustomizerProviders: { - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider":[], - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000], - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {} + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {enableThreadInterrupt: true, timedInterrupt: 10000, compilation: COMPILE_STATIC, extensions: org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample-secure.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/conf/gremlin-server-spark.yaml b/gremlin-server/conf/gremlin-server-spark.yaml index 2335c31c52c..17c9638207c 100644 --- a/gremlin-server/conf/gremlin-server-spark.yaml +++ b/gremlin-server/conf/gremlin-server-spark.yaml @@ -44,13 +44,12 @@ scriptEvaluationTimeout: 30000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer graphs: { graph: conf/hadoop-gryo.properties} -plugins: - - tinkerpop.spark scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/spark.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.spark.jsr223.SparkGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/spark.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/conf/gremlin-server.yaml b/gremlin-server/conf/gremlin-server.yaml index a4680960a8e..83a3fc71f7d 100644 --- a/gremlin-server/conf/gremlin-server.yaml +++ b/gremlin-server/conf/gremlin-server.yaml @@ -21,13 +21,12 @@ scriptEvaluationTimeout: 30000 channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo-lite diff --git a/gremlin-server/pom.xml b/gremlin-server/pom.xml index 75f6c904274..f4fcee49643 100644 --- a/gremlin-server/pom.xml +++ b/gremlin-server/pom.xml @@ -80,12 +80,6 @@ limitations under the License. ${project.version} test - - org.apache.tinkerpop - gremlin-groovy-test - ${project.version} - test - com.carrotsearch junit-benchmarks diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java index ff90de57344..88b033996c4 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java @@ -42,11 +42,9 @@ import org.apache.tinkerpop.gremlin.driver.ser.Serializers; import org.apache.tinkerpop.gremlin.driver.simple.SimpleClient; import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; +import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider; import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; @@ -83,6 +81,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin.Compilation.COMPILE_STATIC; import static org.apache.tinkerpop.gremlin.process.traversal.TraversalSource.GREMLIN_REMOTE_CONNECTION_CLASS; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; @@ -205,13 +204,13 @@ public Settings overrideSettings(final Settings settings) { defaultSettings.port = TestClientFactory.PORT; return settings; case "shouldUseSimpleSandbox": - settings.scriptEngines.get("gremlin-groovy").config = getScriptEngineConfForSimpleSandbox(); + settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForSimpleSandbox()); break; case "shouldUseInterpreterMode": - settings.scriptEngines.get("gremlin-groovy").config = getScriptEngineConfForInterpreterMode(); + settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForInterpreterMode()); break; case "shouldReceiveFailureTimeOutOnScriptEvalOfOutOfControlLoop": - settings.scriptEngines.get("gremlin-groovy").config = getScriptEngineConfForTimedInterrupt(); + settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForTimedInterrupt()); break; case "shouldUseBaseScript": settings.scriptEngines.get("gremlin-groovy").config = getScriptEngineConfForBaseScript(); @@ -235,29 +234,20 @@ private static SslContext createServerSslContext() { private static Map getScriptEngineConfForSimpleSandbox() { final Map scriptEngineConf = new HashMap<>(); - final Map compilerCustomizerProviderConf = new HashMap<>(); - final List sandboxes = new ArrayList<>(); - sandboxes.add(SimpleSandboxExtension.class.getName()); - compilerCustomizerProviderConf.put(CompileStaticCustomizerProvider.class.getName(), sandboxes); - scriptEngineConf.put("compilerCustomizerProviders", compilerCustomizerProviderConf); + scriptEngineConf.put("compilation", COMPILE_STATIC.name()); + scriptEngineConf.put("extensions", SimpleSandboxExtension.class.getName()); return scriptEngineConf; } private static Map getScriptEngineConfForTimedInterrupt() { final Map scriptEngineConf = new HashMap<>(); - final Map timedInterruptProviderConf = new HashMap<>(); - final List config = new ArrayList<>(); - config.add(1000); - timedInterruptProviderConf.put(TimedInterruptCustomizerProvider.class.getName(), config); - scriptEngineConf.put("compilerCustomizerProviders", timedInterruptProviderConf); + scriptEngineConf.put("timedInterrupt", 1000); return scriptEngineConf; } private static Map getScriptEngineConfForInterpreterMode() { final Map scriptEngineConf = new HashMap<>(); - final Map interpreterProviderConf = new HashMap<>(); - interpreterProviderConf.put(InterpreterModeCustomizerProvider.class.getName(), Collections.EMPTY_LIST); - scriptEngineConf.put("compilerCustomizerProviders", interpreterProviderConf); + scriptEngineConf.put("enableInterpreterMode", true); return scriptEngineConf; } diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml index ca8a0df20d4..a755be26f10 100644 --- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml +++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml @@ -24,13 +24,12 @@ graphs: { modern: conf/tinkergraph-empty.properties, crew: conf/tinkergraph-empty.properties, grateful: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-all.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-all.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml index 623c35ef5be..dc411904097 100644 --- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml +++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml @@ -20,13 +20,12 @@ port: 45940 scriptEvaluationTimeout: 30000 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java index 665d21ffb4f..344fc9d47e3 100644 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java +++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java @@ -48,8 +48,6 @@ @Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD) @Graph.OptIn(Graph.OptIn.SUITE_PROCESS_STANDARD) @Graph.OptIn(Graph.OptIn.SUITE_PROCESS_COMPUTER) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_STANDARD) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_COMPUTER) @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals", method = "g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__a_0sungBy_bX", diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java index f7b702a9ccf..5cdad56a1c2 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java @@ -23,17 +23,21 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.TestHelper; import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader; +import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; +import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor; -import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper; import org.apache.tinkerpop.gremlin.groovy.util.TestableConsolePluginAcceptor; import org.apache.tinkerpop.gremlin.hadoop.Constants; import org.apache.tinkerpop.gremlin.hadoop.HadoopGremlinSuite; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.util.Gremlin; import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; +import org.codehaus.groovy.tools.shell.Groovysh; +import org.codehaus.groovy.tools.shell.IO; import org.junit.Before; import org.junit.Test; +import javax.script.ScriptException; import javax.tools.JavaCompiler; import javax.tools.SimpleJavaFileObject; import javax.tools.ToolProvider; @@ -42,11 +46,14 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.net.URI; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; @@ -67,7 +74,15 @@ * @author Marko A. Rodriguez (http://markorodriguez.com) */ public class HadoopGremlinPluginCheck extends AbstractGremlinTest { + // *********************** + // This test will be removed as the old "plugin" infrastructure was deprecated in 3.2.4. need to rework the + // tests a bi for this to see what the model is for validating the jsr223 plugins. note that the code from + // gremlin-groovy-test, specifically TestableConsolePluginAcceptor, has been copied to the bottom of this + // file for reference + // *********************** + + /** @Before public void setupTest() { try { @@ -308,4 +323,73 @@ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOExcept return code; } } + **/ + + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + + +//package org.apache.tinkerpop.gremlin.groovy.util; +// +//import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; +//import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; +//import org.codehaus.groovy.tools.shell.Groovysh; +//import org.codehaus.groovy.tools.shell.IO; +// +//import javax.script.ScriptException; +//import java.io.IOException; +//import java.io.OutputStream; +//import java.util.Collections; +//import java.util.HashMap; +//import java.util.Map; +//import java.util.Set; +// +// /** +// * @author Marko A. Rodriguez (http://markorodriguez.com) +// */ +// public class TestableConsolePluginAcceptor implements PluginAcceptor { +// +// public static final String ENVIRONMENT_NAME = "console"; +// public static final String ENVIRONMENT_SHELL = "ConsolePluginAcceptor.shell"; +// public static final String ENVIRONMENT_IO = "ConsolePluginAcceptor.io"; +// +// private Groovysh shell = new Groovysh(new IO(System.in, new OutputStream() { +// @Override +// public void write(int b) throws IOException { +// +// } +// }, System.err)); +// +// @Override +// public void addImports(final Set importStatements) { +// importStatements.forEach(this.shell::execute); +// } +// +// @Override +// public void addBinding(final String key, final Object val) { +// this.shell.getInterp().getContext().setVariable(key, val); +// } +// +// @Override +// public Map getBindings() { +// return Collections.unmodifiableMap(this.shell.getInterp().getContext().getVariables()); +// } +// +// @Override +// public Object eval(final String script) throws ScriptException { +// return this.shell.execute(script); +// } +// +// @Override +// public Map environment() { +// final Map env = new HashMap<>(); +// env.put(GremlinPlugin.ENVIRONMENT, ENVIRONMENT_NAME); +// env.put(ENVIRONMENT_IO, this.shell.getIo()); +// env.put(ENVIRONMENT_SHELL, this.shell); +// return env; +// } +// +// } } diff --git a/neo4j-gremlin/pom.xml b/neo4j-gremlin/pom.xml index 30c681d139e..cedd11e7714 100644 --- a/neo4j-gremlin/pom.xml +++ b/neo4j-gremlin/pom.xml @@ -31,11 +31,6 @@ limitations under the License. gremlin-core ${project.version} - - org.apache.tinkerpop - gremlin-groovy - ${project.version} - org.neo4j neo4j-tinkerpop-api @@ -48,12 +43,6 @@ limitations under the License. ${project.version} test - - org.apache.tinkerpop - gremlin-groovy-test - ${project.version} - test - org.slf4j slf4j-log4j12 diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java deleted file mode 100644 index 68c00165de3..00000000000 --- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/groovy/plugin/Neo4jGremlinPlugin.java +++ /dev/null @@ -1,62 +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.neo4j.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 org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; -import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; - -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.neo4j.jsr223.Neo4jGremlinPlugin}. - */ -@Deprecated -public final class Neo4jGremlinPlugin extends AbstractGremlinPlugin { - - private static final Set IMPORTS = new HashSet() {{ - add(IMPORT_SPACE + Neo4jGraph.class.getPackage().getName() + DOT_STAR); - add(IMPORT_STATIC_SPACE + LabelP.class.getCanonicalName() + DOT_STAR); - }}; - - @Override - public String getName() { - return "tinkerpop.neo4j"; - } - - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws PluginInitializationException, IllegalEnvironmentException { - pluginAcceptor.addImports(IMPORTS); - } - - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - - } - - @Override - public boolean requireRestart() { - return true; - } -} \ No newline at end of file diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java index 8224d47409e..b92801a08c1 100644 --- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java +++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java @@ -64,9 +64,6 @@ @Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_STANDARD) @Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_INTEGRATE) @Graph.OptIn(Graph.OptIn.SUITE_PROCESS_STANDARD) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_STANDARD) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE) @Graph.OptIn("org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite") public final class Neo4jGraph implements Graph, WrappedGraph { diff --git a/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin b/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin deleted file mode 100644 index f4cbea8805d..00000000000 --- a/neo4j-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin +++ /dev/null @@ -1 +0,0 @@ -org.apache.tinkerpop.gremlin.neo4j.groovy.plugin.Neo4jGremlinPlugin \ No newline at end of file diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/MultiMetaNeo4jGraphGroovyProcessStandardTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/MultiMetaNeo4jGraphGroovyProcessStandardTest.java deleted file mode 100644 index 2e22e1cef4a..00000000000 --- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/MultiMetaNeo4jGraphGroovyProcessStandardTest.java +++ /dev/null @@ -1,33 +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.neo4j.process.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.neo4j.MultiMetaNeo4jGraphProvider; -import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; -import org.apache.tinkerpop.gremlin.process.GroovyProcessStandardSuite; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessStandardSuite.class) -@GraphProviderClass(provider = MultiMetaNeo4jGraphProvider.class, graph = Neo4jGraph.class) -public class MultiMetaNeo4jGraphGroovyProcessStandardTest { -} diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/NoMultiNoMetaNeo4jGraphGroovyProcessStandardTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/NoMultiNoMetaNeo4jGraphGroovyProcessStandardTest.java deleted file mode 100644 index 1e7e200f6f1..00000000000 --- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/groovy/NoMultiNoMetaNeo4jGraphGroovyProcessStandardTest.java +++ /dev/null @@ -1,34 +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.neo4j.process.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.neo4j.NoMultiNoMetaNeo4jGraphProvider; -import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph; -import org.apache.tinkerpop.gremlin.process.GroovyProcessStandardSuite; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessStandardSuite.class) -@GraphProviderClass(provider = NoMultiNoMetaNeo4jGraphProvider.class, graph = Neo4jGraph.class) -public class NoMultiNoMetaNeo4jGraphGroovyProcessStandardTest { - -} \ No newline at end of file diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureCheck.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureCheck.java index d585a5a64b4..b2f245f6c0e 100644 --- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureCheck.java +++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/structure/NativeNeo4jStructureCheck.java @@ -19,13 +19,10 @@ package org.apache.tinkerpop.gremlin.neo4j.structure; import org.apache.tinkerpop.gremlin.FeatureRequirement; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.neo4j.AbstractNeo4jGremlinTest; import org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP; import org.apache.tinkerpop.gremlin.neo4j.structure.trait.MultiMetaNeo4jTrait; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -38,12 +35,14 @@ import org.neo4j.tinkerpop.api.Neo4jRelationship; import org.neo4j.tinkerpop.api.Neo4jTx; -import javax.script.Bindings; -import javax.script.ScriptException; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -127,48 +126,6 @@ public void shouldTraverseWithoutLabels() { tx2.close(); } - @Test - public void shouldEnsureTraverseRelationshipNeedsTx() throws ScriptException { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); - final Bindings bindings = engine.createBindings(); - bindings.put("g", graph.traversal()); - bindings.put("#jsr223.groovy.engine.keep.globals", "phantom"); - - Vertex marko = this.graph.addVertex(T.label, "Person", "name", "marko"); - Vertex john = this.graph.addVertex(T.label, "Person", "name", "john"); - Vertex pete = this.graph.addVertex(T.label, "Person", "name", "pete"); - marko.addEdge("friend", john); - marko.addEdge("friend", pete); - this.graph.tx().commit(); - - Object result = engine.eval("g.V(" + marko.id().toString() + ").outE('friend')", bindings); - assertTrue(result instanceof GraphTraversal); - - this.graph.tx().commit(); - assertEquals(2L, ((GraphTraversal) result).count().next()); - } - - @Test - public void shouldEnsureTraversalOfVerticesNeedsTx() throws ScriptException { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(); - final Bindings bindings = engine.createBindings(); - bindings.put("g", graph.traversal()); - bindings.put("#jsr223.groovy.engine.keep.globals", "phantom"); - - Vertex marko = this.graph.addVertex(T.label, "Person", "name", "marko"); - Vertex john = this.graph.addVertex(T.label, "Person", "name", "john"); - Vertex pete = this.graph.addVertex(T.label, "Person", "name", "pete"); - marko.addEdge("friend", john); - marko.addEdge("friend", pete); - this.graph.tx().commit(); - - Object result = engine.eval("g.V(" + marko.id().toString() + ").out('friend')", bindings); - assertTrue(result instanceof GraphTraversal); - - this.graph.tx().commit(); - assertEquals(2L, ((GraphTraversal) result).count().next()); - } - @Test public void shouldDoLabelSearch() { this.graph.addVertex(T.label, "Person", "name", "marko"); diff --git a/pom.xml b/pom.xml index a0d69517fda..441c5fc6b87 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,6 @@ limitations under the License. gremlin-core gremlin-test gremlin-groovy - gremlin-groovy-test tinkergraph-gremlin gremlin-python hadoop-gremlin diff --git a/tinkergraph-gremlin/pom.xml b/tinkergraph-gremlin/pom.xml index 02e32d7e2e0..4f26d4832d0 100644 --- a/tinkergraph-gremlin/pom.xml +++ b/tinkergraph-gremlin/pom.xml @@ -35,24 +35,15 @@ limitations under the License. org.apache.commons commons-lang3 - - org.apache.tinkerpop - gremlin-groovy - ${project.version} - provided + org.slf4j + slf4j-log4j12 + test org.apache.tinkerpop - gremlin-groovy-test + gremlin-test ${project.version} - test - - - org.slf4j - slf4j-log4j12 - test diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/groovy/plugin/TinkerGraphGremlinPlugin.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/groovy/plugin/TinkerGraphGremlinPlugin.java deleted file mode 100644 index 5c8231afe8b..00000000000 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/groovy/plugin/TinkerGraphGremlinPlugin.java +++ /dev/null @@ -1,57 +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.tinkergraph.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 org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; - -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.tinkergraph.jsr223.TinkerGraphGremlinPlugin}. - */ -@Deprecated -public final class TinkerGraphGremlinPlugin extends AbstractGremlinPlugin { - - private static final Set IMPORTS = new HashSet() {{ - add(IMPORT_SPACE + TinkerGraph.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + TinkerGraphComputer.class.getPackage().getName() + DOT_STAR); - }}; - - @Override - public String getName() { - return "tinkerpop.tinkergraph"; - } - - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws PluginInitializationException, IllegalEnvironmentException { - pluginAcceptor.addImports(IMPORTS); - } - - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - - } -} diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java index 9d2df0ad968..79503eaebb8 100644 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java +++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java @@ -63,10 +63,6 @@ @Graph.OptIn(Graph.OptIn.SUITE_STRUCTURE_INTEGRATE) @Graph.OptIn(Graph.OptIn.SUITE_PROCESS_STANDARD) @Graph.OptIn(Graph.OptIn.SUITE_PROCESS_COMPUTER) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_STANDARD) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_PROCESS_COMPUTER) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT) -@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE) public final class TinkerGraph implements Graph { static { diff --git a/tinkergraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin b/tinkergraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin deleted file mode 100644 index 2c627fef555..00000000000 --- a/tinkergraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin +++ /dev/null @@ -1 +0,0 @@ -org.apache.tinkerpop.gremlin.tinkergraph.groovy.plugin.TinkerGraphGremlinPlugin \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessComputerTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessComputerTest.java deleted file mode 100644 index decf9f489a6..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessComputerTest.java +++ /dev/null @@ -1,33 +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.tinkergraph.process.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.process.GroovyProcessComputerSuite; -import org.apache.tinkerpop.gremlin.tinkergraph.process.TinkerGraphComputerProvider; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessComputerSuite.class) -@GraphProviderClass(provider = TinkerGraphComputerProvider.class, graph = TinkerGraph.class) -public class TinkerGraphGroovyProcessComputerTest { -} diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessStandardTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessStandardTest.java deleted file mode 100644 index a900eaeebda..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/TinkerGraphGroovyProcessStandardTest.java +++ /dev/null @@ -1,33 +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.tinkergraph.process.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.process.GroovyProcessStandardSuite; -import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessStandardSuite.class) -@GraphProviderClass(provider = TinkerGraphProvider.class, graph = TinkerGraph.class) -public class TinkerGraphGroovyProcessStandardTest { -} diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorComputerProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorComputerProvider.java deleted file mode 100644 index ca0e58fd93f..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorComputerProvider.java +++ /dev/null @@ -1,37 +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.tinkergraph.process.groovy.jsr223; - -import org.apache.tinkerpop.gremlin.GraphProvider; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@GraphProvider.Descriptor(computer = TinkerGraphComputer.class) -public class TinkerGraphGroovyTranslatorComputerProvider extends TinkerGraphGroovyTranslatorProvider { - - @Override - public GraphTraversalSource traversal(final Graph graph) { - return super.traversal(graph).withComputer(); - } -} diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessComputerTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessComputerTest.java deleted file mode 100644 index 67760ced986..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessComputerTest.java +++ /dev/null @@ -1,33 +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.tinkergraph.process.groovy.jsr223; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(ProcessComputerSuite.class) -@GraphProviderClass(provider = TinkerGraphGroovyTranslatorComputerProvider.class, graph = TinkerGraph.class) -public class TinkerGraphGroovyTranslatorProcessComputerTest { -} diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessStandardTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessStandardTest.java deleted file mode 100644 index 058b552e380..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/groovy/jsr223/TinkerGraphGroovyTranslatorProcessStandardTest.java +++ /dev/null @@ -1,33 +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.tinkergraph.process.groovy.jsr223; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(ProcessStandardSuite.class) -@GraphProviderClass(provider = TinkerGraphGroovyTranslatorProvider.class, graph = TinkerGraph.class) -public class TinkerGraphGroovyTranslatorProcessStandardTest { -} diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java deleted file mode 100644 index 011ad5d9b2c..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/jsr223/TinkerGraphJavaTranslatorProvider.java +++ /dev/null @@ -1,74 +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.tinkergraph.process.jsr223; - -import org.apache.tinkerpop.gremlin.LoadGraphWith; -import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class TinkerGraphJavaTranslatorProvider extends TinkerGraphProvider { - - private static Set SKIP_TESTS = new HashSet<>(Arrays.asList( - "testProfileStrategyCallback", - "testProfileStrategyCallbackSideEffect", - TraversalInterruptionTest.class.getCanonicalName(), - TraversalInterruptionComputerTest.class.getCanonicalName(), - ElementIdStrategyProcessTest.class.getCanonicalName(), - EventStrategyProcessTest.class.getCanonicalName(), - ProgramTest.Traversals.class.getCanonicalName())); - - - @Override - public Map getBaseConfiguration(final String graphName, final Class test, final String testMethodName, - final LoadGraphWith.GraphData loadGraphWith) { - - final Map config = super.getBaseConfiguration(graphName, test, testMethodName, loadGraphWith); - config.put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName())); - return config; - } - - @Override - public GraphTraversalSource traversal(final Graph graph) { - if ((Boolean) graph.configuration().getProperty("skipTest")) - return graph.traversal(); - //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance()); - else { - final GraphTraversalSource g = graph.traversal(); - return g.withStrategies(new TranslationStrategy(g, JavaTranslator.of(g))); - } - } -} \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentIntegrateTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentIntegrateTest.java deleted file mode 100644 index b97ec06cf0e..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentIntegrateTest.java +++ /dev/null @@ -1,37 +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.tinkergraph.structure.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.groovy.GroovyEnvironmentIntegrateSuite; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -@RunWith(GroovyEnvironmentIntegrateSuite.class) -@GraphProviderClass(provider = TinkerGraphProvider.class, graph = TinkerGraph.class) -public class TinkerGraphGroovyEnvironmentIntegrateTest { - static { - SugarLoader.load(); - } -} \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentTest.java deleted file mode 100644 index 6fb0d1d8c7a..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphGroovyEnvironmentTest.java +++ /dev/null @@ -1,37 +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.tinkergraph.structure.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.groovy.GroovyEnvironmentSuite; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -@RunWith(GroovyEnvironmentSuite.class) -@GraphProviderClass(provider = TinkerGraphProvider.class, graph = TinkerGraph.class) -public class TinkerGraphGroovyEnvironmentTest { - static { - SugarLoader.load(); - } -} \ No newline at end of file diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphUUIDGroovyEnvironmentTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphUUIDGroovyEnvironmentTest.java deleted file mode 100644 index a3dfad77a39..00000000000 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/groovy/TinkerGraphUUIDGroovyEnvironmentTest.java +++ /dev/null @@ -1,38 +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.tinkergraph.structure.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.groovy.GroovyEnvironmentSuite; -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphUUIDProvider; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyEnvironmentSuite.class) -@GraphProviderClass(provider = TinkerGraphUUIDProvider.class, graph = TinkerGraph.class) -public class TinkerGraphUUIDGroovyEnvironmentTest { - static { - SugarLoader.load(); - } -} \ No newline at end of file From 9f6ed57771892e82a71bf3c02bb6310751bf6260 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 25 Jan 2017 06:52:10 -0500 Subject: [PATCH 02/34] TINKERPOP-1612 Configure tests to allow them to pass under new plugins --- .../gremlin/groovy/engine/GremlinExecutor.java | 4 +--- .../gremlin/server/GremlinServerIntegrateTest.java | 14 +++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java index 8fdb86e1f49..80e72fd7c68 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java @@ -128,10 +128,8 @@ private GremlinExecutor(final Builder builder, final boolean suppliedExecutor, // deprecated code around this is removed. if (!useGremlinScriptEngineManager) this.scriptEngines = createScriptEngines(); - else { + else this.scriptEngines = null; - gremlinScriptEngineManager.getEngineByName("gremlin-groovy"); - } this.suppliedExecutor = suppliedExecutor; this.suppliedScheduledExecutor = suppliedScheduledExecutor; diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java index 88b033996c4..16476c31df7 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java @@ -43,8 +43,8 @@ import org.apache.tinkerpop.gremlin.driver.simple.SimpleClient; import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension; +import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; @@ -65,7 +65,6 @@ import java.lang.reflect.Field; import java.nio.channels.ClosedChannelException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -205,6 +204,8 @@ public Settings overrideSettings(final Settings settings) { return settings; case "shouldUseSimpleSandbox": settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForSimpleSandbox()); + // remove the script because it isn't used in the test but also because it's not CompileStatic ready + settings.scriptEngines.get("gremlin-groovy").plugins.remove(ScriptFileGremlinPlugin.class.getName()); break; case "shouldUseInterpreterMode": settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForInterpreterMode()); @@ -213,6 +214,7 @@ public Settings overrideSettings(final Settings settings) { settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForTimedInterrupt()); break; case "shouldUseBaseScript": + settings.scriptEngines.get("gremlin-groovy").plugins.put(GroovyCompilerGremlinPlugin.class.getName(), getScriptEngineConfForBaseScript()); settings.scriptEngines.get("gremlin-groovy").config = getScriptEngineConfForBaseScript(); break; } @@ -253,15 +255,9 @@ private static Map getScriptEngineConfForInterpreterMode() { private static Map getScriptEngineConfForBaseScript() { final Map scriptEngineConf = new HashMap<>(); - final Map compilerCustomizerProviderConf = new HashMap<>(); - final List keyValues = new ArrayList<>(); - final Map properties = new HashMap<>(); properties.put("ScriptBaseClass", BaseScriptForTesting.class.getName()); - keyValues.add(properties); - - compilerCustomizerProviderConf.put(ConfigurationCustomizerProvider.class.getName(), keyValues); - scriptEngineConf.put("compilerCustomizerProviders", compilerCustomizerProviderConf); + scriptEngineConf.put("compilerConfigurationOptions", properties); return scriptEngineConf; } From 5a3f55cbd56467188108031bcc6ab11148ff9d34 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 25 Jan 2017 12:34:09 -0500 Subject: [PATCH 03/34] TINKERPOP-1612 Reconfigure some tests for new plugins. --- .../python/driver/gremlin-server-modern-secure-py.yaml | 3 +-- .../gremlin/server/GremlinDriverIntegrateTest.java | 7 +++++-- .../gremlin/server/GremlinResultSetIntegrateTest.java | 5 ++++- .../gremlin/server/GremlinServerHttpIntegrateTest.java | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml b/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml index c846cf48c51..3f2394685cc 100644 --- a/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml +++ b/gremlin-python/src/test/resources/org/apache/tinkerpop/gremlin/python/driver/gremlin-server-modern-secure-py.yaml @@ -32,10 +32,9 @@ graphs: { graph: src/test/resources/org/apache/tinkerpop/gremlin/python/driver/tinkergraph-empty.properties} scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [src/test/resources/org/apache/tinkerpop/gremlin/python/driver/generate-modern.groovy]}}}, gremlin-jython: {}, gremlin-python: {} diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java index a8164b5f256..658244d9433 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java @@ -32,6 +32,7 @@ import org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer; import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0; import org.apache.tinkerpop.gremlin.driver.ser.Serializers; +import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; import org.apache.tinkerpop.gremlin.server.channel.NioChannelizer; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; @@ -134,7 +135,9 @@ public Settings overrideSettings(final Settings settings) { try { final String p = TestHelper.generateTempFileFromResource( GremlinDriverIntegrateTest.class, "generate-shouldRebindTraversalSourceVariables.groovy", "").getAbsolutePath(); - settings.scriptEngines.get("gremlin-groovy").scripts = Collections.singletonList(p); + final Map m = new HashMap<>(); + m.put("files", Collections.singletonList(p)); + settings.scriptEngines.get("gremlin-groovy").plugins.put(ScriptFileGremlinPlugin.class.getName(), m); } catch (Exception ex) { throw new RuntimeException(ex); } @@ -672,7 +675,7 @@ public void shouldDeserializeWithCustomClasses() throws Exception { final Cluster cluster = TestClientFactory.build().serializer(serializer).create(); final Client client = cluster.connect(); - final List json = client.submit("b = new JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join(); + final List json = client.submit("b = new groovy.json.JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join(); assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString()); cluster.close(); } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java index ec39dece10e..17fd38d6921 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java @@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.driver.ResultSet; import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0; import org.apache.tinkerpop.gremlin.driver.ser.Serializers; +import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; import org.apache.tinkerpop.gremlin.process.traversal.Path; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; @@ -71,7 +72,9 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat @Override public Settings overrideSettings(final Settings settings) { - settings.scriptEngines.get("gremlin-groovy").scripts = Collections.singletonList("scripts/generate-modern.groovy"); + final Map m = new HashMap<>(); + m.put("files", Collections.singletonList("scripts/generate-modern.groovy")); + settings.scriptEngines.get("gremlin-groovy").plugins.put(ScriptFileGremlinPlugin.class.getName(), m); return settings; } 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 4192a6c7f02..9cea2ce1c38 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 @@ -21,6 +21,7 @@ import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0; import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0; import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0; +import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; import org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator; import org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer; import org.apache.http.Consts; @@ -68,7 +69,9 @@ public Settings overrideSettings(final Settings settings) { case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResult": case "should200OnPOSTWithGremlinJsonEndcodedBodyWithIteratorResultAndAliases": case "should200OnGETWithGremlinQueryStringArgumentWithIteratorResultAndAliases": - settings.scriptEngines.get("gremlin-groovy").scripts = Collections.singletonList("scripts/generate-classic.groovy"); + final Map m = new HashMap<>(); + m.put("files", Collections.singletonList("scripts/generate-classic.groovy")); + settings.scriptEngines.get("gremlin-groovy").plugins.put(ScriptFileGremlinPlugin.class.getName(), m); break; case "should200OnPOSTTransactionalGraph": deleteDirectory(new File("/tmp/neo4j")); From 17e4b66d48fa98ab15e71838b3d0bd81e5391842 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Wed, 25 Jan 2017 18:11:36 -0500 Subject: [PATCH 04/34] TINKERPOP-1612 Fixed cut/paste error in server configuration --- gremlin-python/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml index f3dd338b9db..711514a5328 100644 --- a/gremlin-python/pom.xml +++ b/gremlin-python/pom.xml @@ -491,6 +491,8 @@ settings.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties settings.scriptEngines["gremlin-groovy"].plugins["org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin"].files = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] settings.port = 45940 +println settings.scriptEngines["gremlin-groovy"].plugins["org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin"].files + def server = new GremlinServer(settings) server.start().join() @@ -499,7 +501,7 @@ log.info("Gremlin Server with no authentication started on port 45940") def settingsSecure = Settings.read("${gremlin.server.dir}/conf/gremlin-server-modern-py.yaml") settingsSecure.graphs.graph = "${gremlin.server.dir}/conf/tinkergraph-empty.properties" -settings.scriptEngines["gremlin-groovy"].plugins["org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin"].files = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] +settingsSecure.scriptEngines["gremlin-groovy"].plugins["org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin"].files = ["${gremlin.server.dir}/scripts/generate-modern.groovy"] settingsSecure.port = 45941 settingsSecure.authentication.className = "org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator" settingsSecure.authentication.config = [credentialsDb: "${gremlin.server.dir}/conf/tinkergraph-credentials.properties"] From 9a2c571638ba371524477ba83b1f0be5348ee063 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 26 Jan 2017 10:21:10 -0500 Subject: [PATCH 05/34] TINKERPOP-1612 Remove references to gremlin-groovy-test in hadoop stuff --- giraph-gremlin/pom.xml | 11 -- .../groovy/plugin/GiraphGremlinPlugin.java | 65 ---------- ...kerpop.gremlin.groovy.plugin.GremlinPlugin | 1 - ...aphComputerGroovyProcessIntegrateTest.java | 33 ----- .../src/test/resources/gremlin-server.yaml | 8 +- .../groovy/util/SugarTestHelper.groovy | 1 - .../groovy/plugin/HadoopGremlinPlugin.java | 104 --------------- .../groovy/plugin/HadoopRemoteAcceptor.java | 122 ------------------ .../gremlin/hadoop/structure/HadoopGraph.java | 103 --------------- .../io/script/ScriptRecordWriter.java | 11 +- ...kerpop.gremlin.groovy.plugin.GremlinPlugin | 1 - .../gremlin/hadoop/HadoopGraphProvider.java | 5 +- .../gremlin/hadoop/HadoopGremlinSuite.java | 2 +- .../HadoopGremlinPluginCheck.java | 8 +- .../HadoopGraphGroovyProcessStandardTest.java | 33 ----- pom.xml | 2 +- spark-gremlin/pom.xml | 11 -- .../groovy/plugin/SparkGremlinPlugin.java | 74 ----------- ...kerpop.gremlin.groovy.plugin.GremlinPlugin | 1 - .../computer/SparkHadoopGraphProvider.java | 16 +-- ...aphComputerGroovyProcessIntegrateTest.java | 33 ----- .../gremlin/spark/util/SugarTestHelper.java | 56 ++++++++ 22 files changed, 77 insertions(+), 624 deletions(-) delete mode 100644 giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/groovy/plugin/GiraphGremlinPlugin.java delete mode 100644 giraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin delete mode 100644 giraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/giraph/process/computer/groovy/GiraphGraphComputerGroovyProcessIntegrateTest.java delete mode 100644 hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java delete mode 100644 hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java delete mode 100644 hadoop-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin rename hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/{groovy/plugin => jsr223}/HadoopGremlinPluginCheck.java (99%) delete mode 100644 hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/process/groovy/HadoopGraphGroovyProcessStandardTest.java delete mode 100644 spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java delete mode 100644 spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin delete mode 100644 spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/groovy/SparkGraphComputerGroovyProcessIntegrateTest.java create mode 100644 spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/util/SugarTestHelper.java diff --git a/giraph-gremlin/pom.xml b/giraph-gremlin/pom.xml index ed58572f3f1..38b17581dfa 100644 --- a/giraph-gremlin/pom.xml +++ b/giraph-gremlin/pom.xml @@ -41,11 +41,6 @@ limitations under the License. gremlin-core ${project.version} - - org.apache.tinkerpop - gremlin-groovy - ${project.version} - org.apache.tinkerpop hadoop-gremlin @@ -173,12 +168,6 @@ limitations under the License. - - org.apache.tinkerpop - gremlin-groovy-test - ${project.version} - test - org.apache.tinkerpop tinkergraph-gremlin diff --git a/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/groovy/plugin/GiraphGremlinPlugin.java b/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/groovy/plugin/GiraphGremlinPlugin.java deleted file mode 100644 index 80d98f99f28..00000000000 --- a/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/groovy/plugin/GiraphGremlinPlugin.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.giraph.groovy.plugin; - -import org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer; -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 Marko A. Rodriguez (http://markorodriguez.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.giraph.jsr223.GiraphGremlinPlugin}. - */ -@Deprecated -public final class GiraphGremlinPlugin extends AbstractGremlinPlugin { - - protected static String NAME = "tinkerpop.giraph"; - - protected static final Set IMPORTS = new HashSet() {{ - add(IMPORT_SPACE + GiraphGraphComputer.class.getPackage().getName() + DOT_STAR); - }}; - - @Override - public String getName() { - return NAME; - } - - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws PluginInitializationException, IllegalEnvironmentException { - pluginAcceptor.addImports(IMPORTS); - } - - @Override - public boolean requireRestart() { - return true; - } - - @Override - public Optional remoteAcceptor() { - return Optional.empty(); - } -} \ No newline at end of file diff --git a/giraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin b/giraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin deleted file mode 100644 index 9c8f3d00b46..00000000000 --- a/giraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin +++ /dev/null @@ -1 +0,0 @@ -org.apache.tinkerpop.gremlin.giraph.groovy.plugin.GiraphGremlinPlugin \ No newline at end of file diff --git a/giraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/giraph/process/computer/groovy/GiraphGraphComputerGroovyProcessIntegrateTest.java b/giraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/giraph/process/computer/groovy/GiraphGraphComputerGroovyProcessIntegrateTest.java deleted file mode 100644 index bb1da85a38a..00000000000 --- a/giraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/giraph/process/computer/groovy/GiraphGraphComputerGroovyProcessIntegrateTest.java +++ /dev/null @@ -1,33 +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.giraph.process.computer.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphHadoopGraphProvider; -import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph; -import org.apache.tinkerpop.gremlin.process.GroovyProcessComputerSuite; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessComputerSuite.class) -@GraphProviderClass(provider = GiraphHadoopGraphProvider.class, graph = HadoopGraph.class) -public class GiraphGraphComputerGroovyProcessIntegrateTest { -} diff --git a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/resources/gremlin-server.yaml b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/resources/gremlin-server.yaml index d1f91ef87fd..5da82d70fa8 100644 --- a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/resources/gremlin-server.yaml +++ b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/resources/gremlin-server.yaml @@ -23,13 +23,11 @@ scriptEvaluationTimeout: 30000 serializedResponseTimeout: 30000 graphs: { graph: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/generate-modern.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-modern.groovy]}}}} serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+gryo - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} # application/vnd.gremlin-v1.0+gryo-stringd diff --git a/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy b/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy index cf2db11c2e6..3f4df074bea 100644 --- a/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy +++ b/gremlin-groovy/src/test/groovy/org/apache/tinkerpop/gremlin/groovy/util/SugarTestHelper.groovy @@ -18,7 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.util -import org.apache.tinkerpop.gremlin.GraphProvider import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java deleted file mode 100644 index ca446efa82d..00000000000 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java +++ /dev/null @@ -1,104 +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.hadoop.groovy.plugin; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat; -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 org.apache.tinkerpop.gremlin.hadoop.Constants; -import org.apache.tinkerpop.gremlin.hadoop.process.computer.mapreduce.MapReduceGraphComputer; -import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopConfiguration; -import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph; -import org.apache.tinkerpop.gremlin.hadoop.structure.io.FileSystemStorage; -import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable; -import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONInputFormat; -import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat; -import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptInputFormat; -import org.apache.tinkerpop.gremlin.hadoop.structure.util.ConfUtil; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPlugin}. - */ -@Deprecated -public final class HadoopGremlinPlugin extends AbstractGremlinPlugin { - - protected static String NAME = "tinkerpop.hadoop"; - - protected static final Set IMPORTS = new HashSet() {{ - add("import org.apache.hadoop.hdfs.*"); - add("import org.apache.hadoop.conf.*"); - add("import org.apache.hadoop.fs.*"); - add("import org.apache.hadoop.util.*"); - add("import org.apache.hadoop.io.*"); - add("import org.apache.hadoop.io.compress.*"); - add("import org.apache.hadoop.mapreduce.lib.input.*"); - add("import org.apache.hadoop.mapreduce.lib.output.*"); - add("import org.apache.log4j.*"); - add(IMPORT_SPACE + Constants.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + HadoopConfiguration.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + ConfUtil.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + VertexWritable.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + GryoInputFormat.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + GraphSONInputFormat.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + ScriptInputFormat.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + SequenceFileInputFormat.class.getCanonicalName()); - //// - add(IMPORT_SPACE + MapReduceGraphComputer.class.getPackage().getName() + DOT_STAR); - }}; - - @Override - public String getName() { - return NAME; - } - - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws PluginInitializationException, IllegalEnvironmentException { - pluginAcceptor.addImports(IMPORTS); - try { - pluginAcceptor.addBinding("hdfs", FileSystemStorage.open(FileSystem.get(new Configuration()))); - pluginAcceptor.addBinding("fs", FileSystemStorage.open(FileSystem.getLocal(new Configuration()))); - if (null == System.getenv(Constants.HADOOP_GREMLIN_LIBS)) - HadoopGraph.LOGGER.warn("Be sure to set the environmental variable: " + Constants.HADOOP_GREMLIN_LIBS); - else - HadoopGraph.LOGGER.info(Constants.HADOOP_GREMLIN_LIBS + " is set to: " + System.getenv(Constants.HADOOP_GREMLIN_LIBS)); - } catch (final Exception e) { - throw new PluginInitializationException(e.getMessage(), e); - } - } - - @Override - public boolean requireRestart() { - return true; - } - - @Override - public Optional remoteAcceptor() { - return Optional.of(new HadoopRemoteAcceptor(this.shell)); - } -} \ No newline at end of file diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java deleted file mode 100644 index acae442a8c1..00000000000 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopRemoteAcceptor.java +++ /dev/null @@ -1,122 +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.hadoop.groovy.plugin; - -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor; -import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException; -import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph; -import org.apache.tinkerpop.gremlin.process.computer.ComputerResult; -import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram; -import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ComputerResultStep; -import org.apache.tinkerpop.gremlin.process.traversal.Traversal; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep; -import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy; -import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal; -import org.codehaus.groovy.tools.shell.Groovysh; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopRemoteAcceptor}. - */ -@Deprecated -public final class HadoopRemoteAcceptor implements RemoteAcceptor { - - private static final String USE_SUGAR = "useSugar"; - private static final String USE_TRAVERSAL_SOURCE = "useTraversalSource"; - private static final String SPACE = " "; - - private HadoopGraph hadoopGraph; - private Groovysh shell; - private boolean useSugar = false; - private TraversalSource traversalSource; - - public HadoopRemoteAcceptor(final Groovysh shell) { - this.shell = shell; - } - - @Override - public Object connect(final List args) throws RemoteException { - if (args.size() != 1 && args.size() != 2) { - throw new IllegalArgumentException("Usage: :remote connect " + HadoopGremlinPlugin.NAME + " "); - } - this.hadoopGraph = (HadoopGraph) this.shell.getInterp().getContext().getVariable(args.get(0)); - if (args.size() == 2) - this.traversalSource = ((TraversalSource) this.shell.getInterp().getContext().getVariable(args.get(1))); - else - this.traversalSource = this.hadoopGraph.traversal(); - /// - final HashMap configuration = new HashMap<>(); - configuration.put(USE_SUGAR, this.useSugar); - configuration.put(USE_TRAVERSAL_SOURCE, this.traversalSource); - return Collections.unmodifiableMap(configuration); - } - - @Override - public Object configure(final List args) throws RemoteException { - for (int i = 0; i < args.size(); i = i + 2) { - if (args.get(i).equals(USE_SUGAR)) - this.useSugar = Boolean.valueOf(args.get(i + 1)); - else if (args.get(i).equals(USE_TRAVERSAL_SOURCE)) { - this.traversalSource = ((TraversalSource) this.shell.getInterp().getContext().getVariable(args.get(i + 1))); - } else - throw new IllegalArgumentException("The provided configuration is unknown: " + args.get(i) + ":" + args.get(i + 1)); - } - /// - final HashMap configuration = new HashMap<>(); - configuration.put(USE_SUGAR, this.useSugar); - configuration.put(USE_TRAVERSAL_SOURCE, this.traversalSource); - return Collections.unmodifiableMap(configuration); - } - - @Override - public Object submit(final List args) throws RemoteException { - try { - String script = RemoteAcceptor.getScript(String.join(SPACE, args), this.shell); - if (this.useSugar) - script = SugarLoader.class.getCanonicalName() + ".load()\n" + script; - final TraversalVertexProgram program = TraversalVertexProgram.build().traversal(this.traversalSource, "gremlin-groovy", script).create(this.hadoopGraph); - final ComputerResult computerResult = VertexProgramStrategy.getComputer(this.traversalSource.getStrategies()).get().apply(this.hadoopGraph).program(program).submit().get(); - this.shell.getInterp().getContext().setVariable(RESULT, computerResult); - /// - final Traversal.Admin traversal = new DefaultTraversal<>(computerResult.graph()); - traversal.addStep(new ComputerResultStep<>(traversal)); - traversal.addStart(traversal.getTraverserGenerator().generate(computerResult, EmptyStep.instance(), 1l)); - return traversal; - } catch (final Exception e) { - throw new RemoteException(e); - } - } - - @Override - public boolean allowRemoteConsole() { - return true; - } - - @Override - public void close() throws IOException { - this.hadoopGraph.close(); - } -} diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java index 344fc9d47e3..fdcfef2d935 100644 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java +++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java @@ -83,41 +83,6 @@ method = "g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX", reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.", computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__a_0sungBy_bX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_matchXa_knows_b__c_knows_bX", - reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.", - computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_matchXa_created_b__c_created_bX_selectXa_b_cX_byXnameX", - reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.", - computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX", - reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.", - computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer"}) // this is a nasty long test, just do it once in Java MatchTest -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals", - method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_dX_whereXc_sungBy_dX_whereXd_hasXname_GarciaXX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals", method = "g_V_both_both_count", @@ -138,26 +103,6 @@ method = "g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count", reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals", - method = "g_V_both_both_count", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals", - method = "g_V_repeatXoutX_timesX3X_count", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals", - method = "g_V_repeatXoutX_timesX8X_count", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals", - method = "g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profile", @@ -166,14 +111,6 @@ test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals", method = "grateful_V_out_out_profileXmetricsX", reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.") -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProfileTest$Traversals", - method = "grateful_V_out_out_profile", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.") -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProfileTest$Traversals", - method = "grateful_V_out_out_profileXmetricsX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.") @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest", method = "g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX", @@ -204,36 +141,6 @@ method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals", - method = "g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals", - method = "g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals", - method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals", - method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTestV3d0$Traversals", - method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTestV3d0$Traversals", - method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) @Graph.OptOut( test = "org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest", method = "shouldStartAndEndWorkersForVertexProgramAndMapReduce", @@ -258,16 +165,6 @@ method = "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count", reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$CountMatchTraversals", - method = "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) -@Graph.OptOut( - test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$GreedyMatchTraversals", - method = "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count", - reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.", - computers = {"ALL"}) public final class HadoopGraph implements Graph { public static final Logger LOGGER = LoggerFactory.getLogger(HadoopGraph.class); diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java index d445fcdade8..29272e43611 100644 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java +++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java @@ -24,10 +24,9 @@ import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.mapreduce.RecordWriter; import org.apache.hadoop.mapreduce.TaskAttemptContext; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable; +import org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager; +import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager; import javax.script.Bindings; import javax.script.ScriptEngine; @@ -49,6 +48,7 @@ public final class ScriptRecordWriter extends RecordWriter PATHS = new HashMap<>(); - private static final Set IMPLEMENTATION = new HashSet() {{ + public static final Set IMPLEMENTATION = Collections.unmodifiableSet(new HashSet() {{ add(HadoopEdge.class); add(HadoopElement.class); add(HadoopGraph.class); @@ -70,7 +71,7 @@ public class HadoopGraphProvider extends AbstractGraphProvider { add(ComputerGraph.ComputerVertexProperty.class); add(ComputerGraph.ComputerAdjacentVertex.class); add(ComputerGraph.ComputerProperty.class); - }}; + }}); static { try { diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java index 89aef8011d0..3f7009f9e37 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java @@ -20,7 +20,7 @@ package org.apache.tinkerpop.gremlin.hadoop; import org.apache.tinkerpop.gremlin.AbstractGremlinSuite; -import org.apache.tinkerpop.gremlin.hadoop.groovy.plugin.HadoopGremlinPluginCheck; +import org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPluginCheck; import org.apache.tinkerpop.gremlin.hadoop.structure.io.FileSystemStorageCheck; import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine; import org.junit.runners.model.InitializationError; diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java similarity index 99% rename from hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java rename to hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java index 5cdad56a1c2..baa96da05d6 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.tinkerpop.gremlin.hadoop.groovy.plugin; +package org.apache.tinkerpop.gremlin.hadoop.jsr223; import org.apache.tinkerpop.gremlin.AbstractGremlinTest; import org.apache.tinkerpop.gremlin.LoadGraphWith; @@ -26,7 +26,6 @@ import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor; -import org.apache.tinkerpop.gremlin.groovy.util.TestableConsolePluginAcceptor; import org.apache.tinkerpop.gremlin.hadoop.Constants; import org.apache.tinkerpop.gremlin.hadoop.HadoopGremlinSuite; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; @@ -80,7 +79,10 @@ public class HadoopGremlinPluginCheck extends AbstractGremlinTest { // gremlin-groovy-test, specifically TestableConsolePluginAcceptor, has been copied to the bottom of this // file for reference // *********************** - + @Test + public void nothing() { + // this is just to stop junit failures until this test gets figured out + } /** @Before diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/process/groovy/HadoopGraphGroovyProcessStandardTest.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/process/groovy/HadoopGraphGroovyProcessStandardTest.java deleted file mode 100644 index 10399be9aac..00000000000 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/process/groovy/HadoopGraphGroovyProcessStandardTest.java +++ /dev/null @@ -1,33 +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.hadoop.process.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.hadoop.HadoopGraphProvider; -import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph; -import org.apache.tinkerpop.gremlin.process.GroovyProcessStandardSuite; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessStandardSuite.class) -@GraphProviderClass(provider = HadoopGraphProvider.class, graph = HadoopGraph.class) -public class HadoopGraphGroovyProcessStandardTest { -} diff --git a/pom.xml b/pom.xml index 441c5fc6b87..9075e492c28 100644 --- a/pom.xml +++ b/pom.xml @@ -1003,7 +1003,7 @@ limitations under the License. ${basedir}/docs/javadoc/overview.html true - giraph-gremlin/src/main/java:gremlin-core/src/main/java:gremlin-driver/src/main/java:gremlin-groovy/src/main/java:gremlin-groovy-test/src/main/java:gremlin-python/src/main/java:gremlin-server/src/main/java:gremlin-test/src/main/java:hadoop-gremlin/src/main/java:neo4j-gremlin/src/main/java:spark-gremlin/src/main/java:tinkergraph-gremlin/src/main/java + giraph-gremlin/src/main/java:gremlin-core/src/main/java:gremlin-driver/src/main/java:gremlin-groovy/src/main/java:gremlin-python/src/main/java:gremlin-server/src/main/java:gremlin-test/src/main/java:hadoop-gremlin/src/main/java:neo4j-gremlin/src/main/java:spark-gremlin/src/main/java:tinkergraph-gremlin/src/main/java diff --git a/spark-gremlin/pom.xml b/spark-gremlin/pom.xml index 0782f385f1f..68586baf037 100644 --- a/spark-gremlin/pom.xml +++ b/spark-gremlin/pom.xml @@ -45,11 +45,6 @@ - - org.apache.tinkerpop - gremlin-groovy - ${project.version} - org.apache.tinkerpop hadoop-gremlin @@ -343,12 +338,6 @@ - - org.apache.tinkerpop - gremlin-groovy-test - ${project.version} - test - org.apache.tinkerpop tinkergraph-gremlin diff --git a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java deleted file mode 100644 index c6eb6822fb2..00000000000 --- a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java +++ /dev/null @@ -1,74 +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.spark.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 org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor; -import org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer; -import org.apache.tinkerpop.gremlin.spark.structure.Spark; -import org.apache.tinkerpop.gremlin.spark.structure.io.SparkContextStorage; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.spark.jsr223.SparkGremlinPlugin}. - */ -@Deprecated -public final class SparkGremlinPlugin extends AbstractGremlinPlugin { - - protected static String NAME = "tinkerpop.spark"; - - protected static final Set IMPORTS = new HashSet() {{ - add(IMPORT_SPACE + SparkGraphComputer.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + Spark.class.getPackage().getName() + DOT_STAR); - add(IMPORT_SPACE + SparkContextStorage.class.getPackage().getName() + DOT_STAR); - }}; - - @Override - public String getName() { - return NAME; - } - - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws PluginInitializationException, IllegalEnvironmentException { - pluginAcceptor.addImports(IMPORTS); - try { - pluginAcceptor.addBinding("spark", SparkContextStorage.open()); - } catch (final Exception e) { - throw new PluginInitializationException(e.getMessage(), e); - } - } - - @Override - public boolean requireRestart() { - return true; - } - - @Override - public Optional remoteAcceptor() { - return Optional.empty(); - } -} \ No newline at end of file diff --git a/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin b/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin deleted file mode 100644 index 0399720d5a4..00000000000 --- a/spark-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin +++ /dev/null @@ -1 +0,0 @@ -org.apache.tinkerpop.gremlin.spark.groovy.plugin.SparkGremlinPlugin \ No newline at end of file diff --git a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java index 6cdcb678450..74e1207f421 100644 --- a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java +++ b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java @@ -22,32 +22,25 @@ import org.apache.spark.serializer.KryoSerializer; import org.apache.tinkerpop.gremlin.GraphProvider; import org.apache.tinkerpop.gremlin.LoadGraphWith; -import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper; import org.apache.tinkerpop.gremlin.hadoop.Constants; import org.apache.tinkerpop.gremlin.hadoop.HadoopGraphProvider; -import org.apache.tinkerpop.gremlin.hadoop.groovy.plugin.HadoopGremlinPluginCheck; +import org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPluginCheck; import org.apache.tinkerpop.gremlin.hadoop.structure.io.FileSystemStorageCheck; import org.apache.tinkerpop.gremlin.hadoop.structure.io.HadoopPools; -import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.ToyIoRegistry; import org.apache.tinkerpop.gremlin.process.computer.Computer; import org.apache.tinkerpop.gremlin.process.computer.GraphComputer; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.engine.ComputerTraversalEngine; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPageRankTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyPeerPressureTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyProgramTest; import org.apache.tinkerpop.gremlin.process.traversal.step.map.PageRankTest; import org.apache.tinkerpop.gremlin.process.traversal.step.map.PeerPressureTest; import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest; import org.apache.tinkerpop.gremlin.spark.structure.Spark; import org.apache.tinkerpop.gremlin.spark.structure.io.PersistedOutputRDD; import org.apache.tinkerpop.gremlin.spark.structure.io.SparkContextStorageCheck; -import org.apache.tinkerpop.gremlin.spark.structure.io.SparkIoRegistryCheck; import org.apache.tinkerpop.gremlin.spark.structure.io.ToyGraphInputRDD; import org.apache.tinkerpop.gremlin.spark.structure.io.gryo.GryoRegistrator; +import org.apache.tinkerpop.gremlin.spark.util.SugarTestHelper; import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; -import org.apache.tinkerpop.gremlin.structure.io.gryo.kryoshim.KryoShimService; import org.apache.tinkerpop.gremlin.structure.io.gryo.kryoshim.KryoShimServiceLoader; import java.util.Map; @@ -75,11 +68,8 @@ public Map getBaseConfiguration(final String graphName, final Cl // toy graph inputRDD does not have corresponding outputRDD so where jobs chain, it fails (failing makes sense) if (null != loadGraphWith && !test.equals(ProgramTest.Traversals.class) && - !test.equals(GroovyProgramTest.Traversals.class) && !test.equals(PageRankTest.Traversals.class) && - !test.equals(GroovyPageRankTest.Traversals.class) && !test.equals(PeerPressureTest.Traversals.class) && - !test.equals(GroovyPeerPressureTest.Traversals.class) && !test.equals(FileSystemStorageCheck.class) && !testMethodName.equals("shouldSupportJobChaining") && // GraphComputerTest.shouldSupportJobChaining RANDOM.nextBoolean()) { @@ -97,7 +87,7 @@ public Map getBaseConfiguration(final String graphName, final Cl Spark.close(); HadoopPools.close(); KryoShimServiceLoader.close(); - SugarTestHelper.clearRegistry(this); + SugarTestHelper.clearRegistry(); } config.put(Constants.GREMLIN_HADOOP_DEFAULT_GRAPH_COMPUTER, SparkGraphComputer.class.getCanonicalName()); diff --git a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/groovy/SparkGraphComputerGroovyProcessIntegrateTest.java b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/groovy/SparkGraphComputerGroovyProcessIntegrateTest.java deleted file mode 100644 index 6f259dd468a..00000000000 --- a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/groovy/SparkGraphComputerGroovyProcessIntegrateTest.java +++ /dev/null @@ -1,33 +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.spark.process.computer.groovy; - -import org.apache.tinkerpop.gremlin.GraphProviderClass; -import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph; -import org.apache.tinkerpop.gremlin.process.GroovyProcessComputerSuite; -import org.apache.tinkerpop.gremlin.spark.process.computer.SparkHadoopGraphProvider; -import org.junit.runner.RunWith; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@RunWith(GroovyProcessComputerSuite.class) -@GraphProviderClass(provider = SparkHadoopGraphProvider.class, graph = HadoopGraph.class) -public class SparkGraphComputerGroovyProcessIntegrateTest { -} \ No newline at end of file diff --git a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/util/SugarTestHelper.java b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/util/SugarTestHelper.java new file mode 100644 index 00000000000..334c67fd966 --- /dev/null +++ b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/util/SugarTestHelper.java @@ -0,0 +1,56 @@ +/* + * 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.spark.util; + +import org.apache.tinkerpop.gremlin.groovy.util.MetaRegistryUtil; +import org.apache.tinkerpop.gremlin.hadoop.HadoopGraphProvider; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; +import org.apache.tinkerpop.gremlin.process.traversal.traverser.*; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public final class SugarTestHelper { + + public static final Set CORE_IMPLEMENTATIONS = new HashSet() {{ + add(__.class); + add(DefaultGraphTraversal.class); + add(GraphTraversalSource.class); + add(B_O_S_SE_SL_Traverser.class); + add(B_LP_O_P_S_SE_SL_Traverser.class); + add(B_LP_O_S_SE_SL_Traverser.class); + add(B_O_Traverser.class); + add(O_Traverser.class); + }}; + + /** + * Clear the metaclass registry to "turn-off" sugar. + */ + public static void clearRegistry() { + final Set implementationsToClear = new HashSet<>(CORE_IMPLEMENTATIONS); + implementationsToClear.addAll(HadoopGraphProvider.IMPLEMENTATION); + + MetaRegistryUtil.clearRegistry(implementationsToClear); + } +} From 09510a171c803833c1131e829fa0ec0e667c72b6 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 26 Jan 2017 10:58:14 -0500 Subject: [PATCH 06/34] TINKERPOP-1612 Removed exclusion of commons-lang3 for neo4j That used to come in as part of gremlin-groovy, but since neo4j-gremlin no longer depends on that we need to remove the exclusion. --- neo4j-gremlin/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/neo4j-gremlin/pom.xml b/neo4j-gremlin/pom.xml index cedd11e7714..7602cc03590 100644 --- a/neo4j-gremlin/pom.xml +++ b/neo4j-gremlin/pom.xml @@ -121,10 +121,6 @@ limitations under the License. 0.3-2.3.3 test - - org.apache.commons - commons-lang3 - com.googlecode.concurrentlinkedhashmap concurrentlinkedhashmap-lru From 21c530afbacc43b27c9903770149c94ea5d0790d Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 30 Jan 2017 14:36:56 -0500 Subject: [PATCH 07/34] TINKERPOP-1612 Removed mode for old plugin system in console In 3.2.4 the new plugin system was introduced. It was designed to run parallel to the old so there was some extra code in the console to allow it to load either the old plugin system or the new. Since TinkerGraph has removed its plugin due to removal of gremlin-groovy as a dependency, the old plugin system had to be removed as well for 3.3.0 or else no tinkergraph stuff will load in the console. --- .../giraph/jsr223/GiraphGremlinPlugin.java | 2 +- gremlin-console/src/main/ext/plugins.txt | 6 +- .../tinkerpop/gremlin/console/Console.groovy | 29 ++------ .../tinkerpop/gremlin/console/Mediator.groovy | 1 - .../console/commands/InstallCommand.groovy | 14 +--- .../gremlin/jsr223/CoreGremlinModule.java | 62 ---------------- .../tinkerpop/gremlin/jsr223/CoreImports.java | 1 + .../DefaultGremlinScriptEngineManager.java | 25 ------- .../gremlin/jsr223/GremlinModule.java | 74 ------------------- .../jsr223/GremlinScriptEngineManager.java | 8 -- .../GremlinEnabledScriptEngineTest.java | 25 ------- 11 files changed, 15 insertions(+), 232 deletions(-) delete mode 100644 gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java delete mode 100644 gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java diff --git a/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/jsr223/GiraphGremlinPlugin.java b/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/jsr223/GiraphGremlinPlugin.java index ee49ed5e79e..c5123353325 100644 --- a/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/jsr223/GiraphGremlinPlugin.java +++ b/giraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/giraph/jsr223/GiraphGremlinPlugin.java @@ -38,7 +38,7 @@ public final class GiraphGremlinPlugin extends AbstractGremlinPlugin { private static final String MODULE_NAME = "tinkerpop.giraph"; private static final GiraphGremlinPlugin instance = new GiraphGremlinPlugin(); - private GiraphGremlinPlugin() { + public GiraphGremlinPlugin() { super(MODULE_NAME, DefaultImportCustomizer.build().addClassImports( EmptyOutEdges.class, GiraphComputation.class, diff --git a/gremlin-console/src/main/ext/plugins.txt b/gremlin-console/src/main/ext/plugins.txt index 2b1a2e71449..7eb2b23f819 100644 --- a/gremlin-console/src/main/ext/plugins.txt +++ b/gremlin-console/src/main/ext/plugins.txt @@ -1,3 +1,3 @@ -org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin -org.apache.tinkerpop.gremlin.console.groovy.plugin.UtilitiesGremlinPlugin -org.apache.tinkerpop.gremlin.tinkergraph.groovy.plugin.TinkerGraphGremlinPlugin \ No newline at end of file +org.apache.tinkerpop.gremlin.console.jsr223.DriverGremlinPlugin +org.apache.tinkerpop.gremlin.console.jsr223.UtilitiesGremlinPlugin +org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin \ No newline at end of file diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy index 8eee33854e9..57eca8b573e 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy @@ -29,8 +29,8 @@ import org.apache.tinkerpop.gremlin.console.commands.RemoteCommand import org.apache.tinkerpop.gremlin.console.commands.SubmitCommand import org.apache.tinkerpop.gremlin.console.commands.UninstallCommand import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin +import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation import org.apache.tinkerpop.gremlin.structure.Edge @@ -94,18 +94,10 @@ class Console { // hide output temporarily while imports execute showShellEvaluationOutput(false) - if (Mediator.useV3d3) { - def imports = (ImportCustomizer) CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").get()[0] - imports.getClassPackages().collect { Mediator.IMPORT_SPACE + it.getName() + Mediator.IMPORT_WILDCARD }.each { groovy.execute(it) } - imports.getMethodClasses().collect { Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each{ groovy.execute(it) } - imports.getEnumClasses().collect { Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each{ groovy.execute(it) } - } else { - // add the default imports - new ConsoleImportCustomizerProvider().getCombinedImports().stream() - .collect { Mediator.IMPORT_SPACE + it }.each { groovy.execute(it) } - new ConsoleImportCustomizerProvider().getCombinedStaticImports().stream() - .collect { Mediator.IMPORT_STATIC_SPACE + it }.each { groovy.execute(it) } - } + def imports = (ImportCustomizer) CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").get()[0] + imports.getClassPackages().collect { Mediator.IMPORT_SPACE + it.getName() + Mediator.IMPORT_WILDCARD }.each { groovy.execute(it) } + imports.getMethodClasses().collect { Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each{ groovy.execute(it) } + imports.getEnumClasses().collect { Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each{ groovy.execute(it) } final InteractiveShellRunner runner = new InteractiveShellRunner(groovy, handlePrompt) runner.setErrorHandler(handleError) @@ -121,16 +113,9 @@ class Console { // check for available plugins. if they are in the "active" plugins strategies then "activate" them def activePlugins = Mediator.readPluginState() - def pluginClass = mediator.useV3d3 ? org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin : GremlinPlugin - ServiceLoader.load(pluginClass, groovy.getInterp().getClassLoader()).each { plugin -> + ServiceLoader.load(GremlinPlugin, groovy.getInterp().getClassLoader()).each { plugin -> if (!mediator.availablePlugins.containsKey(plugin.class.name)) { - def pluggedIn - - if (Mediator.useV3d3) { - pluggedIn = new PluggedIn(new PluggedIn.GremlinPluginAdapter((org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin) plugin, groovy, io), groovy, io, false) - } else { - pluggedIn = new PluggedIn((GremlinPlugin) plugin, groovy, io, false) - } + def pluggedIn = new PluggedIn(new PluggedIn.GremlinPluginAdapter((GremlinPlugin) plugin, groovy, io), groovy, io, false) mediator.availablePlugins.put(plugin.class.name, pluggedIn) diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy index 2f5b827e2f2..3d0134053c9 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy @@ -36,7 +36,6 @@ class Mediator { public static final String IMPORT_SPACE = "import " public static final String IMPORT_STATIC_SPACE = "import static " public static final String IMPORT_WILDCARD = ".*" - public static final boolean useV3d3 = System.getProperty("plugins", "v3d2") == "v3d3" public Mediator(final Console console) { this.console = console diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy index 5386e8967af..11880272cff 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy @@ -21,10 +21,10 @@ package org.apache.tinkerpop.gremlin.console.commands import org.apache.tinkerpop.gremlin.console.ConsoleFs import org.apache.tinkerpop.gremlin.console.Mediator import org.apache.tinkerpop.gremlin.console.PluggedIn -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin import groovy.grape.Grape import org.apache.tinkerpop.gremlin.groovy.util.Artifact import org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber +import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin import org.codehaus.groovy.tools.shell.CommandSupport import org.codehaus.groovy.tools.shell.Groovysh @@ -64,17 +64,9 @@ class InstallCommand extends CommandSupport { // note that the service loader utilized the classloader from the groovy shell as shell class are available // from within there given loading through Grape. - def pluginClass = mediator.useV3d3 ? org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin : GremlinPlugin - ServiceLoader.load(pluginClass, shell.getInterp().getClassLoader()).forEach { plugin -> + ServiceLoader.load(GremlinPlugin, shell.getInterp().getClassLoader()).forEach { plugin -> if (!mediator.availablePlugins.containsKey(plugin.class.name)) { - - if (Mediator.useV3d3) { - mediator.availablePlugins.put(plugin.class.name, new PluggedIn(new PluggedIn.GremlinPluginAdapter((org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin) plugin, shell, io), shell, io, false)) - } else { - mediator.availablePlugins.put(plugin.class.name, new PluggedIn((GremlinPlugin) plugin, shell, io, false)) - } - - //mediator.availablePlugins.put(plugin.class.name, new PluggedIn(plugin, shell, io, false)) + mediator.availablePlugins.put(plugin.class.name, new PluggedIn(new PluggedIn.GremlinPluginAdapter((GremlinPlugin) plugin, shell, io), shell, io, false)) if (plugin.requireRestart()) pluginsThatNeedRestart << plugin.name } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java deleted file mode 100644 index 369e171264b..00000000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java +++ /dev/null @@ -1,62 +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.jsr223; - -import java.util.Optional; - -/** - * This module is required for a {@code ScriptEngine} to be Gremlin-enabled. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link CoreGremlinPlugin}. - */ -@Deprecated -public final class CoreGremlinModule implements GremlinModule { - - private static final String MODULE_NAME = "tinkerpop.core"; - - private static final ImportCustomizer gremlinCore = DefaultImportCustomizer.build() - .addClassImports(CoreImports.getClassImports()) - .addEnumImports(CoreImports.getEnumImports()) - .addMethodImports(CoreImports.getMethodImports()).create(); - - private static final Customizer[] customizers = new Customizer[] {gremlinCore}; - - /** - * @deprecated As of 3.2.4, replaced by {@link #instance()} as this field will later become private. - */ - @Deprecated - public static final CoreGremlinModule INSTANCE = new CoreGremlinModule(); - - private CoreGremlinModule() {} - - public static CoreGremlinModule instance() { - return INSTANCE; - } - - @Override - public Optional getCustomizers(final String scriptEngineName) { - return Optional.of(customizers); - } - - @Override - public String getName() { - return MODULE_NAME; - } -} diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java index fef2e0fa4f3..5701e47dbf0 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreImports.java @@ -135,6 +135,7 @@ /** * @author Marko A. Rodriguez (http://markorodriguez.com) + * @author Stephen Mallette (http://stephen.genoprime.com) */ public final class CoreImports { diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java index b3025eca33e..ddde15e3344 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java @@ -99,14 +99,6 @@ public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineMan */ private List plugins = new ArrayList<>(); - /** - * List of extensions for the {@link GremlinScriptEngineManager} which will be used to supply - * {@link Customizer} instances to {@link GremlinScriptEngineFactory} that are instantiated. - * - * @deprecated As of release 3.2.4, replaced by {@link #plugins}. - */ - private List modules = new ArrayList<>(); - /** * The effect of calling this constructor is the same as calling * {@code DefaultGremlinScriptEngineManager(Thread.currentThread().getContextClassLoader())}. @@ -133,26 +125,9 @@ public List getCustomizers(final String scriptEngineName) { return Stream.of(customizers.orElse(new Customizer[0])); }).collect(Collectors.toList()); - // modules are deprecated in favor of GremlinPlugin - this line will eventually be removed - pluginCustomizers.addAll(modules.stream().flatMap(plugin -> { - final Optional customizers = plugin.getCustomizers(scriptEngineName); - return Stream.of(customizers.orElse(new Customizer[0])); - }).collect(Collectors.toList())); - - return pluginCustomizers; } - /** - * @deprecated As of release 3.2.4, replaced by {@link #addPlugin(GremlinPlugin)}. - */ - @Override - @Deprecated - public void addModule(final GremlinModule module) { - // TODO: should modules be a set based on "name" to ensure uniqueness? not sure what bad stuff can happen with dupes - if (module != null) modules.add(module); - } - @Override public void addPlugin(final GremlinPlugin plugin) { // TODO: should modules be a set based on "name" to ensure uniqueness? not sure what bad stuff can happen with dupes diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java deleted file mode 100644 index f05b51c79dd..00000000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java +++ /dev/null @@ -1,74 +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.jsr223; - -import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor; - -import java.util.Optional; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link GremlinPlugin}. - */ -@Deprecated -public interface GremlinModule { - /** - * The name of the module. This name should be unique (use a namespaced approach) as naming clashes will - * prevent proper module operations. Modules developed by TinkerPop will be prefixed with "tinkerpop." - * For example, TinkerPop's implementation of Giraph would be named "tinkerpop.giraph". If Facebook were - * to do their own implementation the implementation might be called "facebook.giraph". - */ - public String getName(); - - /** - * Some modules may require a restart of the plugin host for the classloader to pick up the features. This is - * typically true of modules that rely on {@code Class.forName()} to dynamically instantiate classes from the - * root classloader (e.g. JDBC drivers that instantiate via @{code DriverManager}). - */ - public default boolean requireRestart() { - return false; - } - - /** - * Gets the list of all {@link Customizer} implementations to assign to a new {@link GremlinScriptEngine}. This is - * the same as doing {@code getCustomizers(null)}. - */ - public default Optional getCustomizers(){ - return getCustomizers(null); - } - - /** - * Gets the list of {@link Customizer} implementations to assign to a new {@link GremlinScriptEngine}. The - * implementation should filter the returned {@code Customizers} according to the supplied name of the - * Gremlin-enabled {@code ScriptEngine}. By providing a filter, {@code GremlinModule} developers can have the - * ability to target specific {@code ScriptEngines}. - * - * @param scriptEngineName The name of the {@code ScriptEngine} or null to get all the available {@code Customizers} - */ - public Optional getCustomizers(final String scriptEngineName); - - /** - * Allows a plugin to utilize features of the {@code :remote} and {@code :submit} commands of the Gremlin Console. - * This method does not need to be implemented if the plugin is not meant for the Console for some reason or - * if it does not intend to take advantage of those commands. - */ - public default Optional remoteAcceptor() { - return Optional.empty(); - } -} diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java index a48d7618287..eb4a2d3d18f 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java @@ -117,14 +117,6 @@ public interface GremlinScriptEngineManager { */ public List getEngineFactories(); - /** - * Add {@link GremlinModule} instances to customize newly created {@link GremlinScriptEngine} instances. - * - * @deprecated As of release 3.2.4, replaced by {@link #addPlugin(GremlinPlugin)}. - */ - @Deprecated - public void addModule(final GremlinModule module); - /** * Add {@link GremlinPlugin} instances to customize newly created {@link GremlinScriptEngine} instances. */ diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java index 5a880f8fed1..e31a657b490 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java @@ -56,31 +56,6 @@ public void shouldHaveCoreImportsInPlace() throws Exception { } } - @Test - public void shouldSupportDeprecatedGremlinModules() throws Exception { - final GremlinScriptEngineManager mgr = new DefaultGremlinScriptEngineManager(); - mgr.addModule(new GremlinModule() { - @Override - public String getName() { - return "test.junk"; - } - - @Override - public Optional getCustomizers(final String scriptEngineName) { - return Optional.of(new Customizer[] {DefaultImportCustomizer.build() - .addClassImports(java.awt.Color.class) - .addClassImports(java.sql.CallableStatement.class) - .create() }); - } - }); - - final GremlinScriptEngine scriptEngine = mgr.getEngineByName(ENGINE_TO_TEST); - final List classesToCheck = Arrays.asList(java.awt.Color.class, java.sql.CallableStatement.class); - for (Class clazz : classesToCheck) { - assertEquals(clazz, scriptEngine.eval(clazz.getSimpleName())); - } - } - @Test public void shouldReturnNoCustomizers() { final GremlinScriptEngineManager mgr = new DefaultGremlinScriptEngineManager(); From a1707e44bc9abb50d30b57f080cab4c541ccec64 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 2 Feb 2017 06:39:51 -0500 Subject: [PATCH 08/34] TINKERPOP-1612 Update upgrade docs based on deprecation removal. --- docs/src/upgrade/release-3.3.x.asciidoc | 37 +++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index c42d697cdbd..23f80e9d5d1 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -177,20 +177,31 @@ Deprecation Removal The following deprecated classes, methods or fields have been removed in this version: +* `giraph-gremlin` +** org.apache.tinkerpop.gremlin.giraph.groovy.plugin.GiraphGremlinPlugin * `gremlin-console` ** `org.apache.tinkerpop.gremlin.console.Console(String)` +* `gremlin-core` +** `org.apache.tinkerpop.gremlin.jsr223.CoreGremlinModule` +** `org.apache.tinkerpop.gremlin.jsr223.GremlinModule` +** `org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager#addModule(GremlinModule)` * `gremlin-groovy` ** `org.apache.tinkerpop.gremlin.groovy.engine.ConcurrentBindings` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine(ImportCustomizerProvider)` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine#plugins()` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SandboxExtension` +* `spark-gremlin` +** `org.apache.tinkerpop.gremlin.spark.groovy.plugin.SparkGremlinPlugin` +* `tinkergraph-gremlin` +** `org.apache.tinkerpop.gremlin.tinkergraph.groovy.plugin.TinkerGraphGremlinPlugin` Please see the javadoc deprecation notes or upgrade documentation specific to when the deprecation took place to understand how to resolve this breaking change. See: link:https://issues.apache.org/jira/browse/TINKERPOP-1283[TINKERPOP-1283], link:https://issues.apache.org/jira/browse/TINKERPOP-1420[TINKERPOP-1420], -link:https://issues.apache.org/jira/browse/TINKERPOP-833[TINKERPOP-833], link:https://issues.apache.org/jira/browse/TINKERPOP-1040[TINKERPOP-1040] +link:https://issues.apache.org/jira/browse/TINKERPOP-833[TINKERPOP-833], link:https://issues.apache.org/jira/browse/TINKERPOP-1040[TINKERPOP-1040], +link:https://issues.apache.org/jira/browse/TINKERPOP-1612[TINKERPOP-1612] Upgrading for Providers ~~~~~~~~~~~~~~~~~~~~~~~ @@ -198,24 +209,34 @@ Upgrading for Providers Graph Database Providers ^^^^^^^^^^^^^^^^^^^^^^^^ -Performance Tests -+++++++++++++++++ +Test Suite Removal +++++++++++++++++++ -Performance tests based on `junit-benchmarks` have been removed from TinkerPop. Specifically, providers should be -concerned with breaking changes related to the removal of: +A number of test suites that were previously deprecated have been removed which should reduce the burden on graph +providers who are implementing TinkerPop. Test suites related to perfrmance based on `junit-benchmarks` have been +removed as have the suites in `gremlin-groovy-test` (in fact, this entire module has been removed). Specifically, +providers should be concerned with breaking changes related to the removal of: * `StructurePerformanceSuite` * `ProcessPerformanceSuite` * `GroovyEnvironmentPerformanceSuite` +* `GroovyProcessStandardSuite` +* `GroovyProcessComputerSuite` +* `GroovyEnvironmentSuite` +* `GroovyEnvironmentIntegrateSuite` -Those graph providers who relied on these tests should simply remove them from their respective test suites. +Those graph providers who relied on these tests should simply remove them from their respective test suites. Beware of +`OptOut` annotations that reference tests in these suites as test failure will occur if those references are not +removed. -See: link:https://issues.apache.org/jira/browse/TINKERPOP-1235[TINKERPOP-1235] +See: link:https://issues.apache.org/jira/browse/TINKERPOP-1235[TINKERPOP-1235], link:https://issues.apache.org/jira/browse/TINKERPOP-1612[TINKERPOP-1612] Gremlin-server.sh and Init Scripts ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`gremlin-server.sh` is now also an init script and can no longer be started without parameters. To start it in the foreground with defaults like previous usage, please use the `console` parameter. Also, `gremlin-server.sh` will continue to start in the foreground when provided a yaml configuration file. +`gremlin-server.sh` is now also an init script and can no longer be started without parameters. To start it in the +foreground with defaults like previous usage, please use the `console` parameter. Also, `gremlin-server.sh` will +continue to start in the foreground when provided a yaml configuration file. How to install as a service has been added to the link:http://tinkerpop.apache.org/docs/3.3.0/reference/#_as_a_service[Reference Documentation - As A Service]. From d984be0eb059c5583fa7894dae645e5f9d212265 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 2 Feb 2017 06:40:39 -0500 Subject: [PATCH 09/34] TINKERPOP-1612 Remove deprecated OptIn fields --- .../tinkerpop/gremlin/structure/Graph.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java index 65d72a5bcde..c3712643e9a 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java @@ -1215,30 +1215,6 @@ public static NoSuchElementException elementNotFound(final Class Date: Thu, 2 Feb 2017 06:42:40 -0500 Subject: [PATCH 10/34] TINKERPOP-1612 Update upgrade docs with more deprecation removal. --- docs/src/upgrade/release-3.3.x.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index 23f80e9d5d1..5f89c63d005 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -185,6 +185,10 @@ The following deprecated classes, methods or fields have been removed in this ve ** `org.apache.tinkerpop.gremlin.jsr223.CoreGremlinModule` ** `org.apache.tinkerpop.gremlin.jsr223.GremlinModule` ** `org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager#addModule(GremlinModule)` +** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_STANDARD` +** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_COMPUTER` +** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT` +** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT_INTEGRATE` * `gremlin-groovy` ** `org.apache.tinkerpop.gremlin.groovy.engine.ConcurrentBindings` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine(ImportCustomizerProvider)` From 7910360a6ba10d79b275cbe452b017b64ce485aa Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 2 Feb 2017 08:19:59 -0500 Subject: [PATCH 11/34] TINKERPOP-1612 Fixed deprecation javadoc link --- .../plugin/dsl/credential/CredentialGraphGremlinPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java index 72ca1d58d5b..50ee3461313 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java @@ -30,7 +30,7 @@ * Plugin for the "credentials graph". This plugin imports the {@link CredentialGraph} to its environment. * * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphGremlinPlugin}. + * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphGremlinPlugin}. */ @Deprecated public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin { From eb9425734ede4096b6f60a54ed37fa3cdc9b1040 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 2 Feb 2017 11:05:51 -0500 Subject: [PATCH 12/34] TINKERPOP-1622 Removed deprecated G functions --- CHANGELOG.asciidoc | 2 + docs/src/upgrade/release-3.3.x.asciidoc | 3 +- .../AbstractImportCustomizerProvider.java | 2 - .../groovy/function/GBinaryOperator.java | 57 ------------------- .../gremlin/groovy/function/GComparator.java | 56 ------------------ .../gremlin/groovy/function/GFunction.java | 56 ------------------ .../gremlin/groovy/function/GSupplier.java | 56 ------------------ .../groovy/function/GUnaryOperator.java | 56 ------------------ 8 files changed, 4 insertions(+), 284 deletions(-) delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GBinaryOperator.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GComparator.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GFunction.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GSupplier.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GUnaryOperator.java diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 5f65c37f592..1dd298baa18 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -31,6 +31,8 @@ TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET) * Added "attachment requisite" `VertexProperty.element()` and `Property.element()` data in GraphSON serialization. * GraphSON 3.0 is now the default serialization format in TinkerGraph and Gremlin Server. * Established the GraphSON 3.0 format. +* Removed `gremlin-groovy-test`. +* Removed previously deprecated "G" functions in `gremlin-groovy` (i.e. `GFunction`). * Added `Vertex`, `Edge`, `VertexProperty`, and `Property` serializers to Gremlin-Python and exposed tests that use graph object arguments. * `Bytecode.getSourceInstructions()` and `Bytecode.getStepInstructions()` now returns `List` instead of `Iterable`. * Added various `TraversalStrategy` registrations with `GryoMapper`. diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index 5f89c63d005..a9a70f73189 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -191,6 +191,7 @@ The following deprecated classes, methods or fields have been removed in this ve ** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT_INTEGRATE` * `gremlin-groovy` ** `org.apache.tinkerpop.gremlin.groovy.engine.ConcurrentBindings` +** `org.apache.tinkerpop.gremlin.groovy.function.*` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine(ImportCustomizerProvider)` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine#plugins()` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor` @@ -205,7 +206,7 @@ understand how to resolve this breaking change. See: link:https://issues.apache.org/jira/browse/TINKERPOP-1283[TINKERPOP-1283], link:https://issues.apache.org/jira/browse/TINKERPOP-1420[TINKERPOP-1420], link:https://issues.apache.org/jira/browse/TINKERPOP-833[TINKERPOP-833], link:https://issues.apache.org/jira/browse/TINKERPOP-1040[TINKERPOP-1040], -link:https://issues.apache.org/jira/browse/TINKERPOP-1612[TINKERPOP-1612] +link:https://issues.apache.org/jira/browse/TINKERPOP-1612[TINKERPOP-1612], link:https://issues.apache.org/jira/browse/TINKERPOP-1622[TINKERPOP-1622] Upgrading for Providers ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java index 131216e7f08..47709f22069 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java @@ -21,7 +21,6 @@ import groovy.grape.Grape; import groovy.json.JsonBuilder; import org.apache.commons.configuration.Configuration; -import org.apache.tinkerpop.gremlin.groovy.function.GFunction; import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader; import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator; import org.apache.tinkerpop.gremlin.process.computer.Computer; @@ -131,7 +130,6 @@ public abstract class AbstractImportCustomizerProvider implements ImportCustomiz imports.add(Gremlin.class.getPackage().getName() + DOT_STAR); imports.add(GremlinLoader.class.getPackage().getName() + DOT_STAR); imports.add(FunctionUtils.class.getPackage().getName() + DOT_STAR); - imports.add(GFunction.class.getPackage().getName() + DOT_STAR); imports.add(TraversalMetrics.class.getPackage().getName() + DOT_STAR); staticImports.add(TimeUtil.class.getCanonicalName() + DOT_STAR); staticImports.add(Computer.class.getCanonicalName() + DOT_STAR); diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GBinaryOperator.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GBinaryOperator.java deleted file mode 100644 index 445622a2c80..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GBinaryOperator.java +++ /dev/null @@ -1,57 +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.groovy.function; - -import groovy.lang.Closure; -import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder; - -import java.util.function.BinaryOperator; - -/** - * @deprecated As of release 3.1.0, use {@code as BinaryOperator} in Groovy. - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@Deprecated -public final class GBinaryOperator implements BinaryOperator, LambdaHolder { - - private final Closure closure; - - public GBinaryOperator(final Closure closure) { - this.closure = closure; - } - - public static GBinaryOperator[] make(final Closure... closures) { - final GBinaryOperator[] functions = new GBinaryOperator[closures.length]; - for (int i = 0; i < closures.length; i++) { - functions[i] = new GBinaryOperator(closures[i]); - } - return functions; - } - - @Override - public String toString() { - return "lambda"; - } - - @Override - public A apply(final A a, final A b) { - return (A) closure.call(a, b); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GComparator.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GComparator.java deleted file mode 100644 index 76cf619f36c..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GComparator.java +++ /dev/null @@ -1,56 +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.groovy.function; - -import groovy.lang.Closure; -import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder; - -import java.util.Comparator; - -/** - * @deprecated As of release 3.1.0, use {@code as Comparator} in Groovy. - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@Deprecated -public final class GComparator implements Comparator, LambdaHolder { - - private final Closure closure; - - public GComparator(final Closure closure) { - this.closure = closure; - } - - @Override - public int compare(A first, A second) { - return (int) this.closure.call(first, second); - } - - public static GComparator[] make(final Closure... closures) { - final GComparator[] comparators = new GComparator[closures.length]; - for (int i = 0; i < closures.length; i++) { - comparators[i] = new GComparator(closures[i]); - } - return comparators; - } - - @Override - public String toString() { - return "lambda"; - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GFunction.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GFunction.java deleted file mode 100644 index 9dd5d9df1f3..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GFunction.java +++ /dev/null @@ -1,56 +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.groovy.function; - -import groovy.lang.Closure; -import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder; - -import java.util.function.Function; - -/** - * @deprecated As of release 3.1.0, use {@code as Function} in Groovy. - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@Deprecated -public final class GFunction implements Function, LambdaHolder { - - private final Closure closure; - - public GFunction(final Closure closure) { - this.closure = closure; - } - - @Override - public B apply(A a) { - return (B) this.closure.call(a); - } - - public static GFunction[] make(final Closure... closures) { - final GFunction[] functions = new GFunction[closures.length]; - for (int i = 0; i < closures.length; i++) { - functions[i] = new GFunction(closures[i]); - } - return functions; - } - - @Override - public String toString() { - return "lambda"; - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GSupplier.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GSupplier.java deleted file mode 100644 index 0f38bc5937b..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GSupplier.java +++ /dev/null @@ -1,56 +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.groovy.function; - -import groovy.lang.Closure; -import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder; - -import java.util.function.Supplier; - -/** - * @deprecated As of release 3.1.0, use {@code as Supplier} in Groovy. - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@Deprecated -public final class GSupplier implements Supplier, LambdaHolder { - - private final Closure closure; - - public GSupplier(final Closure closure) { - this.closure = closure; - } - - @Override - public A get() { - return (A) this.closure.call(); - } - - public static GSupplier[] make(final Closure... closures) { - final GSupplier[] functions = new GSupplier[closures.length]; - for (int i = 0; i < closures.length; i++) { - functions[i] = new GSupplier(closures[i]); - } - return functions; - } - - @Override - public String toString() { - return "lambda"; - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GUnaryOperator.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GUnaryOperator.java deleted file mode 100644 index 202b29d1e3a..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/function/GUnaryOperator.java +++ /dev/null @@ -1,56 +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.groovy.function; - -import groovy.lang.Closure; -import org.apache.tinkerpop.gremlin.process.traversal.step.LambdaHolder; - -import java.util.function.UnaryOperator; - -/** - * @deprecated As of release 3.1.0, use {@code as UnaryOperator} in Groovy. - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -@Deprecated -public final class GUnaryOperator implements UnaryOperator, LambdaHolder { - - private final Closure closure; - - public GUnaryOperator(final Closure closure) { - this.closure = closure; - } - - public static GUnaryOperator[] make(final Closure... closures) { - final GUnaryOperator[] functions = new GUnaryOperator[closures.length]; - for (int i = 0; i < closures.length; i++) { - functions[i] = new GUnaryOperator(closures[i]); - } - return functions; - } - - @Override - public String toString() { - return "lambda"; - } - - @Override - public A apply(final A a) { - return (A) closure.call(a); - } -} From 29cfc9e78b683230787f46da9624ada59e84d850 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 13 Feb 2017 15:19:57 -0500 Subject: [PATCH 13/34] TINKERPOP-1612 Re-wrote docs on GremlnPlugin Not quite finished at this point as the sections on RemoteAcceptor needs some work. --- docs/src/dev/provider/index.asciidoc | 91 +++++++++++++++---- .../gremlin/jsr223/GremlinPlugin.java | 3 + 2 files changed, 75 insertions(+), 19 deletions(-) diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc index 71d071fe41e..868a6fa11c8 100644 --- a/docs/src/dev/provider/index.asciidoc +++ b/docs/src/dev/provider/index.asciidoc @@ -1074,46 +1074,99 @@ Gremlin Plugins image:gremlin-plugin.png[width=125] -Plugins provide a way to expand the features of Gremlin Console and Gremlin Server. The first step to developing a -plugin is to implement the `GremlinPlugin` interface: +Plugins provide a way to expand the features of a `GremlinScriptEngine`, which stands at that core of both Gremlin +Console and Gremlin Server. Providers may wish to create plugins for a variety of reasons, but some common examples +include: + +* Initialize the `GremlinScriptEngine` application with important classes so that the user doesn't need to type their +own imports. +* Place specific objects in the bindings of the `GremlinScriptEngine` for the convenience of the user. +* Bootstrap the `GremlinScriptEngine` with custom functions so that they are ready for usage at startup. + +The first step to developing a plugin is to implement the link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/GremlinPlugin.html[GremlinPlugin] +interface: [source,java] ---- -include::{basedir}/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPlugin.java[] +include::{basedir}/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPlugin.java[] ---- The most simple plugin and the one most commonly implemented will likely be one that just provides a list of classes -to import to the Gremlin Console. This type of plugin is the easiest way for implementers of the TinkerPop Structure -and Process APIs to make their implementations available to users. The TinkerGraph implementation has just such a plugin: +for import. This type of plugin is the easiest way for implementers of the TinkerPop Structure and Process APIs to +make their implementations available to users. The TinkerGraph implementation has just such a plugin: + +[source,java] +---- +include::{basedir}/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java[] +---- + +This plugin extends from the abstract base class of link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/AbstractGremlinPlugin.html[AbstractGremlinPlugin] +which provides some default implementations of the `GremlinPlugin` methods. It simply allows those who extend from it +to be able to just supply the name of the module and a list of link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/Customizer.html[Customizer] +instances to apply to the `GremlinScriptEngine`. In this case, the TinkerGraph plugin just needs an +link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.html[ImportCustomizer] +which describes the list of classes to import when the plugin is activated and applied to the `GremlinScriptEngine`. + +The `ImportCustomizer` is just one of several provided `Customizer` implementations that can be used in conjunction +with plugin development: + +* link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/BindingCustomizer.html[BindingCustomizer] - Inject a key/value pair into the global bindings of the `GremlinScriptEngine` instances +* link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/ImportCustomizer.html[ImportCustomizer] - Add imports to a `GremlinScriptEngine` +* link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/ScriptCustomizer.html[ScriptCustomizer] - Execute a script on a `GremlinScriptEngine` at startup + +Individual `GremlinScriptEngine` instances may have their own `Customizer` instances that can be used only with that +engine - e.g. `gremlin-groovy` has some that are specific to controlling the Groovy compiler configuration. Developing +a new `Customizer` implementation is not really possible without changes to TinkerPop, as the framework is not designed +to respond to external ones. The base `Customizer` implementations listed above should cover most needs. + +A `GremlinPlugin` must support one of two instantiation models so that it can be instantiated from configuration files +for use in various situations - e.g. Gremlin Server. The first option is to use a static initializer given a method +with the following signature: [source,java] ---- -include::{basedir}/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/groovy/plugin/TinkerGraphGremlinPlugin.java[] +public static GremlinPlugin instance() ---- +The limitation with this approach is that it does not provide a way to supply any configuration to the plugin so it +tends to only be useful for fairly simplistic plugins. The more advanced approach is to provide a "builder" given a +method with the following signature: + +[source,java] +---- +public static Builder build() +---- + +It doesn't really matter what kind of class is returned from `build` so long as it follows a "Builder" pattern, where +methods on that object return an instance of itself, so that builder methods can be chained together prior to calling +a final `create` method as follows: + +[source,java] +---- +public GremlinPlugin create() +---- + +Please see the link:http://tinkerpop.apache.org/javadocs/x.y.z/full/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.html +for an example of what implementing a `Builder` might look like in this context. + Note that the plugin provides a unique name for the plugin which follows a namespaced pattern as _namespace_._plugin-name_ -(e.g. "tinkerpop.hadoop" - "tinkerpop" is the reserved namespace for TinkerPop maintained plugins). To make TinkerGraph -classes available to the Console, the `PluginAcceptor` is given a `Set` of imports to provide to the plugin host. The -`PluginAcceptor` essentially behaves as an abstraction to the "host" that is handling the `GremlinPlugin`. `GremlinPlugin` -implementations maybe hosted by the Console as well as the `ScriptEngine` in Gremlin Server. Obviously, registering -new commands and other operations that are specific to the Groovy Shell don't make sense there. Write the code for -the plugin defensively by checking the `GremlinPlugin.env` key in the `PluginAcceptor.environment()` to understand -which environment the plugin is being used in. - -There is one other step to follow to ensure that the `GremlinPlugin` is visible to its hosts. `GremlinPlugin` -implementations are loaded via link:http://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html[ServiceLoader] +(e.g. "tinkerpop.hadoop" - "tinkerpop" is the reserved namespace for TinkerPop maintained plugins). + +For plugins that will work with Gremlin Console, there is one other step to follow to ensure that the `GremlinPlugin` +will work there. The console loads `GremlinPlugin` instances via link:http://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html[ServiceLoader] and therefore need a resource file added to the jar file where the plugin exists. Add a file called -`org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin` to `META-INF.services`. In the case of the TinkerGraph +`org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin` to `META-INF/services`. In the case of the TinkerGraph plugin above, that file will have this line in it: [source,java] ---- -include::{basedir}/tinkergraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin[] +include::{basedir}/tinkergraph-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin[] ---- Once the plugin is packaged, there are two ways to test it out: -. Copy the jar and its dependencies to the Gremlin Console path and start it. +. Copy the jar and its dependencies to the Gremlin Console path and start it. It is preferrable that the plugin is +copied to the `/ext/_plugin_name_` directory. . Start Gremlin Console and try the `:install` command: `:install com.company my-plugin 1.0.0`. In either case, once one of these two approaches is taken, the jars and their dependencies are available to the diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPlugin.java index 163e364f0b0..99e6bd9df53 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPlugin.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinPlugin.java @@ -21,6 +21,9 @@ import java.util.Optional; /** + * A plugin interface that is used by the {@link GremlinScriptEngineManager} to configure special {@link Customizer} + * instances that will alter the features of any {@link GremlinScriptEngine} created by the manager itself. + * * @author Stephen Mallette (http://stephen.genoprime.com) */ public interface GremlinPlugin { From c5360d7087a953487baf4012d8cbb5955b5c6376 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 23 Feb 2017 13:37:53 -0500 Subject: [PATCH 14/34] TINKERPOP-1612 The old plugins are gone so we no longer need to filter when generating docs --- docs/preprocessor/install-plugins.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/preprocessor/install-plugins.sh b/docs/preprocessor/install-plugins.sh index 7c58aba9084..990dbe4a296 100755 --- a/docs/preprocessor/install-plugins.sh +++ b/docs/preprocessor/install-plugins.sh @@ -39,7 +39,7 @@ while [ ${i} -lt ${pluginsCount} ]; do for part in $(tr '-' '\n' <<< ${pluginName}); do className="${className}$(tr '[:lower:]' '[:upper:]' <<< ${part:0:1})${part:1}" done - pluginClassFile=$(find . -name "${className}Plugin.java" | grep plugin) + pluginClassFile=$(find . -name "${className}Plugin.java") pluginClass=`sed -e 's@.*src/main/java/@@' -e 's/\.java$//' <<< ${pluginClassFile} | tr '/' '.'` installed=`grep -c "${pluginClass}" ${CONSOLE_HOME}/ext/plugins.txt` if [ ${installed} -eq 0 ]; then From 316845f9ede005c60045644ee771eb7a965b411b Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 23 Feb 2017 13:38:49 -0500 Subject: [PATCH 15/34] TINKERPOP-1612 Had to make the constructor public for ServiceLoader ServiceLoader couldn't instantiate the HadoopGremlinPlugin without the public constructor. --- .../tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java index 581920df270..403dd6e6768 100644 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java +++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPlugin.java @@ -132,7 +132,7 @@ public final class HadoopGremlinPlugin extends AbstractGremlinPlugin { private static final HadoopGremlinPlugin plugin = new HadoopGremlinPlugin(); - private HadoopGremlinPlugin() { + public HadoopGremlinPlugin() { super(NAME, appliesTo, imports, bindings, new HadoopConsoleCustomizer()); } From 00ba69cc44396c3b6e846315961309e09ec5fd69 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Fri, 24 Feb 2017 18:02:34 -0500 Subject: [PATCH 16/34] TINKERPOP-1612 Added an import to the doc source As we need to be careful with the number of imports now it seemed better to just add this import manually as it's really for demo purposes only in the docs. It's not a class people would normally use. --- docs/src/reference/the-traversal.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/reference/the-traversal.asciidoc b/docs/src/reference/the-traversal.asciidoc index 990f50f4dff..1e8d18b380c 100644 --- a/docs/src/reference/the-traversal.asciidoc +++ b/docs/src/reference/the-traversal.asciidoc @@ -2779,6 +2779,7 @@ console session displays the basic usage: [gremlin-groovy] ---- +import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.* graph = TinkerFactory.createModern() l = new ConsoleMutationListener(graph) strategy = EventStrategy.build().addListener(l).create() From 60797464a63a3060c0a5208e6b88d75a30310001 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Sat, 25 Feb 2017 10:44:56 -0500 Subject: [PATCH 17/34] TINKERPOP-1612 Close out :remote in every code block This helps prevent some random errors that occur during doc generation. --- docs/src/reference/gremlin-applications.asciidoc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc index 2d9a499dca1..e620372ff37 100644 --- a/docs/src/reference/gremlin-applications.asciidoc +++ b/docs/src/reference/gremlin-applications.asciidoc @@ -572,6 +572,7 @@ for purposes of execution within the context of a script. Therefore, it becomes :remote connect tinkerpop.server conf/remote-objects.yaml :remote config alias x g :> x.E().label().groupCount() +:remote close ---- [[console-sessions]] @@ -581,9 +582,10 @@ Sessions A `:remote` created in the following fashion will be "sessionless", meaning each script issued to the server with `:>` will be encased in a transaction and no state will be maintained from one request to the next. -[gremlin-groovy] +[source,groovy] ---- -:remote connect tinkerpop.server conf/remote-objects.yaml +gremlin> :remote connect tinkerpop.server conf/remote-objects.yaml +==>Configured localhost/127.0.0.1:8182 ---- In other words, the transaction will be automatically committed (or rolledback on error) and any variables declared @@ -598,6 +600,7 @@ To enable the remote to connect with a session the `connect` argument takes anot :> x = 1 :> y = 2 :> x + y +:remote close ---- With the above command a session gets created with a random UUID for a session identifier. It is also possible to @@ -622,6 +625,7 @@ x = 1 y = 2 x + y :remote console +:remote close ---- In the above example, the `:remote console` command is executed. It places the console in a state where the `:>` is @@ -649,7 +653,7 @@ Connecting via Java x.y.z ---- - + gremlin-groovy image:gremlin-java.png[width=175,float=left] TinkerPop3 comes equipped with a reference client for Java-based applications. It is referred to as Gremlin Driver, which enables applications to send requests to Gremlin Server and get back results. From ebb28d21325cfe50ec5161d3ab553d7ae3eeaecc Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Sat, 25 Feb 2017 11:17:47 -0500 Subject: [PATCH 18/34] TINKERPOP-1612 Reference GroovyTranslator with full package name It is no longer part of wildcard imports. --- docs/preprocessor/awk/init-code-blocks.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/preprocessor/awk/init-code-blocks.awk b/docs/preprocessor/awk/init-code-blocks.awk index 4f1c184ad83..27124094c5b 100644 --- a/docs/preprocessor/awk/init-code-blocks.awk +++ b/docs/preprocessor/awk/init-code-blocks.awk @@ -83,7 +83,7 @@ BEGIN { print " mapper = GraphSONMapper.build().version(GraphSONVersion.V2_0).create().createMapper()" print " bytecode = mapper.readValue(jython.eval('GraphSONWriter().writeObject(j)').toString(), Bytecode.class)" print " language = BytecodeHelper.getLambdaLanguage(bytecode).orElse('gremlin-groovy')" - print " result = language.equals('gremlin-groovy') ? groovy.eval(GroovyTranslator.of(\"g\").translate(bytecode) + '.toList()').toString() : jython.eval(JythonTranslator.of(\"h\").translate(bytecode) + '.toList()').toString()" + print " result = language.equals('gremlin-groovy') ? groovy.eval(org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator.of(\"g\").translate(bytecode) + '.toList()').toString() : jython.eval(JythonTranslator.of(\"h\").translate(bytecode) + '.toList()').toString()" print " jython.getContext().getBindings(GLOBAL_SCOPE).put('json', mapper.writeValueAsString(result))" print " return jython.eval('GraphSONReader().readObject(json)').toString()" print " } else {" From 888a911e7d328a40fda85ad23aed8da788c9686b Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Sat, 25 Feb 2017 11:18:23 -0500 Subject: [PATCH 19/34] TINKERPOP-1612 Removed a number of deprecated classes from the old plugin infrastructure --- 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 ---- ...kerpop.gremlin.groovy.plugin.GremlinPlugin | 3 - .../AbstractGremlinServerIntegrationTest.java | 64 --- .../plugin/DriverGremlinPluginTest.java | 58 --- .../DriverRemoteAcceptorIntegrateTest.java | 156 -------- .../plugin/DriverRemoteAcceptorTest.java | 140 ------- .../GephiRemoteAcceptorIntegrateTest.java | 179 --------- .../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 - .../plugin/tinkergraph-empty.properties | 18 - .../jsr223/gremlin-server-integration.yaml | 30 +- 24 files changed, 22 insertions(+), 2027 deletions(-) delete mode 100644 gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/ConsoleImportCustomizerProvider.groovy delete mode 100644 gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiRemoteAcceptor.groovy delete mode 100644 gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/GephiTraversalVisualizationStrategy.groovy delete mode 100644 gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPlugin.java delete mode 100644 gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptor.java delete mode 100644 gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiGremlinPlugin.java delete mode 100644 gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPlugin.java delete mode 100644 gremlin-console/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/AbstractGremlinServerIntegrationTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverGremlinPluginTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorIntegrateTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/DriverRemoteAcceptorTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GephiRemoteAcceptorIntegrateTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SpyPluginAcceptor.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SugarGremlinPluginTest.java delete mode 100644 gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginTest.java delete mode 100644 gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/gremlin-server-integration.yaml delete mode 100644 gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/remote.yaml delete mode 100644 gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy delete mode 100644 gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy delete mode 100644 gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/tinkergraph-empty.properties diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index a9a70f73189..9a58f082c7a 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` 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 85fda8ce3ef..00000000000 --- 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 getCombinedStaticImports() { - final Set combined = new HashSet<>(); - combined.addAll(getStaticImports()); - combined.addAll(extraStaticImports); - - return Collections.unmodifiableSet(combined); - } - - public Set getCombinedImports() { - final Set combined = new HashSet<>(); - combined.addAll(getImports()); - combined.addAll(extraImports); - - return Collections.unmodifiableSet(combined); - } -} 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 902a479e176..00000000000 --- 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 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 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 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") - } - } -} 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 c19de06381a..00000000000 --- 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 - implements TraversalStrategy.FinalizationStrategy { - - private static final Set> 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 graphSteps = TraversalHelper.getStepsOfAssignableClass(GraphStep.class, traversal) - final List vertexSteps = TraversalHelper.getStepsOfAssignableClass(VertexStep.class, traversal) - - def List 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 vertices = ((BulkSet) 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 objects = ((BulkSet) traverser.sideEffects(sideEffectKey)) - if (!objects.isEmpty()) { - final List 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> applyPost() { - return POSTS; - } -} 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 2f8fc755869..00000000000 --- 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 IMPORTS = new HashSet() {{ - 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() { - return null == this.shell ? Optional.empty() : Optional.of(new DriverRemoteAcceptor(this.shell)); - } -} 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 80e8194b979..00000000000 --- 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 aliases = new HashMap<>(); - private Optional 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 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 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 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 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 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 args) throws RemoteException { - final String line = RemoteAcceptor.getScript(String.join(" ", args), this.shell); - - try { - final List 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 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 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 = 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 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()) : ""; - } -} 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 df0541f4fea..00000000000 --- 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() { - return Optional.of(new GephiRemoteAcceptor(shell, io)); - } - - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - // do nothing - } -} 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 d1c853d49e3..00000000000 --- 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 IMPORTS = new HashSet() {{ - 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()); - } - } -} 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 a74add49f23..00000000000 --- 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 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 a6787e6f800..00000000000 --- 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(); - } -} 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 6ff5721c44d..00000000000 --- 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 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)); - } -} 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 1363c265f96..00000000000 --- 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) 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) 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) 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) acceptor.submit(Collections.singletonList("[1,2,3,4,5]")))), contains("1", "2", "3", "4", "5")); - assertThat(((List) 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) acceptor.submit(Collections.singletonList("g.addVertex('name','stephen');g.addVertex('name','marko');g.traversal().V()")))), hasSize(2)); - assertThat(((List) 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) acceptor.submit(Collections.singletonList("x.addVertex('name','stephen');x.addVertex('name','marko');x.traversal().V()")))), hasSize(2)); - assertThat(((List) 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) acceptor.submit(Collections.singletonList("g.traversal().V().drop().iterate();null")))), contains("null")); - assertThat(((List) 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) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString()); - assertEquals("4", ((Iterator) acceptor.submit(Collections.singletonList("x+2"))).next()); - assertEquals("4", ((List) 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) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString()); - assertEquals("4", ((Iterator) acceptor.submit(Collections.singletonList("x+2"))).next()); - assertEquals("4", ((List) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString()); - } -} 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 ef2a0c6c116..00000000000 --- 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 resetAliases = (Map) 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 shownAliases = (Map) acceptor.configure(Arrays.asList("alias", "show")); - assertEquals(0, shownAliases.size()); - } - - @Test - public void shouldAddOverwriteAndShowAliases() throws Exception { - final Map aliases = (Map) 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 resetAliases = (Map) acceptor.configure(Arrays.asList("alias", "g", "main.social")); - assertEquals(1, resetAliases.size()); - assertEquals("main.social", resetAliases.get("g")); - - final Map shownAliases = (Map) 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 ")); - } -} 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 afda5288a06..00000000000 --- 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); - } - } -} 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 fb8f99033a4..00000000000 --- 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 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 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 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 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 bindingsFromSpy = spy.getBindings(); - assertEquals(1, bindingsFromSpy.get("x")); - assertEquals("yes", bindingsFromSpy.get("y")); - assertEquals(true, bindingsFromSpy.get("z")); - } -} diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SpyPluginAcceptor.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SpyPluginAcceptor.java deleted file mode 100644 index dae34cad09f..00000000000 --- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SpyPluginAcceptor.java +++ /dev/null @@ -1,87 +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.PluginAcceptor; - -import javax.script.ScriptException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.function.Supplier; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class SpyPluginAcceptor implements PluginAcceptor { - - private final Set imports = new HashSet<>(); - private final Map bindings = new HashMap<>(); - - private final Function evalSpy; - private final Supplier> environment; - - public SpyPluginAcceptor() { - this(script -> script); - } - - public SpyPluginAcceptor(final Function evalSpy) { - this(evalSpy, HashMap::new); - } - - public SpyPluginAcceptor(final Supplier> environmentMaker) { - this(script -> script, environmentMaker); - } - - public SpyPluginAcceptor(final Function evalSpy, final Supplier> environmentMaker) { - this.evalSpy = evalSpy; - this.environment = environmentMaker; - } - - @Override - public void addImports(final Set importStatements) { - imports.addAll(importStatements); - } - - @Override - public void addBinding(final String key, final Object val) { - bindings.put(key, val); - } - - @Override - public Map getBindings() { - return bindings; - } - - @Override - public Object eval(final String script) throws ScriptException { - return evalSpy.apply(script); - } - - @Override - public Map environment() { - return environment.get(); - } - - public Set getImports() { - return imports; - } -} diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SugarGremlinPluginTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SugarGremlinPluginTest.java deleted file mode 100644 index 4b18cea360c..00000000000 --- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/SugarGremlinPluginTest.java +++ /dev/null @@ -1,63 +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.SugarGremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.util.MetaRegistryUtil; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.codehaus.groovy.tools.shell.Groovysh; -import org.codehaus.groovy.tools.shell.IO; -import org.junit.Test; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -/** - * This test lives here (even though the SugarPlugin is over in gremlin-groovy, because it really tests the - * plugin with respect to the Console. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class SugarGremlinPluginTest { - @Test - public void shouldPluginSugar() throws Exception { - MetaRegistryUtil.clearRegistry(new HashSet<>(Arrays.asList(TinkerGraph.class))); - - final SugarGremlinPlugin plugin = new SugarGremlinPlugin(); - - final Groovysh groovysh = new Groovysh(); - - final Map env = new HashMap<>(); - env.put("ConsolePluginAcceptor.io", new IO()); - env.put("ConsolePluginAcceptor.shell", groovysh); - - final SpyPluginAcceptor spy = new SpyPluginAcceptor(groovysh::execute, () -> env); - plugin.pluginTo(spy); - - groovysh.getInterp().getContext().setProperty("g", TinkerFactory.createClassic()); - assertEquals(6l, ((GraphTraversal) groovysh.execute("g.traversal().V()")).count().next()); - assertEquals(6l, ((GraphTraversal) groovysh.execute("g.traversal().V")).count().next()); - } -} diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginTest.java deleted file mode 100644 index 37a0eef749c..00000000000 --- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/UtilitiesGremlinPluginTest.java +++ /dev/null @@ -1,72 +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.tinkergraph.structure.TinkerFactory; -import org.codehaus.groovy.tools.shell.Groovysh; -import org.codehaus.groovy.tools.shell.IO; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class UtilitiesGremlinPluginTest { - @Test - public void shouldPluginToAndDoImports() throws Exception { - final UtilitiesGremlinPlugin plugin = new UtilitiesGremlinPlugin(); - final SpyPluginAcceptor spy = new SpyPluginAcceptor(); - plugin.pluginTo(spy); - - assertEquals(4, spy.getImports().size()); - } - - @Test - public void shouldFailWithoutUtilitiesPlugin() throws Exception { - final Groovysh groovysh = new Groovysh(); - try { - groovysh.execute("describeGraph(g.class)"); - fail("Utilities were not loaded - this should fail."); - } catch (Exception ignored) { - } - } - - @Test - public void shouldPluginUtilities() throws Exception { - final UtilitiesGremlinPlugin plugin = new UtilitiesGremlinPlugin(); - - final Groovysh groovysh = new Groovysh(); - groovysh.getInterp().getContext().setProperty("g", TinkerFactory.createClassic()); - - final Map env = new HashMap<>(); - env.put("ConsolePluginAcceptor.io", new IO()); - env.put("ConsolePluginAcceptor.shell", groovysh); - - final SpyPluginAcceptor spy = new SpyPluginAcceptor(groovysh::execute, () -> env); - plugin.pluginTo(spy); - - assertThat(groovysh.execute("describeGraph(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph)").toString(), containsString("IMPLEMENTATION - org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph")); - } -} diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/gremlin-server-integration.yaml b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/gremlin-server-integration.yaml deleted file mode 100644 index a7ef1a98021..00000000000 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/gremlin-server-integration.yaml +++ /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. - -host: localhost -port: 45940 -threadPoolWorker: 1 -gremlinPool: 8 -scriptEvaluationTimeout: 30000 -serializedResponseTimeout: 30000 -graphs: { - g: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph -scriptEngines: { - gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI]}} -serializers: - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 } - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 } -processors: - - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} -metrics: { - consoleReporter: {enabled: true, interval: 180000}, - csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv}, - jmxReporter: {enabled: true}, - slf4jReporter: {enabled: true, interval: 180000}, - gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST}, - graphiteReporter: {enabled: false, interval: 180000}} -threadPoolBoss: 1 -maxInitialLineLength: 4096 -maxHeaderSize: 8192 -maxChunkSize: 8192 -maxContentLength: 65536 -maxAccumulationBufferComponents: 1024 -resultIterationBatchSize: 64 -writeBufferHighWaterMark: 32768 -writeBufferHighWaterMark: 65536 diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/remote.yaml b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/remote.yaml deleted file mode 100644 index 373934b2871..00000000000 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/remote.yaml +++ /dev/null @@ -1,20 +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. - -hosts: [localhost] -port: 45940 -serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} \ No newline at end of file diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy deleted file mode 100644 index c2cc784523b..00000000000 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-1.groovy +++ /dev/null @@ -1,3 +0,0 @@ -x = 1 + 1 -y = 10 * x -z = 1 + x + y \ No newline at end of file diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy deleted file mode 100644 index 1a4f9a9200f..00000000000 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/script-customizer-2.groovy +++ /dev/null @@ -1,2 +0,0 @@ -l = g.V(z).out() - .group().by('name') \ No newline at end of file diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/tinkergraph-empty.properties b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/tinkergraph-empty.properties deleted file mode 100644 index 6590d391616..00000000000 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/groovy/plugin/tinkergraph-empty.properties +++ /dev/null @@ -1,18 +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. - -gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph \ No newline at end of file diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/gremlin-server-integration.yaml b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/gremlin-server-integration.yaml index a7ef1a98021..0f6a3316bf5 100644 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/gremlin-server-integration.yaml +++ b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/gremlin-server-integration.yaml @@ -17,25 +17,23 @@ host: localhost port: 45940 -threadPoolWorker: 1 -gremlinPool: 8 scriptEvaluationTimeout: 30000 -serializedResponseTimeout: 30000 -graphs: { - g: conf/tinkergraph-empty.properties} -plugins: - - tinkerpop.tinkergraph +channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}}}} serializers: - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true}} - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 } - - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 } + - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { }} # application/vnd.gremlin-v1.0+gryo + - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { }} # application/vnd.gremlin-v1.0+gryo-lite + - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} # application/vnd.gremlin-v1.0+gryo-stringd + - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0] }} # application/vnd.gremlin-v1.0+json + - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }} # application/vnd.gremlin-v2.0+json + - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { }} # application/json,application/vnd.gremlin-v3.0+json processors: - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} + - { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }} metrics: { consoleReporter: {enabled: true, interval: 180000}, csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv}, @@ -43,12 +41,14 @@ metrics: { slf4jReporter: {enabled: true, interval: 180000}, gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST}, graphiteReporter: {enabled: false, interval: 180000}} -threadPoolBoss: 1 +strictTransactionManagement: false maxInitialLineLength: 4096 maxHeaderSize: 8192 maxChunkSize: 8192 maxContentLength: 65536 maxAccumulationBufferComponents: 1024 resultIterationBatchSize: 64 -writeBufferHighWaterMark: 32768 +writeBufferLowWaterMark: 32768 writeBufferHighWaterMark: 65536 +ssl: { + enabled: false} \ No newline at end of file From a3706f6632bacd144f0a09127dec7521d7f82707 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Sat, 25 Feb 2017 11:48:40 -0500 Subject: [PATCH 20/34] TINKERPOP-1612 Removed dependency on gremlin-groovy-test from hadoop-gremlin --- hadoop-gremlin/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hadoop-gremlin/pom.xml b/hadoop-gremlin/pom.xml index 927b2afa3d8..5dbcfe93355 100644 --- a/hadoop-gremlin/pom.xml +++ b/hadoop-gremlin/pom.xml @@ -137,12 +137,6 @@ limitations under the License. ${project.version} test - - org.apache.tinkerpop - gremlin-groovy-test - ${project.version} - test - org.apache.tinkerpop tinkergraph-gremlin From ec053040b22df04f770277eb3dbdeed4210fcf80 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Sat, 25 Feb 2017 11:49:01 -0500 Subject: [PATCH 21/34] TINKERPOP-1612 Allow any scriptengine to be used for ScriptRecordReader --- .../structure/io/script/ScriptRecordReader.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java index ea72f9ad3c6..3299c1c985b 100644 --- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java +++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordReader.java @@ -27,12 +27,11 @@ import org.apache.hadoop.mapreduce.RecordReader; import org.apache.hadoop.mapreduce.TaskAttemptContext; import org.apache.hadoop.mapreduce.lib.input.LineRecordReader; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.hadoop.Constants; import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable; import org.apache.tinkerpop.gremlin.hadoop.structure.util.ConfUtil; +import org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager; +import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager; import org.apache.tinkerpop.gremlin.process.computer.GraphFilter; import org.apache.tinkerpop.gremlin.process.computer.util.VertexProgramHelper; import org.apache.tinkerpop.gremlin.structure.Edge; @@ -58,13 +57,14 @@ public final class ScriptRecordReader extends RecordReader { protected final static String SCRIPT_FILE = "gremlin.hadoop.scriptInputFormat.script"; - //protected final static String SCRIPT_ENGINE = "gremlin.hadoop.scriptInputFormat.scriptEngine"; + protected final static String SCRIPT_ENGINE = "gremlin.hadoop.scriptInputFormat.scriptEngine"; private final static String GRAPH = "graph"; private final static String LINE = "line"; private final static String FACTORY = "factory"; private final static String READ_CALL = "parse(" + LINE + "," + FACTORY + ")"; private final VertexWritable vertexWritable = new VertexWritable(); private final LineRecordReader lineRecordReader; + private final GremlinScriptEngineManager manager = new CachedGremlinScriptEngineManager(); private ScriptEngine engine; private String parse; @@ -82,8 +82,7 @@ public void initialize(final InputSplit genericSplit, final TaskAttemptContext c final Configuration configuration = context.getConfiguration(); if (configuration.get(Constants.GREMLIN_HADOOP_GRAPH_FILTER, null) != null) this.graphFilter = VertexProgramHelper.deserialize(ConfUtil.makeApacheConfiguration(configuration), Constants.GREMLIN_HADOOP_GRAPH_FILTER); - this.engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) new DefaultImportCustomizerProvider()); - //this.engine = ScriptEngineCache.get(configuration.get(SCRIPT_ENGINE, ScriptEngineCache.DEFAULT_SCRIPT_ENGINE)); + this.engine = manager.getEngineByName(configuration.get(SCRIPT_ENGINE, "gremlin-groovy")); final FileSystem fs = FileSystem.get(configuration); try (final InputStream stream = fs.open(new Path(configuration.get(SCRIPT_FILE))); final InputStreamReader reader = new InputStreamReader(stream)) { From 9d26abaa80b41d27f85bd3b1c290f8f68f46c5da Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 12:36:11 -0500 Subject: [PATCH 22/34] TINKERPOP-1612 Factored out all the adapters between old/new plugin system in the console. --- docs/src/upgrade/release-3.3.x.asciidoc | 2 + .../tinkerpop/gremlin/console/Console.groovy | 2 +- .../tinkerpop/gremlin/console/Mediator.groovy | 2 +- .../gremlin/console/PluggedIn.groovy | 115 +++--------- .../console/commands/InstallCommand.groovy | 2 +- .../console/commands/RemoteCommand.groovy | 7 +- .../plugin/ConsolePluginAcceptor.groovy | 67 ------- .../gremlin/console/plugin/PluggedIn.groovy | 173 ------------------ .../jsr223/UtilitiesGremlinPluginTest.java | 7 +- .../jsr223/console/ConsoleCustomizer.java | 4 + .../jsr223/console/PluginAcceptor.java | 64 ------- 11 files changed, 42 insertions(+), 403 deletions(-) delete mode 100644 gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy delete mode 100644 gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy delete mode 100644 gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index 9a58f082c7a..db35b9b4a8e 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -182,6 +182,7 @@ The following deprecated classes, methods or fields have been removed in this ve * `gremlin-console` ** `org.apache.tinkerpop.gremlin.console.Console(String)` ** `org.apache.tinkerpop.gremlin.console.ConsoleImportCustomizerProvider` +** `org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor` ** `org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor` ** `org.apache.tinkerpop.gremlin.console.plugin.GephiTraversalVisualizationStrategy` ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin` @@ -192,6 +193,7 @@ The following deprecated classes, methods or fields have been removed in this ve ** `org.apache.tinkerpop.gremlin.jsr223.CoreGremlinModule` ** `org.apache.tinkerpop.gremlin.jsr223.GremlinModule` ** `org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager#addModule(GremlinModule)` +** `org.apache.tinkerpop.gremlin.jsr223.console.PluginAcceptor` ** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_STANDARD` ** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_COMPUTER` ** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT` diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy index 57eca8b573e..9e0b6825892 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy @@ -115,7 +115,7 @@ class Console { def activePlugins = Mediator.readPluginState() ServiceLoader.load(GremlinPlugin, groovy.getInterp().getClassLoader()).each { plugin -> if (!mediator.availablePlugins.containsKey(plugin.class.name)) { - def pluggedIn = new PluggedIn(new PluggedIn.GremlinPluginAdapter((GremlinPlugin) plugin, groovy, io), groovy, io, false) + def pluggedIn = new PluggedIn((GremlinPlugin) plugin, groovy, io, false) mediator.availablePlugins.put(plugin.class.name, pluggedIn) diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy index 3d0134053c9..7c89ca46929 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.console -import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor +import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor /** * @author Stephen Mallette (http://stephen.genoprime.com) diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy index a1e1ee7c42f..e8a3b8a46d7 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy @@ -18,13 +18,13 @@ */ package org.apache.tinkerpop.gremlin.console -import org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor -import org.apache.tinkerpop.gremlin.groovy.plugin.* import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer +import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment +import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor import org.codehaus.groovy.tools.shell.Groovysh import org.codehaus.groovy.tools.shell.IO @@ -55,7 +55,17 @@ class PluggedIn { } void activate() { - plugin.pluginTo(new ConsolePluginAcceptor(shell, io)) + plugin.getCustomizers("gremlin-groovy").get().each { + if (it instanceof ImportCustomizer) { + it.getClassPackages().collect {Mediator.IMPORT_SPACE + it.getName() + Mediator.IMPORT_WILDCARD }.each { shell.execute(it) } + it.getMethodClasses().collect {Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {shell.execute(it)} + it.getEnumClasses().collect {Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {shell.execute(it)} + } else if (it instanceof ScriptCustomizer) { + it.getScripts().collect { it.join(LINE_SEPARATOR) }.each { shell.execute(it) } + } else if (it instanceof BindingsCustomizer) { + it.bindings.entrySet().each { kv -> shell.getInterp().getContext().setProperty(kv.key, kv.value) } + } + } this.activated = true } @@ -63,104 +73,35 @@ class PluggedIn { this.activated = false } - public static class GremlinPluginAdapter implements GremlinPlugin { - org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin - private final Groovysh shell - private final IO io - - public GremlinPluginAdapter(final org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin, final Groovysh shell, final IO io) { - this.corePlugin = corePlugin - this.shell = shell - this.io = io - } - - @Override - String getName() { - return corePlugin.getName() - } - - @Override - void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - corePlugin.getCustomizers("gremlin-groovy").get().each { - if (it instanceof ImportCustomizer) { - def imports = [] as Set - it.getClassPackages().collect {Mediator.IMPORT_SPACE + it.getName() + Mediator.IMPORT_WILDCARD }.each { imports.add(it) } - it.getMethodClasses().collect {Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {imports.add(it)} - it.getEnumClasses().collect {Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {imports.add(it)} - pluginAcceptor.addImports(imports) - } else if (it instanceof ScriptCustomizer) { - it.getScripts().collect { it.join(LINE_SEPARATOR) }.each { pluginAcceptor.eval(it) } - } else if (it instanceof BindingsCustomizer) { - it.bindings.entrySet().each { kv -> pluginAcceptor.addBinding(kv.key, kv.value) } - } - } - } - - @Override - boolean requireRestart() { - return corePlugin.requireRestart() - } - - @Override - Optional remoteAcceptor() { - // find a consoleCustomizer if available - if (!corePlugin.getCustomizers("gremlin-groovy").isPresent() || !corePlugin.getCustomizers("gremlin-groovy").get().any{ it instanceof ConsoleCustomizer }) - return Optional.empty() - - ConsoleCustomizer customizer = (ConsoleCustomizer) corePlugin.getCustomizers("gremlin-groovy").get().find{ it instanceof ConsoleCustomizer } - return Optional.of(new RemoteAcceptorAdapter(customizer.getRemoteAcceptor(new GroovyGremlinShellEnvironment()))) - } - - public class GroovyGremlinShellEnvironment implements GremlinShellEnvironment { - - @Override - def T getVariable(final String variableName) { - return (T) shell.interp.context.getVariable(variableName) - } - - @Override - def void setVariable(final String variableName, final T variableValue) { - shell.interp.context.setVariable(variableName, variableValue) - } + Optional remoteAcceptor() { + // find a consoleCustomizer if available + if (!plugin.getCustomizers("gremlin-groovy").isPresent() || !plugin.getCustomizers("gremlin-groovy").get().any{ it instanceof ConsoleCustomizer }) + return Optional.empty() - @Override - void println(final String line) { - io.println(line) - } - - @Override - def T execute(final String line) { - return (T) shell.execute(line) - } - } + ConsoleCustomizer customizer = (ConsoleCustomizer) plugin.getCustomizers("gremlin-groovy").get().find{ it instanceof ConsoleCustomizer } + return Optional.of(customizer.getRemoteAcceptor(new GroovyGremlinShellEnvironment())) } - public static class RemoteAcceptorAdapter implements RemoteAcceptor { - - private org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor remoteAcceptor - - public RemoteAcceptorAdapter(org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor remoteAcceptor) { - this.remoteAcceptor = remoteAcceptor - } + public class GroovyGremlinShellEnvironment implements GremlinShellEnvironment { @Override - Object connect(final List args) throws RemoteException { - return remoteAcceptor.connect(args) + def T getVariable(final String variableName) { + return (T) shell.interp.context.getVariable(variableName) } @Override - Object configure(final List args) throws RemoteException { - return remoteAcceptor.configure(args) + def void setVariable(final String variableName, final T variableValue) { + shell.interp.context.setVariable(variableName, variableValue) } @Override - Object submit(final List args) throws RemoteException { - return remoteAcceptor.submit(args) + void println(final String line) { + io.println(line) } @Override - void close() throws IOException { - remoteAcceptor.close() + def T execute(final String line) { + return (T) shell.execute(line) } } } diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy index 11880272cff..9736f444b4c 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy @@ -66,7 +66,7 @@ class InstallCommand extends CommandSupport { // from within there given loading through Grape. ServiceLoader.load(GremlinPlugin, shell.getInterp().getClassLoader()).forEach { plugin -> if (!mediator.availablePlugins.containsKey(plugin.class.name)) { - mediator.availablePlugins.put(plugin.class.name, new PluggedIn(new PluggedIn.GremlinPluginAdapter((GremlinPlugin) plugin, shell, io), shell, io, false)) + mediator.availablePlugins.put(plugin.class.name, new PluggedIn((GremlinPlugin) plugin, shell, io, false)) if (plugin.requireRestart()) pluginsThatNeedRestart << plugin.name } diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy index dccebd39427..68e48d9d217 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy @@ -19,8 +19,8 @@ package org.apache.tinkerpop.gremlin.console.commands import org.apache.tinkerpop.gremlin.console.Mediator -import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor -import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException +import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor +import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException import org.codehaus.groovy.tools.shell.ComplexCommandSupport import org.codehaus.groovy.tools.shell.Groovysh @@ -47,8 +47,7 @@ class RemoteCommand extends ComplexCommandSupport { def pluggedIn = mediator.availablePlugins.values().find { it.plugin.name == arguments[0] } if (!pluggedIn.activated) return "Plugin is available but not activated with ':plugin use ${arguments[0]}'" - def plugin = pluggedIn.plugin - def Optional remoteAcceptor = plugin.remoteAcceptor() + def Optional remoteAcceptor = pluggedIn.remoteAcceptor() if (!remoteAcceptor.isPresent()) return "${arguments[0]} does not accept remote configuration" try { diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy deleted file mode 100644 index bbb2dfda152..00000000000 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy +++ /dev/null @@ -1,67 +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 org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin -import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor -import org.codehaus.groovy.tools.shell.Groovysh -import org.codehaus.groovy.tools.shell.IO - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, not replaced. - */ -@Deprecated -class ConsolePluginAcceptor implements PluginAcceptor, org.apache.tinkerpop.gremlin.jsr223.console.PluginAcceptor { - - public static final String ENVIRONMENT_NAME = "console"; - public static final String ENVIRONMENT_SHELL = "ConsolePluginAcceptor.shell" - public static final String ENVIRONMENT_IO = "ConsolePluginAcceptor.io" - - private final Groovysh shell - private final IO io - - public ConsolePluginAcceptor(final Groovysh shell, final IO io) { - this.shell = shell - this.io = io - } - - @Override - void addBinding(final String key, final Object val) { - shell.interp.context.setVariable(key, val) - } - - @Override - Map getBindings() { - return Collections.unmodifiableMap(shell.interp.context.variables) - } - - @Override - void addImports(final Set importStatements) { - importStatements.each { this.shell.execute(it) } - } - - @Override - Object eval(final String script) throws javax.script.ScriptException { return this.shell.execute(script) } - - @Override - Map environment() { - return [(GremlinPlugin.ENVIRONMENT): ENVIRONMENT_NAME, (ENVIRONMENT_IO): io, (ENVIRONMENT_SHELL): shell] - } -} \ No newline at end of file diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy deleted file mode 100644 index a4afb28f075..00000000000 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy +++ /dev/null @@ -1,173 +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 org.apache.tinkerpop.gremlin.console.Mediator -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin -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 org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException -import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer -import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer -import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer -import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer -import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment -import org.codehaus.groovy.tools.shell.Groovysh -import org.codehaus.groovy.tools.shell.IO - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link org.apache.tinkerpop.gremlin.console.PluggedIn} - */ -@Deprecated -class PluggedIn { - private static final String LINE_SEPARATOR = System.getProperty("line.separator") - private final GremlinPlugin plugin - private boolean activated = false - - private final Groovysh shell - private final IO io - - public PluggedIn(final GremlinPlugin plugin, final Groovysh shell, final IO io, final boolean activated) { - this.plugin = plugin - this.activated = activated - this.shell = shell - this.io = io - } - - GremlinPlugin getPlugin() { - return plugin - } - - boolean getActivated() { - return activated - } - - void activate() { - plugin.pluginTo(new ConsolePluginAcceptor(shell, io)) - this.activated = true - } - - void deactivate() { - this.activated = false - } - - public static class GremlinPluginAdapter implements GremlinPlugin { - org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin - private final Groovysh shell - private final IO io - - public GremlinPluginAdapter(final org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin, final Groovysh shell, final IO io) { - this.corePlugin = corePlugin - this.shell = shell - this.io = io - } - - @Override - String getName() { - return corePlugin.getName() - } - - @Override - void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - corePlugin.getCustomizers("gremlin-groovy").get().each { - if (it instanceof ImportCustomizer) { - def imports = [] as Set - it.getClassPackages().collect {Mediator.IMPORT_SPACE + it.getName() + Mediator.IMPORT_WILDCARD }.each { imports.add(it) } - it.getMethodClasses().collect {Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {imports.add(it)} - it.getEnumClasses().collect {Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {imports.add(it)} - pluginAcceptor.addImports(imports) - } else if (it instanceof ScriptCustomizer) { - it.getScripts().collect { it.join(LINE_SEPARATOR) }.each { pluginAcceptor.eval(it) } - } else if (it instanceof BindingsCustomizer) { - it.bindings.entrySet().each { kv -> pluginAcceptor.addBinding(kv.key, kv.value) } - } - } - } - - @Override - boolean requireRestart() { - return corePlugin.requireRestart() - } - - @Override - Optional remoteAcceptor() { - // find a consoleCustomizer if available - if (!corePlugin.getCustomizers("gremlin-groovy").isPresent() || !corePlugin.getCustomizers("gremlin-groovy").get().any{ it instanceof ConsoleCustomizer }) - return Optional.empty() - - ConsoleCustomizer customizer = (ConsoleCustomizer) corePlugin.getCustomizers("gremlin-groovy").get().find{ it instanceof ConsoleCustomizer } - return Optional.of(new RemoteAcceptorAdapter(customizer.getRemoteAcceptor(new GroovyGremlinShellEnvironment()))) - } - - public class GroovyGremlinShellEnvironment implements GremlinShellEnvironment { - - @Override - def T getVariable(final String variableName) { - return (T) shell.interp.context.getVariable(variableName) - } - - @Override - def void setVariable(final String variableName, final T variableValue) { - shell.interp.context.setVariable(variableName, variableValue) - } - - @Override - void println(final String line) { - io.println(line) - } - - @Override - def T execute(final String line) { - return (T) shell.execute(line) - } - } - } - - public static class RemoteAcceptorAdapter implements RemoteAcceptor { - - private org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor remoteAcceptor - - public RemoteAcceptorAdapter(org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor remoteAcceptor) { - this.remoteAcceptor = remoteAcceptor - } - - @Override - Object connect(final List args) throws RemoteException { - return remoteAcceptor.connect(args) - } - - @Override - Object configure(final List args) throws RemoteException { - return remoteAcceptor.configure(args) - } - - @Override - Object submit(final List args) throws RemoteException { - return remoteAcceptor.submit(args) - } - - @Override - void close() throws IOException { - remoteAcceptor.close() - } - } -} diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java index 65b2ee0bfd9..385e0869669 100644 --- a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java +++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java @@ -19,7 +19,6 @@ package org.apache.tinkerpop.gremlin.console.jsr223; import org.apache.commons.io.input.NullInputStream; -import org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor; import org.apache.tinkerpop.gremlin.console.PluggedIn; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.codehaus.groovy.tools.shell.Groovysh; @@ -60,10 +59,8 @@ public void shouldPluginUtilities() throws Exception { final Groovysh groovysh = new Groovysh(); groovysh.getInterp().getContext().setProperty("g", TinkerFactory.createClassic()); - final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin, groovysh, io); - final ConsolePluginAcceptor acceptor = new ConsolePluginAcceptor(groovysh, io); - - adapter.pluginTo(acceptor); + final PluggedIn pluggedIn = new PluggedIn(plugin, groovysh, io, false); + pluggedIn.activate(); assertThat(groovysh.execute("describeGraph(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph)").toString(), containsString("IMPLEMENTATION - org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph")); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java index 92044884213..4ab851ebed5 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java @@ -19,8 +19,12 @@ package org.apache.tinkerpop.gremlin.jsr223.console; import org.apache.tinkerpop.gremlin.jsr223.Customizer; +import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin; /** + * A {@link Customizer} that allows a {@link RemoteAcceptor} to be used with a console implementation. Only one + * {@code ConsoleCustomizer} can be added to a particular {@link GremlinPlugin}. + * * @author Stephen Mallette (http://stephen.genoprime.com) */ public interface ConsoleCustomizer extends Customizer { diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java deleted file mode 100644 index cd6951b03b2..00000000000 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.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.jsr223.console; - -import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin; - -import javax.script.ScriptException; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -/** - * A {@link GremlinPlugin} can be used in multiple environments (e.g. ScriptEngine implementation). Any environment - * wishing to allow plugins should implement the {@code PluginAcceptor}. It acts as an adapter to those environments - * and provides the abstractions required for a plugin to work regardless of the environmental implementations. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, not replaced. - */ -@Deprecated -public interface PluginAcceptor { - - public void addImports(final Set importStatements); - - /** - * Add a variable binding for the plugin host. - */ - public void addBinding(final String key, final Object val); - - /** - * Gets the list of bindings from the plugin host. These bindings will represent the "global" binding list. - */ - public Map getBindings(); - - /** - * Evaluate a script in the {@code PluginAcceptor}. - */ - public Object eval(final String script) throws ScriptException; - - /** - * Returns a map of implementation specific variables that can be referenced by the plugin. Those writing - * plugins should examine the details of the various {@code PluginAcceptor} implementations for the variables - * that they pass, as they may provide important information useful to the plugin itself. - */ - public default Map environment() { - return Collections.emptyMap(); - } -} From 680fa3f9304884cbec05f8629b57ac0ac4554f20 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 12:51:02 -0500 Subject: [PATCH 23/34] TINKERPOP-1612 Minor fix to upgrade docs The entire package was removed, better to refer to it with a wildcard. --- docs/src/upgrade/release-3.3.x.asciidoc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index db35b9b4a8e..72be2aa996a 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -182,9 +182,7 @@ The following deprecated classes, methods or fields have been removed in this ve * `gremlin-console` ** `org.apache.tinkerpop.gremlin.console.Console(String)` ** `org.apache.tinkerpop.gremlin.console.ConsoleImportCustomizerProvider` -** `org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor` -** `org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor` -** `org.apache.tinkerpop.gremlin.console.plugin.GephiTraversalVisualizationStrategy` +** `org.apache.tinkerpop.gremlin.console.plugin.* ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin` ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverRemoteAcceptor` ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.GephiGremlinPlugin` From af3bdf9eae7282d4187d8175b1c54e1fb5ce0863 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 13:16:55 -0500 Subject: [PATCH 24/34] TINKERPOP-1612 Cleaned up some imports --- .../tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java | 3 ++- .../gremlin/console/jsr223/UtilitiesGremlinPlugin.java | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java index c30f8641b61..aa9f9a2dcdb 100644 --- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java +++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/GephiGremlinPlugin.java @@ -21,6 +21,7 @@ import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin; import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer; import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment; +import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor; /** * @author Stephen Mallette (http://stephen.genoprime.com) @@ -34,7 +35,7 @@ public GephiGremlinPlugin() { private static class GephiConsoleCustomizer implements ConsoleCustomizer { @Override - public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment gremlinShellEnvironment) { + public RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment gremlinShellEnvironment) { return new GephiRemoteAcceptor(gremlinShellEnvironment); } } diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java index 57bacda2f97..6b8f9d30250 100644 --- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java +++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPlugin.java @@ -18,10 +18,7 @@ */ package org.apache.tinkerpop.gremlin.console.jsr223; -import groovyx.gbench.Benchmark; -import groovyx.gbench.BenchmarkStaticExtension; import groovyx.gprof.ProfileStaticExtension; -import groovyx.gprof.Profiler; import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin; import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; import org.apache.tinkerpop.gremlin.jsr223.DefaultScriptCustomizer; From 2f0b8504eb3287b9ad883a6e774597bf37825733 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 17:03:35 -0500 Subject: [PATCH 25/34] TINKERPOP-1421 TINKERPOP-1621 Removed deprecated GremlinPlugin/ControlOps infrastructure --- CHANGELOG.asciidoc | 2 + docs/src/upgrade/release-3.3.x.asciidoc | 31 +- .../groovy/util/DependencyGrabber.groovy | 14 - .../AbstractImportCustomizerProvider.java | 221 --------- .../groovy/CompilerCustomizerProvider.java | 39 -- .../DefaultImportCustomizerProvider.java | 80 --- .../groovy/EmptyImportCustomizerProvider.java | 87 ---- .../groovy/ImportCustomizerProvider.java | 41 -- .../groovy/NoImportCustomizerProvider.java | 64 --- .../groovy/engine/GremlinExecutor.java | 247 +--------- .../gremlin/groovy/engine/ScriptEngines.java | 461 ------------------ .../groovy/jsr223/DependencyManager.java | 84 ---- .../jsr223/GremlinGroovyScriptEngine.java | 198 +------- .../jsr223/ScriptEnginePluginAcceptor.java | 96 ---- .../TimedInterruptTimeoutException.java | 4 +- .../jsr223/TypeCheckedGroovyCustomizer.java | 1 - .../CompileStaticCustomizerProvider.java | 64 --- .../ConfigurationCustomizerProvider.java | 86 ---- .../InterpreterModeCustomizerProvider.java | 42 -- .../ThreadInterruptCustomizerProvider.java | 39 -- .../TimedInterruptCustomizerProvider.java | 66 --- .../TimedInterruptTimeoutException.java | 38 -- .../TypeCheckedCustomizerProvider.java | 68 --- .../VariableIdentificationCustomizer.java | 93 ---- .../groovy/plugin/AbstractGremlinPlugin.java | 99 ---- .../gremlin/groovy/plugin/Artifact.java | 88 ---- .../gremlin/groovy/plugin/GremlinPlugin.java | 72 --- .../groovy/plugin/GremlinPluginException.java | 43 -- .../plugin/IllegalEnvironmentException.java | 33 -- .../gremlin/groovy/plugin/PluginAcceptor.java | 67 --- .../plugin/PluginInitializationException.java | 41 -- .../gremlin/groovy/plugin/RemoteAcceptor.java | 92 ---- .../groovy/plugin/RemoteException.java | 42 -- .../groovy/plugin/SugarGremlinPlugin.java | 53 -- .../dsl/credential/CredentialGraph.java | 123 ----- .../CredentialGraphGremlinPlugin.java | 57 --- .../dsl/credential/CredentialGraphTokens.java | 33 -- ...ltDefaultImportCustomizerProviderTest.java | 90 ---- .../groovy/engine/GremlinExecutorTest.java | 136 ++---- .../groovy/engine/ScriptEnginesTest.java | 218 --------- .../ConfigurationCustomizerProviderTest.java | 11 +- ...inGroovyScriptEngineCompileStaticTest.java | 66 --- .../GremlinGroovyScriptEngineConfigTest.java | 10 - ...mlinGroovyScriptEngineFileSandboxTest.java | 16 +- ...remlinGroovyScriptEngineOverGraphTest.java | 46 +- ...oovyScriptEngineSandboxedStandardTest.java | 12 +- .../jsr223/GremlinGroovyScriptEngineTest.java | 215 -------- ...GroovyScriptEngineThreadInterruptTest.java | 21 - ...nGroovyScriptEngineTimedInterruptTest.java | 62 --- ...roovyScriptEngineTinkerPopSandboxTest.java | 7 +- ...mlinGroovyScriptEngineTypeCheckedTest.java | 69 +-- .../GroovyCompilerGremlinPluginTest.java | 6 - .../gremlin/groovy/plugin/ArtifactTest.java | 85 ---- .../util/DependencyGrabberIntegrateTest.java | 1 - .../dsl/credential/CredentialGraphTest.java | 118 ----- .../tinkerpop/gremlin/server/Settings.java | 9 - .../server/auth/SimpleAuthenticator.java | 4 +- .../HttpBasicAuthenticationHandler.java | 4 +- .../server/op/AbstractEvalOpProcessor.java | 7 +- .../server/op/control/ControlOpProcessor.java | 168 ------- .../gremlin/server/op/control/ControlOps.java | 123 ----- .../gremlin/server/op/session/Session.java | 13 +- .../op/traversal/TraversalOpProcessor.java | 1 - .../server/util/GremlinServerInstall.java | 2 +- .../server/util/ServerGremlinExecutor.java | 12 +- ...pache.tinkerpop.gremlin.server.OpProcessor | 1 - .../gremlin/hadoop/HadoopGremlinSuite.java | 3 +- .../jsr223/HadoopGremlinPluginCheck.java | 397 --------------- .../computer/SparkHadoopGraphProvider.java | 9 - 69 files changed, 122 insertions(+), 4829 deletions(-) delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/CompilerCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/DefaultImportCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/EmptyImportCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/ImportCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/NoImportCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPlugin.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteException.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java delete mode 100644 gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java delete mode 100644 gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/DefaultDefaultImportCustomizerProviderTest.java delete mode 100644 gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEnginesTest.java rename gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/{customizer => }/ConfigurationCustomizerProviderTest.java (86%) delete mode 100644 gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java delete mode 100644 gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java delete mode 100644 gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/control/ControlOpProcessor.java delete mode 100644 gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/control/ControlOps.java delete mode 100644 hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1dd298baa18..e72422e72d5 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -33,6 +33,8 @@ TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET) * Established the GraphSON 3.0 format. * Removed `gremlin-groovy-test`. * Removed previously deprecated "G" functions in `gremlin-groovy` (i.e. `GFunction`). +* Removed references to the old `GremlinPlugin` system that was in `gremlin-groovy` - the revised `GremlinPlugin` system in `gremlin-core` is the only one now in use. +* `GremlinGroovyScriptEngine` no longer implements the now removed `DependencyManager`. * Added `Vertex`, `Edge`, `VertexProperty`, and `Property` serializers to Gremlin-Python and exposed tests that use graph object arguments. * `Bytecode.getSourceInstructions()` and `Bytecode.getStepInstructions()` now returns `List` instead of `Iterable`. * Added various `TraversalStrategy` registrations with `GryoMapper`. diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc index 72be2aa996a..46043209915 100644 --- a/docs/src/upgrade/release-3.3.x.asciidoc +++ b/docs/src/upgrade/release-3.3.x.asciidoc @@ -182,7 +182,7 @@ The following deprecated classes, methods or fields have been removed in this ve * `gremlin-console` ** `org.apache.tinkerpop.gremlin.console.Console(String)` ** `org.apache.tinkerpop.gremlin.console.ConsoleImportCustomizerProvider` -** `org.apache.tinkerpop.gremlin.console.plugin.* +** `org.apache.tinkerpop.gremlin.console.plugin.*` ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin` ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverRemoteAcceptor` ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.GephiGremlinPlugin` @@ -197,12 +197,36 @@ The following deprecated classes, methods or fields have been removed in this ve ** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT` ** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT_INTEGRATE` * `gremlin-groovy` +** `org.apache.tinkerpop.gremlin.groovy.AbstractImportCustomizerProvider` +** `org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider` +** `org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider` +** `org.apache.tinkerpop.gremlin.groovy.EmptyImportCustomizerProvider` +** `org.apache.tinkerpop.gremlin.groovy.ImportCustomizerProvider` +** `org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider` ** `org.apache.tinkerpop.gremlin.groovy.engine.ConcurrentBindings` +** `org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor#build(String,List,List,List,Map)` +** `org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor#getScriptEngines()` +** `org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.Builder#enabledPlugins(Set) +** `org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.Builder#addEngineSettings(String,List,List,List,Map)` +** `org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.Builder#engineSettings(Map)` +** `org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.Builder#use(List)` +** `org.apache.tinkerpop.gremlin.groovy.engine.ScriptEngines` ** `org.apache.tinkerpop.gremlin.groovy.function.*` +** `org.apache.tinkerpop.gremlin.groovy.plugin.*` +** `org.apache.tinkerpop.gremlin.groovy.plugin.credential.*` +** `org.apache.tinkerpop.gremlin.groovy.jsr223.DependencyManager` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine(ImportCustomizerProvider)` +** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine(CompilerCustomizerProvider)` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine#plugins()` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor` +** `org.apache.tinkerpop.gremlin.groovy.jsr223.ScriptEnginePluginAcceptor` ** `org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SandboxExtension` +** `org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.*` +** `org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber#deleteDependenciesFromPath(org.apache.tinkerpop.gremlin.groovy.plugin.Artifact)` +** `org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber#copyDependenciesToPath(org.apache.tinkerpop.gremlin.groovy.plugin.Artifact)` +* `gremlin-server` +** `org.apache.tinkerpop.gremlin.server.Settings#plugins` +** `org.apache.tinkerpop.gremlin.server.op.control.*` * `spark-gremlin` ** `org.apache.tinkerpop.gremlin.spark.groovy.plugin.SparkGremlinPlugin` * `tinkergraph-gremlin` @@ -212,8 +236,9 @@ Please see the javadoc deprecation notes or upgrade documentation specific to wh understand how to resolve this breaking change. See: link:https://issues.apache.org/jira/browse/TINKERPOP-1283[TINKERPOP-1283], link:https://issues.apache.org/jira/browse/TINKERPOP-1420[TINKERPOP-1420], -link:https://issues.apache.org/jira/browse/TINKERPOP-833[TINKERPOP-833], link:https://issues.apache.org/jira/browse/TINKERPOP-1040[TINKERPOP-1040], -link:https://issues.apache.org/jira/browse/TINKERPOP-1612[TINKERPOP-1612], link:https://issues.apache.org/jira/browse/TINKERPOP-1622[TINKERPOP-1622] +link:https://issues.apache.org/jira/browse/TINKERPOP-1421[TINKERPOP-1421], link:https://issues.apache.org/jira/browse/TINKERPOP-833[TINKERPOP-833], +link:https://issues.apache.org/jira/browse/TINKERPOP-1040[TINKERPOP-1040], link:https://issues.apache.org/jira/browse/TINKERPOP-1612[TINKERPOP-1612], +link:https://issues.apache.org/jira/browse/TINKERPOP-1622[TINKERPOP-1622] Upgrading for Providers ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy index 4f895c86bd7..f2bfe5c8bbe 100644 --- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy +++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy @@ -50,13 +50,6 @@ class DependencyGrabber { this.extensionDirectory = extensionDirectory } - /** - * @deprecated As of release 3.2.4, replaced by {@link #deleteDependenciesFromPath(Artifact)} - */ - def String deleteDependenciesFromPath(final org.apache.tinkerpop.gremlin.groovy.plugin.Artifact artifact) { - deleteDependenciesFromPath(new Artifact(artifact.group, artifact.artifact, artifact.version)) - } - def String deleteDependenciesFromPath(final Artifact artifact) { final def dep = makeDepsMap(artifact) final String extClassPath = getPathFromDependency(dep) @@ -70,13 +63,6 @@ class DependencyGrabber { } } - /** - * @deprecated As of release 3.2.4, replaced by {@link #copyDependenciesToPath(Artifact)} - */ - def String copyDependenciesToPath(final org.apache.tinkerpop.gremlin.groovy.plugin.Artifact artifact) { - copyDependenciesToPath(new Artifact(artifact.group, artifact.artifact, artifact.version)) - } - def Set copyDependenciesToPath(final Artifact artifact) { final def dep = makeDepsMap(artifact) final String extClassPath = getPathFromDependency(dep) diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java deleted file mode 100644 index 47709f22069..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java +++ /dev/null @@ -1,221 +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.groovy; - -import groovy.grape.Grape; -import groovy.json.JsonBuilder; -import org.apache.commons.configuration.Configuration; -import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator; -import org.apache.tinkerpop.gremlin.process.computer.Computer; -import org.apache.tinkerpop.gremlin.process.computer.GraphComputer; -import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkDumperVertexProgram; -import org.apache.tinkerpop.gremlin.process.computer.bulkloading.BulkLoaderVertexProgram; -import org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.PeerPressureVertexProgram; -import org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgram; -import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram; -import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy; -import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.optimization.GraphFilterStrategy; -import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph; -import org.apache.tinkerpop.gremlin.process.traversal.Operator; -import org.apache.tinkerpop.gremlin.process.traversal.Order; -import org.apache.tinkerpop.gremlin.process.traversal.P; -import org.apache.tinkerpop.gremlin.process.traversal.Pop; -import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions; -import org.apache.tinkerpop.gremlin.process.traversal.Scope; -import org.apache.tinkerpop.gremlin.process.traversal.Traversal; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__; -import org.apache.tinkerpop.gremlin.process.traversal.engine.ComputerTraversalEngine; -import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent; -import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.Event; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IdentityRemovalStrategy; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy; -import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics; -import org.apache.tinkerpop.gremlin.structure.Column; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.T; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.apache.tinkerpop.gremlin.structure.io.GraphReader; -import org.apache.tinkerpop.gremlin.structure.io.IoCore; -import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader; -import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader; -import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader; -import org.apache.tinkerpop.gremlin.structure.util.GraphFactory; -import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedElement; -import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; -import org.apache.tinkerpop.gremlin.util.Gremlin; -import org.apache.tinkerpop.gremlin.util.TimeUtil; -import org.apache.tinkerpop.gremlin.util.function.FunctionUtils; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; -import org.codehaus.groovy.control.customizers.ImportCustomizer; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link ImportCustomizer} - */ -@Deprecated -public abstract class AbstractImportCustomizerProvider implements ImportCustomizerProvider { - protected static final String DOT_STAR = ".*"; - protected static final String EMPTY_STRING = ""; - protected static final String PERIOD = "."; - - protected final Set extraImports = new HashSet<>(); - protected final Set extraStaticImports = new HashSet<>(); - - private static final Set imports = new HashSet<>(); - private static final Set staticImports = new HashSet<>(); - - static { - // graph structure - imports.add(Graph.class.getPackage().getName() + DOT_STAR); - imports.add(GraphFactory.class.getPackage().getName() + DOT_STAR); - imports.add(DetachedElement.class.getPackage().getName() + DOT_STAR); - imports.add(RemoteGraph.class.getPackage().getName() + DOT_STAR); - imports.add(EmptyGraph.class.getPackage().getName() + DOT_STAR); - staticImports.add(T.class.getCanonicalName() + DOT_STAR); - staticImports.add(Direction.class.getCanonicalName() + DOT_STAR); - staticImports.add(VertexProperty.Cardinality.class.getCanonicalName() + DOT_STAR); - - // graph process - imports.add(Traversal.class.getPackage().getName() + DOT_STAR); - imports.add(GraphComputer.class.getPackage().getName() + DOT_STAR); - imports.add(GraphTraversal.class.getPackage().getName() + DOT_STAR); - imports.add(ComputerTraversalEngine.class.getPackage().getName() + DOT_STAR); - imports.add(PartitionStrategy.class.getPackage().getName() + DOT_STAR); // decoration strategies - imports.add(IdentityRemovalStrategy.class.getPackage().getName() + DOT_STAR); // optimization strategies - imports.add(ProfileStrategy.class.getPackage().getName() + DOT_STAR); // finalization strategies - imports.add(ReadOnlyStrategy.class.getPackage().getName() + DOT_STAR); // verification strategies - imports.add(VertexProgramStrategy.class.getPackage().getName() + DOT_STAR); // computer decoration strategies - imports.add(GraphFilterStrategy.class.getPackage().getName() + DOT_STAR); // computer optimization strategies - imports.add(Event.class.getPackage().getName() + DOT_STAR); // eventing - imports.add(GroovyTranslator.class.getPackage().getName() + DOT_STAR); // groovy translator - - staticImports.add(P.class.getCanonicalName() + DOT_STAR); - staticImports.add(Order.class.getCanonicalName() + DOT_STAR); - staticImports.add(Column.class.getCanonicalName() + DOT_STAR); - staticImports.add(Operator.class.getCanonicalName() + DOT_STAR); - staticImports.add(Scope.class.getCanonicalName() + DOT_STAR); - staticImports.add(Pop.class.getCanonicalName() + DOT_STAR); - staticImports.add(__.class.getCanonicalName() + DOT_STAR); - - staticImports.add(SackFunctions.Barrier.class.getCanonicalName() + DOT_STAR); - staticImports.add(TraversalOptionParent.Pick.class.getCanonicalName() + DOT_STAR); - staticImports.add(GraphTraversalSource.class.getCanonicalName() + DOT_STAR); - - // utils - imports.add(Gremlin.class.getPackage().getName() + DOT_STAR); - imports.add(GremlinLoader.class.getPackage().getName() + DOT_STAR); - imports.add(FunctionUtils.class.getPackage().getName() + DOT_STAR); - imports.add(TraversalMetrics.class.getPackage().getName() + DOT_STAR); - staticImports.add(TimeUtil.class.getCanonicalName() + DOT_STAR); - staticImports.add(Computer.class.getCanonicalName() + DOT_STAR); - - // IO packages - imports.add(GraphReader.class.getPackage().getName() + DOT_STAR); - imports.add(GraphMLReader.class.getPackage().getName() + DOT_STAR); - imports.add(GraphSONReader.class.getPackage().getName() + DOT_STAR); - imports.add(GryoReader.class.getPackage().getName() + DOT_STAR); - staticImports.add(IoCore.class.getCanonicalName() + DOT_STAR); - - // algorithms - imports.add(PeerPressureVertexProgram.class.getPackage().getName() + DOT_STAR); - imports.add(PageRankVertexProgram.class.getPackage().getName() + DOT_STAR); - imports.add(TraversalVertexProgram.class.getPackage().getName() + DOT_STAR); - imports.add(BulkLoaderVertexProgram.class.getPackage().getName() + DOT_STAR); - imports.add(BulkDumperVertexProgram.class.getPackage().getName() + DOT_STAR); - - // groovy extras - imports.add(Grape.class.getCanonicalName()); - imports.add(JsonBuilder.class.getPackage().getName() + DOT_STAR); - - // external - imports.add(Configuration.class.getPackage().getName() + DOT_STAR); - } - - @Override - public CompilationCustomizer create() { - final ImportCustomizer ic = new ImportCustomizer(); - - processImports(ic, imports); - processStaticImports(ic, staticImports); - processImports(ic, extraImports); - processStaticImports(ic, extraStaticImports); - - return ic; - } - - @Override - public Set getImports() { - return imports; - } - - @Override - public Set getStaticImports() { - return staticImports; - } - - @Override - public Set getExtraImports() { - return extraImports; - } - - @Override - public Set getExtraStaticImports() { - return extraStaticImports; - } - - public Set getAllImports() { - final Set allImports = new HashSet<>(); - allImports.addAll(imports); - allImports.addAll(staticImports); - allImports.addAll(extraImports); - allImports.addAll(extraStaticImports); - - return allImports; - } - - protected static void processStaticImports(final ImportCustomizer ic, final Set staticImports) { - for (final String staticImport : staticImports) { - if (staticImport.endsWith(DOT_STAR)) { - ic.addStaticStars(staticImport.replace(DOT_STAR, EMPTY_STRING)); - } else { - final int place = staticImport.lastIndexOf(PERIOD); - ic.addStaticImport(staticImport.substring(0, place), staticImport.substring(place + 1)); - } - } - } - - protected static void processImports(final ImportCustomizer ic, final Set imports) { - for (final String imp : imports) { - if (imp.endsWith(DOT_STAR)) { - ic.addStarImports(imp.replace(DOT_STAR, EMPTY_STRING)); - } else { - ic.addImports(imp); - } - } - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/CompilerCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/CompilerCustomizerProvider.java deleted file mode 100644 index 0e8cc389b25..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/CompilerCustomizerProvider.java +++ /dev/null @@ -1,39 +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.groovy; - -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -/** - * Provides a way to plugin Groovy {@code CompilationCustomizer} implementations to the - * {@link GremlinGroovyScriptEngine}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link Customizer}. - */ -@Deprecated -public interface CompilerCustomizerProvider { - - /** - * Create a new instance of a {@code CompilationCustomizer} to add to the {@link GremlinGroovyScriptEngine}. - */ - public CompilationCustomizer create(); -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/DefaultImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/DefaultImportCustomizerProvider.java deleted file mode 100644 index 7282e813edc..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/DefaultImportCustomizerProvider.java +++ /dev/null @@ -1,80 +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.groovy; - -import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; - -import java.util.HashSet; -import java.util.Set; - -/** - * Grabs the standard Gremlin core classes and allows additional imports to be added. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link DefaultImportCustomizer}. - */ -@Deprecated -public class DefaultImportCustomizerProvider extends AbstractImportCustomizerProvider { - private static Set staticExtraImports = new HashSet<>(); - private static Set staticExtraStaticImports = new HashSet<>(); - - /** - * Utilizes imports defined statically by initializeStatically(). - */ - public DefaultImportCustomizerProvider() { - this.extraImports.addAll(staticExtraImports); - this.extraStaticImports.addAll(staticExtraStaticImports); - } - - /** - * Utilizes imports defined by the supplied arguments. Those imports defined statically through - * initializeStatically() are ignored. - */ - public DefaultImportCustomizerProvider(final Set extraImports, final Set extraStaticImports) { - this.extraStaticImports.addAll(extraStaticImports); - this.extraImports.addAll(extraImports); - } - - /** - * Utilizes imports defined by the supplied arguments. Those imports defined statically through - * initializeStatically() are ignored. - * - * @param baseCustomizer Imports from this customizer get added to the new one - */ - public DefaultImportCustomizerProvider(final ImportCustomizerProvider baseCustomizer, - final Set extraImports, final Set extraStaticImports) { - this(extraImports, extraStaticImports); - this.extraImports.addAll(baseCustomizer.getExtraImports()); - this.extraStaticImports.addAll(baseCustomizer.getExtraStaticImports()); - } - - /** - * Allows imports to defined globally and statically. This method must be called prior to initialization of - * a ScriptEngine instance through the ScriptEngineFactory. - */ - public static void initializeStatically(final Set extraImports, final Set extraStaticImports) { - if (extraImports != null) { - staticExtraImports = extraImports; - } - - if (extraStaticImports != null) { - staticExtraStaticImports = extraStaticImports; - } - } -} \ No newline at end of file diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/EmptyImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/EmptyImportCustomizerProvider.java deleted file mode 100644 index 01f6995a60c..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/EmptyImportCustomizerProvider.java +++ /dev/null @@ -1,87 +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.groovy; - -import org.codehaus.groovy.control.customizers.CompilationCustomizer; -import org.codehaus.groovy.control.customizers.ImportCustomizer; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * This {@link ImportCustomizerProvider} is empty and comes with no pre-defined imports at all. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link ImportCustomizer} - */ -@Deprecated -public class EmptyImportCustomizerProvider extends DefaultImportCustomizerProvider { - - /** - * Utilizes imports defined by the supplied arguments. - */ - public EmptyImportCustomizerProvider(final Set extraImports, final Set extraStaticImports) { - this.extraStaticImports.addAll(extraStaticImports); - this.extraImports.addAll(extraImports); - } - - /** - * Utilizes imports defined by the supplied arguments. - * - * @param baseCustomizer Imports from this customizer get added to the new one. - */ - public EmptyImportCustomizerProvider(final ImportCustomizerProvider baseCustomizer, - final Set extraImports, final Set extraStaticImports) { - this(extraImports, extraStaticImports); - this.extraImports.addAll(baseCustomizer.getImports()); - this.extraImports.addAll(baseCustomizer.getExtraImports()); - this.extraStaticImports.addAll(baseCustomizer.getStaticImports()); - this.extraStaticImports.addAll(baseCustomizer.getExtraStaticImports()); - } - - @Override - public CompilationCustomizer create() { - final ImportCustomizer ic = new ImportCustomizer(); - - processImports(ic, extraImports); - processStaticImports(ic, extraStaticImports); - - return ic; - } - - @Override - public Set getImports() { - return Collections.emptySet(); - } - - @Override - public Set getStaticImports() { - return Collections.emptySet(); - } - - @Override - public Set getAllImports() { - final Set allImports = new HashSet<>(); - allImports.addAll(extraImports); - allImports.addAll(extraStaticImports); - - return allImports; - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/ImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/ImportCustomizerProvider.java deleted file mode 100644 index cb7186503e7..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/ImportCustomizerProvider.java +++ /dev/null @@ -1,41 +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.groovy; - -import org.codehaus.groovy.control.customizers.ImportCustomizer; - -import java.util.Set; - -/** - * Allows customization of the imports used by the GremlinGroovyScriptEngine implementation. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link ImportCustomizer} - */ -@Deprecated -public interface ImportCustomizerProvider extends CompilerCustomizerProvider { - - Set getExtraImports(); - - Set getExtraStaticImports(); - - Set getImports(); - - Set getStaticImports(); -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/NoImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/NoImportCustomizerProvider.java deleted file mode 100644 index 433a51d1f6e..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/NoImportCustomizerProvider.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.groovy; - -import org.codehaus.groovy.control.customizers.CompilationCustomizer; -import org.codehaus.groovy.control.customizers.ImportCustomizer; - -import java.util.Collections; -import java.util.Set; - -/** - * Provides no imports. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.5, replaced by {@link ImportCustomizer} - */ -@Deprecated -public final class NoImportCustomizerProvider implements ImportCustomizerProvider { - - public static final NoImportCustomizerProvider INSTANCE = new NoImportCustomizerProvider(); - - private NoImportCustomizerProvider() {} - - @Override - public CompilationCustomizer create() { - return new ImportCustomizer(); - } - - @Override - public Set getExtraImports() { - return Collections.emptySet(); - } - - @Override - public Set getExtraStaticImports() { - return Collections.emptySet(); - } - - @Override - public Set getImports() { - return Collections.emptySet(); - } - - @Override - public Set getStaticImports() { - return Collections.emptySet(); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java index 80e72fd7c68..2d04fb25aac 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java @@ -20,35 +20,27 @@ import org.apache.commons.lang.ClassUtils; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager; import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin; +import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine; import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager; import org.apache.tinkerpop.gremlin.process.traversal.Bytecode; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; -import org.javatuples.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.script.Bindings; +import javax.script.Compilable; import javax.script.CompiledScript; import javax.script.ScriptException; import javax.script.SimpleBindings; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.ServiceLoader; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -61,7 +53,6 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -81,28 +72,19 @@ public class GremlinExecutor implements AutoCloseable { private static final Logger logger = LoggerFactory.getLogger(GremlinExecutor.class); - /** - * {@link ScriptEngines} instance to evaluate Gremlin script requests. - */ - private ScriptEngines scriptEngines; - private GremlinScriptEngineManager gremlinScriptEngineManager; - private final Map settings; private final Map>> plugins; private final long scriptEvaluationTimeout; private final Bindings globalBindings; - private final List> use; private final ExecutorService executorService; private final ScheduledExecutorService scheduledExecutorService; private final Consumer beforeEval; private final Consumer afterSuccess; private final Consumer afterTimeout; private final BiConsumer afterFailure; - private final Set enabledPlugins; private final boolean suppliedExecutor; private final boolean suppliedScheduledExecutor; - private boolean useGremlinScriptEngineManager; private GremlinExecutor(final Builder builder, final boolean suppliedExecutor, final boolean suppliedScheduledExecutor) { @@ -113,24 +95,13 @@ private GremlinExecutor(final Builder builder, final boolean suppliedExecutor, this.afterSuccess = builder.afterSuccess; this.afterTimeout = builder.afterTimeout; this.afterFailure = builder.afterFailure; - this.use = builder.use; - this.settings = builder.settings; this.plugins = builder.plugins; this.scriptEvaluationTimeout = builder.scriptEvaluationTimeout; this.globalBindings = builder.globalBindings; - this.enabledPlugins = builder.enabledPlugins; this.gremlinScriptEngineManager = new CachedGremlinScriptEngineManager(); initializeGremlinScriptEngineManager(); - // this is temporary so that we can have backward compatibility to the old plugin system and ScriptEngines - // approach to configuring Gremlin Server and GremlinExecutor. This code/check should be removed with the - // deprecated code around this is removed. - if (!useGremlinScriptEngineManager) - this.scriptEngines = createScriptEngines(); - else - this.scriptEngines = null; - this.suppliedExecutor = suppliedExecutor; this.suppliedScheduledExecutor = suppliedScheduledExecutor; } @@ -147,14 +118,18 @@ public Optional compile(final String script) throws ScriptExcept /** * Attempts to compile a script and cache it in the request {@link javax.script.ScriptEngine}. This is only - * possible if the {@link javax.script.ScriptEngine} implementation implements {@link javax.script.Compilable}. + * possible if the {@link javax.script.ScriptEngine} implementation implements {@link Compilable}. * In the event that the requested {@link javax.script.ScriptEngine} does not implement it, the method will * return empty. */ public Optional compile(final String script, final Optional language) throws ScriptException { final String lang = language.orElse("gremlin-groovy"); try { - return Optional.of(scriptEngines.compile(script, lang)); + final GremlinScriptEngine scriptEngine = gremlinScriptEngineManager.getEngineByName(lang); + if (scriptEngine instanceof Compilable) + return Optional.of(((Compilable) scriptEngine).compile(script)); + else + return Optional.empty(); } catch (UnsupportedOperationException uoe) { return Optional.empty(); } @@ -308,8 +283,7 @@ public CompletableFuture eval(final String script, final String language logger.debug("Evaluating script - {} - in thread [{}]", script, Thread.currentThread().getName()); // do this weirdo check until the now deprecated ScriptEngines is gutted - final Object o = useGremlinScriptEngineManager ? - gremlinScriptEngineManager.getEngineByName(lang).eval(script, bindings) : scriptEngines.eval(script, bindings, lang); + final Object o = gremlinScriptEngineManager.getEngineByName(lang).eval(script, bindings); // apply a transformation before sending back the result - useful when trying to force serialization // in the same thread that the eval took place given ThreadLocal nature of graphs as well as some @@ -362,16 +336,7 @@ public Traversal.Admin eval(final Bytecode bytecode, final Bindings boundVars, f bindings.putAll(globalBindings); bindings.putAll(boundVars); - return useGremlinScriptEngineManager ? - gremlinScriptEngineManager.getEngineByName(lang).eval(bytecode, bindings) : scriptEngines.eval(bytecode, bindings, lang); - } - - /** - * @deprecated As of release 3.2.4, replaced by {@link #getScriptEngineManager()}. - */ - @Deprecated - public ScriptEngines getScriptEngines() { - return this.scriptEngines; + return gremlinScriptEngineManager.getEngineByName(lang).eval(bytecode, bindings); } public GremlinScriptEngineManager getScriptEngineManager() { @@ -431,12 +396,6 @@ public CompletableFuture closeAsync() throws Exception { } } - try { - scriptEngines.close(); - } catch (Exception ex) { - logger.warn("Error while shutting down the ScriptEngines in the GremlinExecutor", ex); - } - future.complete(null); }, "gremlin-executor-close").start(); @@ -444,8 +403,6 @@ public CompletableFuture closeAsync() throws Exception { } private void initializeGremlinScriptEngineManager() { - this.useGremlinScriptEngineManager = !plugins.entrySet().isEmpty(); - for (Map.Entry>> config : plugins.entrySet()) { final String language = config.getKey(); final Map> pluginConfigs = config.getValue(); @@ -493,113 +450,23 @@ private void initializeGremlinScriptEngineManager() { } } - if (this.useGremlinScriptEngineManager) { - gremlinScriptEngineManager.setBindings(globalBindings); - } - } - - private ScriptEngines createScriptEngines() { - // plugins already on the path - ones static to the classpath - final List globalPlugins = new ArrayList<>(); - ServiceLoader.load(org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin.class).forEach(globalPlugins::add); - - return new ScriptEngines(se -> { - // this first part initializes the scriptengines Map - for (Map.Entry config : settings.entrySet()) { - final String language = config.getKey(); - se.reload(language, new HashSet<>(config.getValue().getImports()), - new HashSet<>(config.getValue().getStaticImports()), config.getValue().getConfig()); - } - - // use grabs dependencies and returns plugins to load - final List pluginsToLoad = new ArrayList<>(globalPlugins); - use.forEach(u -> { - if (u.size() != 3) - logger.warn("Could not resolve dependencies for [{}]. Each entry for the 'use' configuration must include [groupId, artifactId, version]", u); - else { - logger.info("Getting dependencies for [{}]", u); - pluginsToLoad.addAll(se.use(u.get(0), u.get(1), u.get(2))); - } - }); - - // now that all dependencies are in place, the imports can't get messed up if a plugin tries to execute - // a script (as the script engine appends the import list to the top of all scripts passed to the engine). - // only enable those plugins that are configured to be enabled. - se.loadPlugins(pluginsToLoad.stream().filter(plugin -> enabledPlugins.contains(plugin.getName())).collect(Collectors.toList())); - - // initialization script eval can now be performed now that dependencies are present with "use" - for (Map.Entry config : settings.entrySet()) { - final String language = config.getKey(); - - // script engine initialization files that fail will only log warnings - not fail server initialization - final AtomicBoolean hasErrors = new AtomicBoolean(false); - config.getValue().getScripts().stream().map(File::new).filter(f -> { - if (!f.exists()) { - logger.warn("Could not initialize {} ScriptEngine with {} as file does not exist", language, f); - hasErrors.set(true); - } - - return f.exists(); - }).map(f -> { - try { - return Pair.with(f, Optional.of(new FileReader(f))); - } catch (IOException ioe) { - logger.warn("Could not initialize {} ScriptEngine with {} as file could not be read - {}", language, f, ioe.getMessage()); - hasErrors.set(true); - return Pair.with(f, Optional.empty()); - } - }).filter(p -> p.getValue1().isPresent()).map(p -> Pair.with(p.getValue0(), p.getValue1().get())).forEachOrdered(p -> { - try { - final Bindings bindings = new SimpleBindings(); - bindings.putAll(globalBindings); - - // evaluate init scripts with hard reference so as to ensure it doesn't get garbage collected - bindings.put(GremlinGroovyScriptEngine.KEY_REFERENCE_TYPE, GremlinGroovyScriptEngine.REFERENCE_TYPE_HARD); - - // the returned object should be a Map of initialized global bindings - final Object initializedBindings = se.eval(p.getValue1(), bindings, language); - if (initializedBindings != null && initializedBindings instanceof Map) - globalBindings.putAll((Map) initializedBindings); - else - logger.warn("Initialization script {} did not return a Map - no global bindings specified", p.getValue0()); - - logger.info("Initialized {} ScriptEngine with {}", language, p.getValue0()); - } catch (ScriptException sx) { - hasErrors.set(true); - logger.warn("Could not initialize {} ScriptEngine with {} as script could not be evaluated - {}", language, p.getValue0(), sx.getMessage()); - } - }); - } - }); + gremlinScriptEngineManager.setBindings(globalBindings); } /** * Create a {@code Builder} with the gremlin-groovy ScriptEngine configured. */ public static Builder build() { - return new Builder().addEngineSettings("gremlin-groovy", new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new HashMap<>()); - } - - /** - * Create a {@code Builder} and specify the first ScriptEngine to be included. - * - * @deprecated As of release 3.2.4, replaced by {@link #build()}. - */ - public static Builder build(final String engineName, final List imports, - final List staticImports, final List scripts, - final Map config) { - return new Builder().addEngineSettings(engineName, imports, staticImports, scripts, config); + return new Builder(); } public final static class Builder { private long scriptEvaluationTimeout = 8000; - private Map settings = new HashMap<>(); private Map>> plugins = new HashMap<>(); private ExecutorService executorService = null; private ScheduledExecutorService scheduledExecutorService = null; - private Set enabledPlugins = new HashSet<>(); private Consumer beforeEval = (b) -> { }; private Consumer afterSuccess = (b) -> { @@ -608,36 +475,11 @@ public final static class Builder { }; private BiConsumer afterFailure = (b, e) -> { }; - private List> use = new ArrayList<>(); private Bindings globalBindings = new org.apache.tinkerpop.gremlin.jsr223.ConcurrentBindings(); private Builder() { } - /** - * Add a particular script engine for the executor to instantiate. - * - * @param engineName The name of the engine as defined by the engine itself. - * @param imports A list of imports for the engine. - * @param staticImports A list of static imports for the engine. - * @param scripts A list of scripts to execute in the engine to initialize it. - * @param config Custom configuration map for the ScriptEngine - * - * @deprecated As of release 3.2.4, replaced by {@link #addPlugins(String, Map)}. - */ - @Deprecated - public Builder addEngineSettings(final String engineName, final List imports, - final List staticImports, final List scripts, - final Map config) { - if (null == imports) throw new IllegalArgumentException("imports cannot be null"); - if (null == staticImports) throw new IllegalArgumentException("staticImports cannot be null"); - if (null == scripts) throw new IllegalArgumentException("scripts cannot be null"); - final Map m = null == config ? Collections.emptyMap() : config; - - settings.put(engineName, new EngineSettings(imports, staticImports, scripts, m)); - return this; - } - /** * Add a configuration for a {@link GremlinPlugin} to the executor. The key is the fully qualified class name * of the {@link GremlinPlugin} instance and the value is a map of configuration values. In that map, the key @@ -672,17 +514,6 @@ public Builder scriptEvaluationTimeout(final long scriptEvaluationTimeout) { return this; } - /** - * Replaces any settings provided. - * - * @deprecated As of release 3.2.4, replaced by {@link #addPlugins(String, Map)}. - */ - @Deprecated - public Builder engineSettings(final Map settings) { - this.settings = settings; - return this; - } - /** * The thread pool used to evaluate scripts. */ @@ -733,29 +564,6 @@ public Builder afterFailure(final BiConsumer afterFailure) return this; } - /** - * A set of maven coordinates for dependencies to be applied for the script engine instances. - * - * @deprecated As of release 3.2.4, not replaced. - */ - @Deprecated - public Builder use(final List> use) { - this.use = use; - return this; - } - - /** - * Set of the names of plugins that should be enabled for the engine. - * - * @deprecated As of release 3.2.4, replaced by {@link #addPlugins(String, Map)} though behavior is not quite - * the same. - */ - @Deprecated - public Builder enabledPlugins(final Set enabledPlugins) { - this.enabledPlugins = enabledPlugins; - return this; - } - public GremlinExecutor create() { final BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("gremlin-executor-default-%d").build(); @@ -783,37 +591,6 @@ public GremlinExecutor create() { } } - private static class EngineSettings { - private List imports; - private List staticImports; - private List scripts; - private Map config; - - public EngineSettings(final List imports, final List staticImports, - final List scripts, final Map config) { - this.imports = imports; - this.staticImports = staticImports; - this.scripts = scripts; - this.config = config; - } - - private List getImports() { - return imports; - } - - private List getStaticImports() { - return staticImports; - } - - private List getScripts() { - return scripts; - } - - public Map getConfig() { - return config; - } - } - /** * The lifecycle of execution within the {@link #eval(String, String, Bindings, LifeCycle)} method. Since scripts * are executed in a thread pool and graph transactions are bound to a thread all actions related to that script diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java deleted file mode 100644 index 7dcfc5cf8ce..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java +++ /dev/null @@ -1,461 +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.groovy.engine; - -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.DependencyManager; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.plugin.IllegalEnvironmentException; -import org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager; -import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine; -import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager; -import org.apache.tinkerpop.gremlin.process.traversal.Bytecode; -import org.apache.tinkerpop.gremlin.process.traversal.Traversal; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.script.Bindings; -import javax.script.Compilable; -import javax.script.CompiledScript; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptException; -import javax.script.SimpleBindings; -import java.io.Reader; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -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.Queue; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.LockSupport; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Holds a batch of the configured {@code ScriptEngine} objects for the server. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not directly replaced - see {@link GremlinScriptEngineManager}. - */ -@Deprecated -public class ScriptEngines implements AutoCloseable { - private static final Logger logger = LoggerFactory.getLogger(ScriptEngines.class); - - private final static GremlinScriptEngineManager SCRIPT_ENGINE_MANAGER = new DefaultGremlinScriptEngineManager(); - private static final GremlinGroovyScriptEngineFactory gremlinGroovyScriptEngineFactory = new GremlinGroovyScriptEngineFactory(); - - /** - * {@code ScriptEngine} objects configured for the server keyed on the language name. - */ - private final Map scriptEngines = new ConcurrentHashMap<>(); - - private final AtomicBoolean controlOperationExecuting = new AtomicBoolean(false); - private final Queue controlWaiters = new ConcurrentLinkedQueue<>(); - private final Queue evalWaiters = new ConcurrentLinkedQueue<>(); - - private final Consumer initializer; - - /** - * Creates a new object. - * - * @param initializer allows for external initialization of the newly created {@code ScriptEngines} object - */ - public ScriptEngines(final Consumer initializer) { - this.initializer = initializer; - this.initializer.accept(this); - } - - public Traversal.Admin eval(final Bytecode bytecode, final Bindings bindings, final String language) throws ScriptException { - if (!scriptEngines.containsKey(language)) - throw new IllegalArgumentException(String.format("Language [%s] not supported", language)); - - awaitControlOp(); - - final GremlinScriptEngine engine = scriptEngines.get(language); - final Bindings all = mergeBindings(bindings, engine); - - return engine.eval(bytecode, all); - } - - /** - * Evaluate a script with {@code Bindings} for a particular language. - */ - public Object eval(final String script, final Bindings bindings, final String language) throws ScriptException { - checkLanguageIsSupported(language); - - awaitControlOp(); - - final ScriptEngine engine = scriptEngines.get(language); - final Bindings all = mergeBindings(bindings, engine); - - return engine.eval(script, all); - } - - /** - * Evaluate a script with {@code Bindings} for a particular language. - */ - public Object eval(final Reader reader, final Bindings bindings, final String language) - throws ScriptException { - checkLanguageIsSupported(language); - - awaitControlOp(); - - final ScriptEngine engine = scriptEngines.get(language); - final Bindings all = mergeBindings(bindings, engine); - - return engine.eval(reader, all); - } - - /** - * Compiles a script without executing it. - * - * @throws UnsupportedOperationException if the {@link ScriptEngine} implementation does not implement - * the {@link javax.script.Compilable} interface. - */ - public CompiledScript compile(final String script, final String language) throws ScriptException { - if (!scriptEngines.containsKey(language)) - throw new IllegalArgumentException("Language [%s] not supported"); - - awaitControlOp(); - final ScriptEngine scriptEngine = scriptEngines.get(language); - if (!Compilable.class.isAssignableFrom(scriptEngine.getClass())) - throw new UnsupportedOperationException(String.format("ScriptEngine for %s does not implement %s", language, Compilable.class.getName())); - - final Compilable compilable = (Compilable) scriptEngine; - return compilable.compile(script); - } - - /** - * Compiles a script without executing it. - * - * @throws UnsupportedOperationException if the {@link ScriptEngine} implementation does not implement - * the {@link javax.script.Compilable} interface. - */ - public CompiledScript compile(final Reader script, final String language) throws ScriptException { - if (!scriptEngines.containsKey(language)) - throw new IllegalArgumentException("Language [%s] not supported"); - - awaitControlOp(); - final ScriptEngine scriptEngine = scriptEngines.get(language); - if (scriptEngine instanceof Compilable) - throw new UnsupportedOperationException(String.format("ScriptEngine for %s does not implement %s", language, Compilable.class.getName())); - - final Compilable compilable = (Compilable) scriptEngine; - return compilable.compile(script); - } - - /** - * Reload a {@code ScriptEngine} with fresh imports. Waits for any existing script evaluations to complete but - * then blocks other operations until complete. - */ - public void reload(final String language, final Set imports, final Set staticImports, - final Map config) { - try { - signalControlOpStart(); - if (scriptEngines.containsKey(language)) - scriptEngines.remove(language); - - final GremlinScriptEngine scriptEngine = createScriptEngine(language, imports, staticImports, config) - .orElseThrow(() -> new IllegalArgumentException(String.format("Language [%s] not supported", language))); - scriptEngines.put(language, scriptEngine); - - logger.info("Loaded {} ScriptEngine", language); - } finally { - signalControlOpEnd(); - } - } - - /** - * Perform append to the existing import list for all {@code ScriptEngine} instances that implement the - * {@link DependencyManager} interface. Waits for any existing script evaluations to complete but - * then blocks other operations until complete. - */ - public void addImports(final Set imports) { - try { - signalControlOpStart(); - getDependencyManagers().forEach(dm -> dm.addImports(imports)); - } finally { - signalControlOpEnd(); - } - } - - /** - * Pull in dependencies given some Maven coordinates. Cycle through each {@code ScriptEngine} and determine if it - * implements {@link DependencyManager}. For those that do call the @{link DependencyManager#use} method to fire - * it up. Waits for any existing script evaluations to complete but then blocks other operations until complete. - */ - public List use(final String group, final String artifact, final String version) { - final List pluginsToLoad = new ArrayList<>(); - try { - signalControlOpStart(); - getDependencyManagers().forEach(dm -> { - try { - pluginsToLoad.addAll(dm.use(group, artifact, version)); - } catch (Exception ex) { - logger.warn("Could not get dependency for [{}, {}, {}] - {}", group, artifact, version, ex.getMessage()); - } - }); - } finally { - signalControlOpEnd(); - } - - return pluginsToLoad; - } - - /** - * For each {@link DependencyManager} try to load the specified plugins. - */ - public void loadPlugins(final List plugins) { - try { - signalControlOpStart(); - getDependencyManagers().forEach(dm -> { - try { - dm.loadPlugins(plugins); - } catch (IllegalEnvironmentException iee) { - logger.warn("Some plugins may not have been loaded to {} - {}", dm.getClass().getSimpleName(), iee.getMessage()); - } catch (Exception ex) { - logger.error(String.format("Some plugins may not have been loaded to %s", dm.getClass().getSimpleName()), ex); - } - }); - } finally { - signalControlOpEnd(); - } - } - - /** - * Iterate through all the {@link ScriptEngine} implementations and if they implement {@link AutoCloseable} - * then call the {@link AutoCloseable#close()} method. After that is complete, the script engine cache will be - * cleared. - */ - @Override - public void close() throws Exception { - try { - signalControlOpStart(); - scriptEngines.values().stream() - .filter(se -> se instanceof AutoCloseable) - .map(se -> (AutoCloseable) se).forEach(c -> { - try { - c.close(); - } catch (Exception ignored) { - } - }); - scriptEngines.clear(); - } finally { - signalControlOpEnd(); - } - } - - /** - * Resets the ScriptEngines and re-initializes them. Waits for any existing script evaluations to complete but - * then blocks other operations until complete. - */ - public void reset() { - try { - signalControlOpStart(); - getDependencyManagers().forEach(DependencyManager::reset); - } finally { - signalControlOpEnd(); - this.initializer.accept(this); - } - } - - /** - * List dependencies for those {@code ScriptEngine} objects that implement the {@link DependencyManager} interface. - */ - public Map> dependencies() { - final Map> m = new HashMap<>(); - scriptEngines.entrySet().stream() - .filter(kv -> kv.getValue() instanceof DependencyManager) - .forEach(kv -> m.put(kv.getKey(), Arrays.asList(((DependencyManager) kv.getValue()).dependencies()))); - return m; - } - - /** - * List the imports for those {@code ScriptEngine} objects that implement the {@link DependencyManager} interface. - */ - public Map> imports() { - final Map> m = new HashMap<>(); - scriptEngines.entrySet().stream() - .filter(kv -> kv.getValue() instanceof DependencyManager) - .forEach(kv -> m.put(kv.getKey(), Arrays.asList(((DependencyManager) kv.getValue()).imports()))); - return m; - } - - /** - * Get the set of {@code ScriptEngine} that implement {@link DependencyManager} interface. - */ - private Set getDependencyManagers() { - return scriptEngines.entrySet().stream() - .map(Map.Entry::getValue) - .filter(se -> se instanceof DependencyManager) - .map(se -> (DependencyManager) se) - .collect(Collectors.toSet()); - } - - /** - * Called when a control operation starts. Attempts to grab a lock on the "control" process and parks the - * current thread if it cannot. Parked threads are queued until released by {@link #signalControlOpEnd()}. - */ - private void signalControlOpStart() { - boolean wasInterrupted = false; - final Thread current = Thread.currentThread(); - controlWaiters.add(current); - - // Block while not first in queue or cannot acquire lock - while (controlWaiters.peek() != current || !controlOperationExecuting.compareAndSet(false, true)) { - LockSupport.park(this); - if (Thread.interrupted()) - wasInterrupted = true; - } - - controlWaiters.remove(); - if (wasInterrupted) - current.interrupt(); - } - - /** - * Called when a control operation is finished. Releases the lock for the next thread trying to call a - * control operation. If there are no additional threads trying to call control operations then unpark - * any evaluation threads that are waiting. - */ - private void signalControlOpEnd() { - controlOperationExecuting.set(false); - LockSupport.unpark(controlWaiters.peek()); - - // let the eval threads proceed as long as the control functions waiting are all complete - if (controlWaiters.size() == 0) { - Thread t = evalWaiters.poll(); - while (t != null) { - LockSupport.unpark(t); - t = evalWaiters.poll(); - } - } - } - - /** - * If a control operation is executing or there are some in the queue to be executed, then block the current - * thread until that process completes. - */ - private void awaitControlOp() { - if (controlWaiters.size() > 0 || controlOperationExecuting.get()) { - evalWaiters.add(Thread.currentThread()); - LockSupport.park(this); - } - } - - private static synchronized Optional createScriptEngine(final String language, - final Set imports, - final Set staticImports, - final Map config) { - // gremlin-groovy gets special initialization for mapper imports and such. could implement this more - // generically with the DependencyManager interface, but going to wait to see how other ScriptEngines - // develop for TinkerPop3 before committing too deeply here to any specific way of doing this. - if (language.equals(gremlinGroovyScriptEngineFactory.getLanguageName())) { - final List providers = new ArrayList<>(); - providers.add(new DefaultImportCustomizerProvider(imports, staticImports)); - - // the key to the config of the compilerCustomizerProvider is the fully qualified classname of a - // CompilerCustomizerProvider. the value is a list of arguments to pass to an available constructor. - // the arguments must match in terms of type, so given that configuration typically comes from yaml - // or properties file, it is best to stick to primitive values when possible here for simplicity. - final Map compilerCustomizerProviders = (Map) config.getOrDefault( - "compilerCustomizerProviders", Collections.emptyMap()); - compilerCustomizerProviders.forEach((k, v) -> { - try { - final Class providerClass = Class.forName(k); - if (v != null && v instanceof List && ((List) v).size() > 0) { - final List l = (List) v; - final Object[] args = new Object[l.size()]; - l.toArray(args); - - final Class[] argClasses = new Class[args.length]; - Stream.of(args).map(a -> a.getClass()).collect(Collectors.toList()).toArray(argClasses); - - final Optional constructor = Stream.of(providerClass.getConstructors()) - .filter(c -> c.getParameterCount() == argClasses.length && - allMatch(c.getParameterTypes(), argClasses)) - .findFirst(); - - if (constructor.isPresent()) providers.add((CompilerCustomizerProvider) - constructor.get().newInstance(args)); - else - throw new IllegalStateException(String.format("Could not configure %s with the supplied options %s", - ConfigurationCustomizerProvider.class.getName(), Arrays.asList(args))); - } else { - providers.add((CompilerCustomizerProvider) providerClass.newInstance()); - } - } catch (Exception ex) { - logger.warn(String.format("Could not instantiate CompilerCustomizerProvider implementation [%s]. It will not be applied.", k), ex); - } - }); - - final CompilerCustomizerProvider[] providerArray = new CompilerCustomizerProvider[providers.size()]; - return Optional.of(new GremlinGroovyScriptEngine(providers.toArray(providerArray))); - } else { - return Optional.ofNullable(SCRIPT_ENGINE_MANAGER.getEngineByName(language)); - } - } - - /** - * Determine if the constructor argument types match the arg types that are going to be passed in to that - * constructor. - */ - private static boolean allMatch(final Class[] constructorArgTypes, final Class[] argTypes) { - for (int ix = 0; ix < constructorArgTypes.length; ix++) { - if (!constructorArgTypes[ix].isAssignableFrom(argTypes[ix])) { - return false; - } - } - - return true; - } - - /** - * Takes the bindings from a request for eval and merges them with the {@code ENGINE_SCOPE} bindings. - */ - private static Bindings mergeBindings(final Bindings bindings, final ScriptEngine engine) { - // plugins place "globals" here - see ScriptEnginePluginAcceptor - final Bindings global = engine.getBindings(ScriptContext.GLOBAL_SCOPE); - if (null == global) return bindings; - - // merge the globals with the incoming bindings where local bindings "win" - final Bindings all = new SimpleBindings(global); - all.putAll(bindings); - return all; - } - - private void checkLanguageIsSupported(final String language) { - if (!scriptEngines.containsKey(language)) { - throw new IllegalArgumentException(String.format("Language [%s] not supported", language)); - } - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java deleted file mode 100644 index 4f1384d9232..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/DependencyManager.java +++ /dev/null @@ -1,84 +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.groovy.jsr223; - -import org.apache.tinkerpop.gremlin.groovy.ImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPluginException; -import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; -import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Provides a way to dynamically consume dependencies into the ScriptEngine classloader. With Groovy this is - * somewhat easily accomplished with Grape, but other ScriptEngine implementations might have ways to do it too, - * so this interface makes that possible to expose. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced - no longer needed under the new {@link GremlinScriptEngine} model. - */ -@Deprecated -public interface DependencyManager { - /** - * Take maven coordinates and load the classes into the classloader used by the ScriptEngine. Those ScriptEngines - * that can support script engine plugins should check if there are any new {@link GremlinPlugin} - * implementations in the classloader. The {@link GremlinGroovyScriptEngine} - * implementation uses ServiceLoader to figure out if there are such classes to return. - *

- * It is up to the caller to execute the - * {@link GremlinPlugin#pluginTo(org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor)} method. The reason for - * this has to do with conflicts that can occur with mapper imports that are added via the - * {@link ImportCustomizerProvider} and scripts executed through the - * {@link PluginAcceptor}. Generally speaking, all calls to this "use" method - * should be complete prior to calling - * {@link GremlinPlugin#pluginTo(PluginAcceptor)}. - */ - List use(final String group, final String artifact, final String version); - - /** - * Load a list of {@link GremlinPlugin} instances. These plugins are typically returned from calls to - * {@link #use(String, String, String)}. - * - * @throws GremlinPluginException if there is a problem loading the plugin itself. - */ - void loadPlugins(final List plugins) throws GremlinPluginException; - - /** - * Perform class imports for the ScriptEngine. - */ - void addImports(final Set importStatements); - - /** - * List the dependencies in the ScriptEngine classloader. - */ - Map[] dependencies(); - - /** - * List the imports in the ScriptEngine; - */ - Map> imports(); - - /** - * Reset the ScriptEngine. Clear caches and kill the classloader. - */ - void reset(); -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java index 5de06e5a11f..0ac5582b50e 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java @@ -18,7 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import groovy.grape.Grape; import groovy.lang.Binding; import groovy.lang.Closure; import groovy.lang.DelegatingMetaClass; @@ -27,17 +26,7 @@ import groovy.lang.MissingPropertyException; import groovy.lang.Script; import groovy.lang.Tuple; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.EmptyImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.ImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader; -import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPluginException; import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin; import org.apache.tinkerpop.gremlin.jsr223.Customizer; import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine; @@ -91,7 +80,7 @@ * @see org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor */ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl - implements DependencyManager, AutoCloseable, GremlinScriptEngine { + implements AutoCloseable, GremlinScriptEngine { /** * An "internal" key for sandboxing the script engine - technically not for public use. @@ -136,7 +125,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl /** * Name of variable that holds local variables to be globally bound if "interpreter mode" is enabled with - * {@link InterpreterModeCustomizerProvider}. + * {@link InterpreterModeGroovyCustomizer}. */ public static final String COLLECTED_BOUND_VARS_MAP_VARNAME = "gremlin_script_engine_collected_boundvars"; @@ -175,17 +164,13 @@ protected Map initialValue() { private static final String DOT_GROOVY = ".groovy"; private static final String GROOVY_LANG_SCRIPT = "groovy.lang.Script"; - private ImportCustomizerProvider importCustomizerProvider; - private final List customizerProviders; - private final ImportGroovyCustomizer importGroovyCustomizer; private final List groovyCustomizers; - private final Set artifactsToUse = new HashSet<>(); private final boolean interpreterModeEnabled; /** - * Creates a new instance using the {@link DefaultImportCustomizerProvider}. + * Creates a new instance using no {@link Customizer}. */ public GremlinGroovyScriptEngine() { this(new Customizer[0]); @@ -215,137 +200,9 @@ public GremlinGroovyScriptEngine(final Customizer... customizers) { interpreterModeEnabled = groovyCustomizers.stream() .anyMatch(p -> p.getClass().equals(InterpreterModeGroovyCustomizer.class)); - // not using the old provider model so set that to empty list so that when createClassLoader is called - // it knows to use groovyCustomizers instead - customizerProviders = Collections.emptyList(); - - createClassLoader(); - } - - /** - * Creates a new instance with the specified {@link CompilerCustomizerProvider} objects. - * - * @deprecated As of release 3.2.4, replaced by {@link #GremlinGroovyScriptEngine(Customizer...)}. - */ - @Deprecated - public GremlinGroovyScriptEngine(final CompilerCustomizerProvider... compilerCustomizerProviders) { - final List providers = Arrays.asList(compilerCustomizerProviders); - - GremlinLoader.load(); - - importCustomizerProvider = providers.stream() - .filter(p -> p instanceof ImportCustomizerProvider) - .map(p -> (ImportCustomizerProvider) p) - .findFirst().orElse(NoImportCustomizerProvider.INSTANCE); - - // determine if interpreter mode should be enabled - interpreterModeEnabled = providers.stream() - .anyMatch(p -> p.getClass().equals(InterpreterModeCustomizerProvider.class)); - - // remove used providers as the rest will be applied directly - customizerProviders = providers.stream() - .filter(p -> p != null && !(p instanceof ImportCustomizerProvider)) - .collect(Collectors.toList()); - - // groovy customizers are not used here - set to empty list so that the customizerProviders get used - // in createClassLoader - groovyCustomizers = Collections.emptyList(); - importGroovyCustomizer = null; - createClassLoader(); } - /** - * {@inheritDoc} - *

- * This method should be called after "expected" imports have been added to the {@code DependencyManager} - * because adding imports with {@link #addImports(java.util.Set)} will reset the classloader and flush away - * dependencies. - */ - @Override - public synchronized List use(final String group, final String artifact, final String version) { - final Map dependency = new HashMap() {{ - put("group", group); - put("module", artifact); - put("version", version); - }}; - - final Map args = new HashMap() {{ - put("classLoader", loader); - }}; - - Grape.grab(args, dependency); - - // note that the service loader utilized the classloader from the groovy shell as shell class are available - // from within there given loading through Grape. - final List pluginsFound = new ArrayList<>(); - ServiceLoader.load(GremlinPlugin.class, loader).forEach(pluginsFound::add); - - artifactsToUse.add(new Artifact(group, artifact, version)); - - return pluginsFound; - } - - /** - * {@inheritDoc} - */ - @Override - public void loadPlugins(final List plugins) throws GremlinPluginException { - for (GremlinPlugin gremlinPlugin : plugins) { - if (!loadedPlugins.contains(gremlinPlugin.getName())) { - gremlinPlugin.pluginTo(new ScriptEnginePluginAcceptor(this)); - loadedPlugins.add(gremlinPlugin.getName()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public Map[] dependencies() { - return Grape.listDependencies(loader); - } - - /** - * {@inheritDoc} - */ - @Override - public Map> imports() { - final Map> m = new HashMap<>(); - m.put("imports", importCustomizerProvider.getImports()); - m.put("staticImports", importCustomizerProvider.getStaticImports()); - m.put("extraImports", importCustomizerProvider.getExtraImports()); - m.put("extraStaticImports", importCustomizerProvider.getExtraStaticImports()); - return m; - } - - /** - * {@inheritDoc} - */ - @Override - public synchronized void addImports(final Set importStatements) { - // can't use this feature because imports can't come in as String for the revised model - if (null == importCustomizerProvider) - throw new IllegalStateException("Imports cannot be added to a GremlinGroovyScriptEngine that uses Customizer instances"); - - final Set staticImports = new HashSet<>(); - final Set imports = new HashSet<>(); - - importStatements.forEach(s -> { - final String trimmed = s.trim(); - if (patternImportStatic.matcher(trimmed).matches()) { - final int pos = trimmed.indexOf(STATIC); - staticImports.add(s.substring(pos + 6).trim()); - } else - imports.add(s.substring(6).trim()); - }); - - importCustomizerProvider = new EmptyImportCustomizerProvider(importCustomizerProvider, imports, staticImports); - - internalReset(); - } - /** * Get the list of loaded plugins. */ @@ -376,21 +233,16 @@ public void close() throws Exception { } /** - * {@inheritDoc} + * Resets the entire {@code GremlinGroovyScriptEngine} by clearing script caches, recreating the classloader, + * clearing bindings. */ - @Override public void reset() { internalReset(); - - loadedPlugins.clear(); - getContext().getBindings(ScriptContext.ENGINE_SCOPE).clear(); } /** - * Resets the {@code ScriptEngine} but does not clear the loaded plugins or bindings. Typically called by - * {@link DependencyManager} methods that need to just force the classloader to be recreated and script caches - * cleared. + * Resets the {@code ScriptEngine} but does not clear the loaded plugins or bindings. */ private void internalReset() { createClassLoader(); @@ -399,9 +251,6 @@ private void internalReset() { // referenced before that might not have evaluated might cleanly evaluate now. classMap.clear(); globalClosures.clear(); - - final Set toReuse = new HashSet<>(artifactsToUse); - toReuse.forEach(this::use); } /** @@ -670,36 +519,17 @@ private Object invokeImpl(final Object thiz, final String name, final Object arg } private synchronized void createClassLoader() { - // check for customizerProviders temporarily until this deprecated stuff is gone - if (groovyCustomizers.isEmpty() && null == importGroovyCustomizer) { - final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT); - conf.addCompilationCustomizers(this.importCustomizerProvider.create()); - - // ConfigurationCustomizerProvider is treated separately - customizerProviders.stream().filter(cp -> !(cp instanceof ConfigurationCustomizerProvider)) - .forEach(p -> conf.addCompilationCustomizers(p.create())); - - customizerProviders.stream().filter(cp -> cp instanceof ConfigurationCustomizerProvider).findFirst() - .ifPresent(cp -> ((ConfigurationCustomizerProvider) cp).applyCustomization(conf)); - - this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf); - } else { - final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT); - conf.addCompilationCustomizers(this.importGroovyCustomizer.create()); - - // ConfigurationCustomizerProvider is treated separately - groovyCustomizers.stream().filter(cp -> !(cp instanceof ConfigurationGroovyCustomizer)) - .forEach(p -> conf.addCompilationCustomizers(p.create())); + final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT); + conf.addCompilationCustomizers(this.importGroovyCustomizer.create()); - groovyCustomizers.stream().filter(cp -> cp instanceof ConfigurationGroovyCustomizer).findFirst() - .ifPresent(cp -> ((ConfigurationGroovyCustomizer) cp).applyCustomization(conf)); + // ConfigurationCustomizerProvider is treated separately + groovyCustomizers.stream().filter(cp -> !(cp instanceof ConfigurationGroovyCustomizer)) + .forEach(p -> conf.addCompilationCustomizers(p.create())); - this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf); - } - } + groovyCustomizers.stream().filter(cp -> cp instanceof ConfigurationGroovyCustomizer).findFirst() + .ifPresent(cp -> ((ConfigurationGroovyCustomizer) cp).applyCustomization(conf)); - private void use(final Artifact artifact) { - use(artifact.getGroup(), artifact.getArtifact(), artifact.getVersion()); + this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf); } private Object callGlobal(final String name, final Object args[]) { diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java deleted file mode 100644 index 5832e0b074f..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptEnginePluginAcceptor.java +++ /dev/null @@ -1,96 +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.groovy.jsr223; - -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; - -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptException; -import javax.script.SimpleBindings; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * A {@link PluginAcceptor} implementation for bare {@code ScriptEngine} implementations allowing plugins to - * interact with them on initialization. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced. - */ -@Deprecated -public class ScriptEnginePluginAcceptor implements PluginAcceptor { - private final ScriptEngine scriptEngine; - - public ScriptEnginePluginAcceptor(final ScriptEngine scriptEngine) { - this.scriptEngine = scriptEngine; - } - - /** - * Adds global bindings to the {@code ScriptEngine} that will be applied to every evaluated script. - */ - @Override - public void addBinding(final String key, final Object val) { - // The binding was originally added to the engine scope but that proved to be "bad" as it mixed with other - // bindings in that space. - if (null == scriptEngine.getContext().getBindings(ScriptContext.GLOBAL_SCOPE)) - scriptEngine.getContext().setBindings(new SimpleBindings(), ScriptContext.GLOBAL_SCOPE); - scriptEngine.getContext().setAttribute(key, val, ScriptContext.GLOBAL_SCOPE); - } - - /** - * Gets the global bindings that will be applied to every evaluated script. - */ - @Override - public Map getBindings() { - // as these "global" bindings were added to engine scope they should be pulled from the same place - return scriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE); - } - - /** - * If the {@code ScriptEngine} implements the {@link DependencyManager} interface it will try to import the - * specified import statements. - */ - @Override - public void addImports(final Set importStatements) { - if (this.scriptEngine instanceof DependencyManager) - ((DependencyManager) this.scriptEngine).addImports(importStatements); - } - - /** - * Evaluate a script in the {@code ScriptEngine}. Typically {@code eval()} should be called after imports as - * {@code ScriptEngine} resets may occur during import. - */ - @Override - public Object eval(final String script) throws ScriptException { - return this.scriptEngine.eval(script); - } - - /** - * Defines the environment settings for the {@link GremlinPlugin}. - */ - @Override - public Map environment() { - final Map env = new HashMap<>(); - env.put(GremlinPlugin.ENVIRONMENT, "scriptEngine"); - return env; - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java index bdd49b3cbbf..57516871dc1 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TimedInterruptTimeoutException.java @@ -18,12 +18,10 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider; - import java.util.concurrent.TimeoutException; /** - * An exception thrown from the {@link TimedInterruptCustomizerProvider} when the timeout is exceeded. This exception + * An exception thrown from the {@link TimedInterruptGroovyCustomizer} when the timeout is exceeded. This exception * allows differentiation from other "timeout exceptions" that might occur. * * @author Stephen Mallette (http://stephen.genoprime.com) diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java index ac8dd1d5f26..0dde1dcf716 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/TypeCheckedGroovyCustomizer.java @@ -19,7 +19,6 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223; import groovy.transform.TypeChecked; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer; import org.codehaus.groovy.control.customizers.CompilationCustomizer; diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.java deleted file mode 100644 index 4371e8a374a..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/CompileStaticCustomizerProvider.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.groovy.jsr223.customizer; - -import groovy.transform.CompileStatic; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Injects the {@code CompileStatic} transformer to enable type validation on script execution. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced by a public class. - */ -@Deprecated -public class CompileStaticCustomizerProvider implements CompilerCustomizerProvider { - - private final String extensions; - - public CompileStaticCustomizerProvider() { - this(null); - } - - public CompileStaticCustomizerProvider(final String extensions) { - this.extensions = extensions; - } - - @Override - public CompilationCustomizer create() { - final Map annotationParams = new HashMap<>(); - if (extensions != null && !extensions.isEmpty()) { - if (extensions.contains(",")) - annotationParams.put("extensions", Stream.of(extensions.split(",")).collect(Collectors.toList())); - else - annotationParams.put("extensions", Collections.singletonList(extensions)); - } - - return new ASTTransformationCustomizer(annotationParams, CompileStatic.class); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java deleted file mode 100644 index 3c8b673a7a1..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProvider.java +++ /dev/null @@ -1,86 +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.groovy.jsr223.customizer; - -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * Allows configurations to be directly supplied to a groovy {@code CompilerConfiguration} when a - * {@link org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine} is initialized, providing fine-grained - * control over its internals. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced by a public class. - */ -@Deprecated -public class ConfigurationCustomizerProvider implements CompilerCustomizerProvider { - - private final Map properties; - - /** - * Creates a new instance using configuration values specified - */ - public ConfigurationCustomizerProvider(final Object... keyValues) { - if (null == keyValues || keyValues.length == 0) - throw new IllegalArgumentException("ConfigurationCustomizerProvider must have key/values specified"); - - if (keyValues.length % 2 != 0) - throw new IllegalArgumentException("The keyValues must have an even number of values"); - - properties = ElementHelper.asMap(keyValues); - } - - /** - * Creates a new instance using configuration values specified - */ - public ConfigurationCustomizerProvider(final Map keyValues) { - properties = keyValues; - } - - public CompilerConfiguration applyCustomization(final CompilerConfiguration compilerConfiguration) { - final Class clazz = CompilerConfiguration.class; - final List methods = Arrays.asList(clazz.getMethods()); - for (Map.Entry entry : properties.entrySet()) { - final Method method = methods.stream().filter(m -> m.getName().equals("set" + entry.getKey())).findFirst() - .orElseThrow(() -> new IllegalStateException("Invalid setting [" + entry.getKey() + "] for CompilerConfiguration")); - - try { - method.invoke(compilerConfiguration, entry.getValue()); - } catch (Exception ex) { - throw new IllegalStateException(ex); - } - } - - return compilerConfiguration; - } - - @Override - public CompilationCustomizer create() { - throw new UnsupportedOperationException("This is a marker implementation that does not create a CompilationCustomizer instance"); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java deleted file mode 100644 index 30444746ce3..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/InterpreterModeCustomizerProvider.java +++ /dev/null @@ -1,42 +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.groovy.jsr223.customizer; - -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.ast.InterpreterMode; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -/** - * Places the {@code ScriptEngine} in "interpreter mode" where local variables of a script are treated as global - * bindings. This implementation is technically not a true {@link CompilerCustomizerProvider} instance as the - * "interpreter mode" feature does not require a {@code CompilerCustomizer}. This class merely acts as a flag that - * tells the {@link org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine} to turn this feature on. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced by a public class. - */ -@Deprecated -public class InterpreterModeCustomizerProvider implements CompilerCustomizerProvider { - @Override - public CompilationCustomizer create() { - return new ASTTransformationCustomizer(InterpreterMode.class); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java deleted file mode 100644 index c5fc60c5bdf..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ThreadInterruptCustomizerProvider.java +++ /dev/null @@ -1,39 +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.groovy.jsr223.customizer; - -import groovy.transform.ThreadInterrupt; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -/** - * Injects checks for thread interruption into scripts. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced by a public class. - */ -@Deprecated -public class ThreadInterruptCustomizerProvider implements CompilerCustomizerProvider { - @Override - public CompilationCustomizer create() { - return new ASTTransformationCustomizer(ThreadInterrupt.class); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java deleted file mode 100644 index f0e10805fb7..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptCustomizerProvider.java +++ /dev/null @@ -1,66 +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.groovy.jsr223.customizer; - -import groovy.transform.TimedInterrupt; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.codehaus.groovy.ast.tools.GeneralUtils; -import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * Injects a check in loops and other areas of code to interrupt script execution if the run time exceeds the - * specified time. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced by a public class. - */ -@Deprecated -public class TimedInterruptCustomizerProvider implements CompilerCustomizerProvider { - public static final long DEFAULT_INTERRUPTION_TIMEOUT = 60000; - - private final long interruptionTimeout; - - public TimedInterruptCustomizerProvider() { - this(DEFAULT_INTERRUPTION_TIMEOUT); - } - - public TimedInterruptCustomizerProvider(final Long interruptionTimeout) { - this.interruptionTimeout = interruptionTimeout; - } - - public TimedInterruptCustomizerProvider(final Integer interruptionTimeout) { - this.interruptionTimeout = interruptionTimeout.longValue(); - } - - @Override - public CompilationCustomizer create() { - final Map timedInterruptAnnotationParams = new HashMap<>(); - timedInterruptAnnotationParams.put("value", interruptionTimeout); - timedInterruptAnnotationParams.put("unit", GeneralUtils.propX(GeneralUtils.classX(TimeUnit.class), TimeUnit.MILLISECONDS.toString())); - timedInterruptAnnotationParams.put("checkOnMethodStart", false); - timedInterruptAnnotationParams.put("thrown", GeneralUtils.classX(TimedInterruptTimeoutException.class)); - return new ASTTransformationCustomizer(timedInterruptAnnotationParams, TimedInterrupt.class); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java deleted file mode 100644 index 4063d4f962a..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TimedInterruptTimeoutException.java +++ /dev/null @@ -1,38 +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.groovy.jsr223.customizer; - -import java.util.concurrent.TimeoutException; - -/** - * An exception thrown from the {@link TimedInterruptCustomizerProvider} when the timeout is exceeded. This exception - * allows differentiation from other "timeout exceptions" that might occur. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException}. - */ -@Deprecated -public class TimedInterruptTimeoutException extends TimeoutException { - public TimedInterruptTimeoutException() { - } - - public TimedInterruptTimeoutException(final String message) { - super(message); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java deleted file mode 100644 index b5c2729031e..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/TypeCheckedCustomizerProvider.java +++ /dev/null @@ -1,68 +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.groovy.jsr223.customizer; - -import groovy.transform.TypeChecked; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.jsr223.Customizer; -import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Injects the {@code TypeChecked} transformer to enable type validation on script execution. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced by a public class. - */ -@Deprecated -public class TypeCheckedCustomizerProvider implements CompilerCustomizerProvider { - - private final String extensions; - - public TypeCheckedCustomizerProvider() { - this(null); - } - - /** - * Configures the {@code TypeChecked} annotation to use optional extensions. The argument should be one or more - * groovy scripts on the classpath or the fully qualified classname of a precompiled extension. If there are - * multiple extensions then extensions should be comma separated. - */ - public TypeCheckedCustomizerProvider(final String extensions) { - this.extensions = extensions; - } - - @Override - public CompilationCustomizer create() { - final Map annotationParams = new HashMap<>(); - if (extensions != null && !extensions.isEmpty()) { - if (extensions.contains(",")) - annotationParams.put("extensions", Stream.of(extensions.split(",")).collect(Collectors.toList())); - else - annotationParams.put("extensions", Collections.singletonList(extensions)); - } - return new ASTTransformationCustomizer(annotationParams, TypeChecked.class); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java deleted file mode 100644 index 2c216d76b12..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/VariableIdentificationCustomizer.java +++ /dev/null @@ -1,93 +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.groovy.jsr223.customizer; - -import org.codehaus.groovy.ast.ClassCodeVisitorSupport; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.expr.VariableExpression; -import org.codehaus.groovy.classgen.GeneratorContext; -import org.codehaus.groovy.control.CompilationFailedException; -import org.codehaus.groovy.control.CompilePhase; -import org.codehaus.groovy.control.SourceUnit; -import org.codehaus.groovy.control.customizers.CompilationCustomizer; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced. - */ -@Deprecated -public class VariableIdentificationCustomizer extends CompilationCustomizer { - - private static final ThreadLocal> variables = new ThreadLocal>() { - @Override - protected Set initialValue() { - return new TreeSet<>(); - } - }; - - private static final List variablesToIgnore = new ArrayList<>(Arrays.asList("this", "args", "context", "super")); - - public VariableIdentificationCustomizer() { - super(CompilePhase.CLASS_GENERATION); - } - - public Set getVariables() { - return variables.get(); - } - - public void clearVariables() { - variables.get().clear(); - } - - @Override - public void call(final SourceUnit sourceUnit, final GeneratorContext generatorContext, - final ClassNode classNode) throws CompilationFailedException { - classNode.visitContents(new Visitor(sourceUnit)); - } - - class Visitor extends ClassCodeVisitorSupport { - - private SourceUnit sourceUnit; - - public Visitor(final SourceUnit sourceUnit) { - this.sourceUnit = sourceUnit; - } - - @Override - public void visitVariableExpression(final VariableExpression expression) { - if (!variablesToIgnore.contains(expression.getName()) - && expression.getAccessedVariable().isDynamicTyped()) { - variables.get().add(expression.getName()); - } - - super.visitVariableExpression(expression); - } - - @Override - protected SourceUnit getSourceUnit() { - return sourceUnit; - } - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java deleted file mode 100644 index 090da6e3333..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/AbstractGremlinPlugin.java +++ /dev/null @@ -1,99 +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.groovy.plugin; - -import org.codehaus.groovy.tools.shell.Groovysh; -import org.codehaus.groovy.tools.shell.IO; - -import java.util.Map; - -/** - * A base class for a plugin that provides access to the shell and io variables. This is a good class to extend - * from if the plugin needs to interact with the shell in some way, such as the case with those plugins that - * want to utilize the {@link org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor} and may need access to those - * shell and io objects. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin}. - */ -@Deprecated -public abstract class AbstractGremlinPlugin implements GremlinPlugin { - public static final String ENV_CONSOLE_IO = "ConsolePluginAcceptor.io"; - public static final String ENV_CONSOLE_SHELL = "ConsolePluginAcceptor.shell"; - - protected static final String IMPORT_SPACE = "import "; - protected static final String IMPORT_STATIC_SPACE = "import static "; - protected static final String DOT_STAR = ".*"; - - protected IO io; - protected Groovysh shell; - protected final boolean requireConsoleEnvironment; - - /** - * Creates a new instance that does not force the plugin to require the console. This will create a plugin that - * will work in Gremlin Console and Gremlin Server. - */ - public AbstractGremlinPlugin() { - this(false); - } - - /** - * Creates a new instance that allows the plugin to specify whether the console is required or not. It is only - * necessary to require the console if there are specific required calls to {@code IO} or to {@code Groovysh} - * methods in the plugin (as those classes are Gremlin Console related and cannot be provided outside of that - * environment). For a plugin to work in the Gremlin Console and in Gremlin Server this value must be set - * to {@code false}. - */ - public AbstractGremlinPlugin(final boolean requireConsoleEnvironment) { - this.requireConsoleEnvironment = requireConsoleEnvironment; - } - - /** - * {@inheritDoc} - *

- * Provides a base implementation for plugins by grabbing the console environment variables and assigning them - * to the {@link #io} and {@link #shell} member variables. - * - * @throws IllegalEnvironmentException if {@link #requireConsoleEnvironment} is set to true and if either - * the {@link #io} and {@link #shell} member variables are null. - */ - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - final Map environment = pluginAcceptor.environment(); - io = (IO) environment.get(ENV_CONSOLE_IO); - shell = (Groovysh) environment.get(ENV_CONSOLE_SHELL); - - if (requireConsoleEnvironment && (null == io || null == shell)) - throw new IllegalEnvironmentException(this, ENV_CONSOLE_SHELL, ENV_CONSOLE_IO); - - try { - afterPluginTo(pluginAcceptor); - } catch (PluginInitializationException pie) { - throw pie; - } catch (Exception ex) { - throw new PluginInitializationException(ex); - } - } - - /** - * Called after the {@link #pluginTo(PluginAcceptor)} method is executed which sets the {@link #io} and - * {@link #shell} member variables. - */ - public abstract void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException; -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java deleted file mode 100644 index 7fb0bd319b0..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java +++ /dev/null @@ -1,88 +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.groovy.plugin; - -/** - * A software artifact identified by its maven coordinates. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.util.Artifact} - */ -@Deprecated -public class Artifact { - private final String group; - private final String artifact; - private final String version; - - /** - * Create a new instance. - * - * @param group the {@code groupId} - * @param artifact the {@code artifactId} - * @param version the {@code version} - */ - public Artifact(final String group, final String artifact, final String version) { - if (group == null || group.isEmpty()) - throw new IllegalArgumentException("group cannot be null or empty"); - - if (artifact == null || artifact.isEmpty()) - throw new IllegalArgumentException("artifact cannot be null or empty"); - - if (version == null || version.isEmpty()) - throw new IllegalArgumentException("version cannot be null or empty"); - - this.group = group; - this.artifact = artifact; - this.version = version; - } - - public String getGroup() { - return group; - } - - public String getArtifact() { - return artifact; - } - - public String getVersion() { - return version; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - final Artifact a = (Artifact) o; - - if (group != null ? !group.equals(a.group) : a.group != null) return false; - if (artifact != null ? !artifact.equals(a.artifact) : a.artifact != null) return false; - if (version != null ? !version.equals(a.version) : a.version != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = group != null ? group.hashCode() : 0; - result = 31 * result + (artifact != null ? artifact.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - return result; - } -} \ No newline at end of file diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPlugin.java deleted file mode 100644 index 400c0030b87..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPlugin.java +++ /dev/null @@ -1,72 +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.groovy.plugin; - -import java.util.Optional; - -/** - * Those wanting to extend Gremlin can implement this interface to provide mapper imports and extension - * methods to the language itself. Gremlin uses {@code ServiceLoader} to install plugins. It is necessary for - * projects to include a {@code org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin} file in - * {@code META-INF/services} of their packaged project which includes the full class names of the implementations - * of this interface to install. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As for 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin} - */ -@Deprecated -public interface GremlinPlugin { - public static final String ENVIRONMENT = "GremlinPlugin.env"; - - /** - * The name of the plugin. This name should be unique (use a namespaced approach) as naming clashes will - * prevent proper plugin operations. Plugins developed by TinkerPop will be prefixed with "tinkerpop." - * For example, TinkerPop's implementation of Giraph would be named "tinkerpop.giraph". If Facebook were - * to do their own implementation the implementation might be called "facebook.giraph". - */ - public String getName(); - - /** - * Implementers will typically execute imports of classes within their project that they want available in the - * console or they may use meta programming to introduce new extensions to the Gremlin. - * - * @throws IllegalEnvironmentException if there are missing environment properties required by the plugin as - * provided from {@link PluginAcceptor#environment()}. - * @throws PluginInitializationException if there is a failure in the plugin iniitalization process - */ - public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException; - - /** - * Some plugins may require a restart of the plugin host for the classloader to pick up the features. This is - * typically true of plugins that rely on {@code Class.forName()} to dynamically instantiate classes from the - * root classloader (e.g. JDBC drivers that instantiate via @{code DriverManager}). - */ - public default boolean requireRestart() { - return false; - } - - /** - * Allows a plugin to utilize features of the {@code :remote} and {@code :submit} commands of the Gremlin Console. - * This method does not need to be implemented if the plugin is not meant for the Console for some reason or - * if it does not intend to take advantage of those commands. - */ - public default Optional remoteAcceptor() { - return Optional.empty(); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java deleted file mode 100644 index c8664c759db..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/GremlinPluginException.java +++ /dev/null @@ -1,43 +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.groovy.plugin; - -/** - * Base exception for {@link GremlinPlugin}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced. - */ -@Deprecated -public abstract class GremlinPluginException extends Exception { - public GremlinPluginException() { - } - - public GremlinPluginException(final String message) { - super(message); - } - - public GremlinPluginException(final String message, final Throwable cause) { - super(message, cause); - } - - public GremlinPluginException(final Throwable cause) { - super(cause); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java deleted file mode 100644 index 8d6fbe222e3..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/IllegalEnvironmentException.java +++ /dev/null @@ -1,33 +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.groovy.plugin; - -/** - * An exception thrown when the environment variables passed via {@link PluginAcceptor#environment()} do not meet - * the needs of the {@link GremlinPlugin}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced. - */ -@Deprecated -public class IllegalEnvironmentException extends GremlinPluginException { - public IllegalEnvironmentException(final GremlinPlugin plugin, final String... expectedKeys) { - super(String.format("The %s plugin may not be compatible with this environment - requires the follow ScriptEngine environment keys [%s]", plugin.getName(), String.join(",", expectedKeys))); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java deleted file mode 100644 index 91652377680..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginAcceptor.java +++ /dev/null @@ -1,67 +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.groovy.plugin; - -import org.apache.tinkerpop.gremlin.groovy.jsr223.DependencyManager; - -import javax.script.ScriptException; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -/** - * A {@link GremlinPlugin} can be used in multiple environments (e.g. ScriptEngine implementation). Any environment - * wishing to allow plugins should implement the {@code PluginAcceptor}. It acts as an adapter to those environments - * and provides the abstractions required for a plugin to work regardless of the environmental implementations. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.console.PluginAcceptor}. - */ -@Deprecated -public interface PluginAcceptor { - /** - * If the {@code PluginAcceptor} implements the {@link DependencyManager} interface it will try to import the - * specified import statements. - */ - public void addImports(final Set importStatements); - - /** - * Add a variable binding for the plugin host. - */ - public void addBinding(final String key, final Object val); - - /** - * Gets the list of bindings from the plugin host. These bindings will represent the "global" binding list. - */ - public Map getBindings(); - - /** - * Evaluate a script in the {@code PluginAcceptor}. - */ - public Object eval(final String script) throws ScriptException; - - /** - * Returns a map of implementation specific variables that can be referenced by the plugin. Those writing - * plugins should examine the details of the various {@code PluginAcceptor} implementations for the variables - * that they pass, as they may provide important information useful to the plugin itself. - */ - public default Map environment() { - return Collections.emptyMap(); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java deleted file mode 100644 index 0dd6fc1fd4d..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/PluginInitializationException.java +++ /dev/null @@ -1,41 +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.groovy.plugin; - -/** - * An exception that occurs as a result of plugin initialization, typically triggered by a bad evaluation in the - * {@code ScriptEngine}. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, not replaced. - */ -@Deprecated -public class PluginInitializationException extends GremlinPluginException { - public PluginInitializationException(final String message) { - super(message); - } - - public PluginInitializationException(final String message, final Throwable cause) { - super(message, cause); - } - - public PluginInitializationException(final Throwable cause) { - super(cause); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java deleted file mode 100644 index 2bb8663d0a1..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java +++ /dev/null @@ -1,92 +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.groovy.plugin; - -import org.codehaus.groovy.tools.shell.Groovysh; - -import java.io.Closeable; -import java.util.List; - -/** - * The Gremlin Console supports the {@code :remote} and {@code :submit} commands which provide standardized ways - * for plugins to provide "remote connections" to resources and a way to "submit" a command to those resources. - * A "remote connection" does not necessarily have to be a remote server. It simply refers to a resource that is - * external to the console. - *

- * By implementing this interface and returning an instance of it through {@link GremlinPlugin#remoteAcceptor()} a - * plugin can hook into those commands and provide remoting features. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor}; - */ -@Deprecated -public interface RemoteAcceptor extends Closeable { - - public static final String RESULT = "result"; - - /** - * Gets called when {@code :remote} is used in conjunction with the "connect" option. It is up to the - * implementation to decide how additional arguments on the line should be treated after "connect". - * - * @return an object to display as output to the user - * @throws org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException if there is a problem with connecting - */ - public Object connect(final List args) throws RemoteException; - - /** - * Gets called when {@code :remote} is used in conjunction with the {@code config} option. It is up to the - * implementation to decide how additional arguments on the line should be treated after {@code config}. - * - * @return an object to display as output to the user - * @throws org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException if there is a problem with configuration - */ - public Object configure(final List args) throws RemoteException; - - /** - * Gets called when {@code :submit} is executed. It is up to the implementation to decide how additional - * arguments on the line should be treated after {@code :submit}. - * - * @return an object to display as output to the user - * @throws org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException if there is a problem with submission - */ - public Object submit(final List args) throws RemoteException; - - /** - * If the {@code RemoteAcceptor} is used in the Gremlin Console, then this method might be called to determine - * if it can be used in a fashion that supports the {@code :remote console} command. By default, this value is - * set to {@code false}. - *

- * A {@code RemoteAcceptor} should only return {@code true} for this method if it expects that all activities it - * supports are executed through the {@code :sumbit} command. If the users interaction with the remote requires - * working with both local and remote evaluation at the same time, it is likely best to keep this method return - * {@code false}. A good example of this type of plugin would be the Gephi Plugin which uses {@code :remote config} - * to configure a local {@code TraversalSource} to be used and expects calls to {@code :submit} for the same body - * of analysis. - */ - public default boolean allowRemoteConsole() { - return false; - } - - /** - * Retrieve a script as defined in the shell context. This allows for multi-line scripts to be submitted. - */ - public static String getScript(final String submittedScript, final Groovysh shell) { - return submittedScript.startsWith("@") ? shell.getInterp().getContext().getProperty(submittedScript.substring(1)).toString() : submittedScript; - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteException.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteException.java deleted file mode 100644 index 3eb5f697524..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteException.java +++ /dev/null @@ -1,42 +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.groovy.plugin; - -/** - * A mapper {@link Exception} to be thrown when there are problems with processing a command given to a - * {@link org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor}. The message provided to the exception will - * be displayed to the user in the Console. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.jsr223.console.RemoteException}; - */ -@Deprecated -public class RemoteException extends Exception { - public RemoteException(final String message) { - super(message); - } - - public RemoteException(final String message, final Throwable cause) { - super(message, cause); - } - - public RemoteException(final Throwable cause) { - super(cause); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java deleted file mode 100644 index 0666d71417a..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/SugarGremlinPlugin.java +++ /dev/null @@ -1,53 +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.groovy.plugin; - -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; - -/** - * A plugin implementation which allows for the usage of Gremlin Groovy's syntactic sugar. - * - * @author Marko A. Rodriguez (http://markorodriguez.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.SugarGremlinPlugin}. - */ -@Deprecated -public class SugarGremlinPlugin extends AbstractGremlinPlugin { - - @Override - public String getName() { - return "tinkerpop.sugar"; - } - - /** - * {@inheritDoc} - *

- * Executes the {@link SugarLoader#load()} method in the {@link PluginAcceptor}. - */ - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - try { - pluginAcceptor.eval(SugarLoader.class.getPackage().getName() + "." + SugarLoader.class.getSimpleName() + ".load()"); - } catch (Exception ex) { - if (io != null) - io.out.println("Error loading the 'tinkerpop.sugar' plugin - " + ex.getMessage()); - else - throw new PluginInitializationException("Error loading the 'tinkerpop.sugar' plugin - " + ex.getMessage(), ex); - } - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java deleted file mode 100644 index 564c5735d31..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java +++ /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.groovy.plugin.dsl.credential; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.T; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.mindrot.jbcrypt.BCrypt; - -import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.drop; - -/** - * A DSL for managing a "credentials graph" used by Gremlin Server for simple authentication functions. If the - * {@link Graph} is transactional, new transactions will be started for each method call. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph}. - */ -@Deprecated -public class CredentialGraph { - - private final int BCRYPT_ROUNDS = 4; - private final Graph graph; - private final GraphTraversalSource g; - private final boolean supportsTransactions; - - public CredentialGraph(final Graph graph) { - this.graph = graph; - g = graph.traversal(); - supportsTransactions = graph.features().graph().supportsTransactions(); - } - - /** - * Finds a user by username and return {@code null} if one could not be found. - * - * @throws IllegalStateException if there is more than one user with a particular username. - */ - public Vertex findUser(final String username) { - if (supportsTransactions) g.tx().rollback(); - final GraphTraversal t = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username); - final Vertex v = t.hasNext() ? t.next() : null; - if (t.hasNext()) throw new IllegalStateException(String.format("Multiple users with username %s", username)); - return v; - } - - /** - * Creates a new user. - * - * @return the newly created user vertex - */ - public Vertex createUser(final String username, final String password) { - if (findUser(username) != null) throw new IllegalStateException("User with this name already exists"); - if (supportsTransactions) graph.tx().rollback(); - - try { - final Vertex v = graph.addVertex(T.label, CredentialGraphTokens.VERTEX_LABEL_USER, - CredentialGraphTokens.PROPERTY_USERNAME, username, - CredentialGraphTokens.PROPERTY_PASSWORD, BCrypt.hashpw(password, BCrypt.gensalt(BCRYPT_ROUNDS))); - if (supportsTransactions) graph.tx().commit(); - return v; - } catch (Exception ex) { - if (supportsTransactions) graph.tx().rollback(); - throw new RuntimeException(ex); - } - } - - /** - * Removes a user by name. - * - * @return the number of users removed (which should be one or zero) - */ - public long removeUser(final String username) { - if (supportsTransactions) graph.tx().rollback(); - try { - final long count = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username).sideEffect(drop()).count().next(); - if (supportsTransactions) graph.tx().commit(); - return count; - } catch (Exception ex) { - if (supportsTransactions) graph.tx().rollback(); - throw new RuntimeException(ex); - } - } - - /** - * Get a count of the number of users in the database. - */ - public long countUsers() { - if (supportsTransactions) graph.tx().rollback(); - return g.V().hasLabel(CredentialGraphTokens.VERTEX_LABEL_USER).count().next(); - } - - @Override - public String toString() { - return "CredentialGraph{" + - "graph=" + graph + - '}'; - } - - /** - * Wrap up any {@link Graph} instance in the {@code CredentialGraph} DSL. - */ - public static CredentialGraph credentials(final Graph graph) { - return new CredentialGraph(graph); - } -} diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java deleted file mode 100644 index 50ee3461313..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphGremlinPlugin.java +++ /dev/null @@ -1,57 +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.groovy.plugin.dsl.credential; - -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 java.util.HashSet; -import java.util.Set; - -/** - * Plugin for the "credentials graph". This plugin imports the {@link CredentialGraph} to its environment. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphGremlinPlugin}. - */ -@Deprecated -public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin { - - private static final Set IMPORTS = new HashSet() {{ - add(IMPORT_SPACE + CredentialGraph.class.getName()); - add(IMPORT_STATIC_SPACE + CredentialGraph.class.getName() + DOT_STAR); - }}; - - @Override - public String getName() { - return "tinkerpop.credentials"; - } - - /** - * {@inheritDoc} - *

- * Adds imports for the {@link CredentialGraph}. - */ - @Override - public void afterPluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - pluginAcceptor.addImports(IMPORTS); - } -} \ No newline at end of file diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java deleted file mode 100644 index 1f0d8cf44ef..00000000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java +++ /dev/null @@ -1,33 +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.groovy.plugin.dsl.credential; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens}. - */ -@Deprecated -public final class CredentialGraphTokens { - public static final String PROPERTY_USERNAME = "username"; - public static final String PROPERTY_PASSWORD = "password"; - - public static final String VERTEX_LABEL_USER = "user"; - - private CredentialGraphTokens() {} -} diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/DefaultDefaultImportCustomizerProviderTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/DefaultDefaultImportCustomizerProviderTest.java deleted file mode 100644 index 9a3785f1c90..00000000000 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/DefaultDefaultImportCustomizerProviderTest.java +++ /dev/null @@ -1,90 +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.groovy; - -import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader; -import org.junit.Test; - -import java.util.HashSet; -import java.util.Set; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class DefaultDefaultImportCustomizerProviderTest { - static { - SugarLoader.load(); - } - - @Test - public void shouldReturnDefaultImports() { - final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(); - assertImportsInProvider(provider); - } - - @Test - public void shouldReturnWithExtraStaticImports() { - final Set statics = new HashSet<>(); - statics.add("com.test.This.*"); - statics.add("com.test.That.OTHER"); - final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(new HashSet<>(), statics); - assertImportsInProvider(provider); - } - - @Test - public void shouldReturnWithExtraImports() { - final Set imports = new HashSet<>(); - imports.add("com.test.that.*"); - imports.add("com.test.that.That"); - final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(imports, new HashSet<>()); - assertImportsInProvider(provider); - } - - @Test - public void shouldReturnWithBothImportTypes() { - final Set imports = new HashSet<>(); - imports.add("com.test.that.*"); - imports.add("com.test.that.That"); - - final Set statics = new HashSet<>(); - statics.add("com.test.This.*"); - statics.add("com.test.That.OTHER"); - - final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(imports, statics); - assertImportsInProvider(provider); - } - - private static void assertImportsInProvider(DefaultImportCustomizerProvider provider) { - final Set allImports = provider.getAllImports(); - - final Set imports = provider.getImports(); - final Set staticImports = provider.getStaticImports(); - final Set extraImports = provider.getExtraImports(); - final Set extraStaticImports = provider.getExtraStaticImports(); - - assertEquals(imports.size() + staticImports.size() + extraImports.size() + extraStaticImports.size(), allImports.size()); - assertTrue(allImports.containsAll(imports)); - assertTrue(allImports.containsAll(staticImports)); - assertTrue(allImports.containsAll(extraImports)); - assertTrue(allImports.containsAll(extraStaticImports)); - } -} diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java index a56f80555df..9aef783cee4 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java @@ -20,9 +20,9 @@ import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.tinkerpop.gremlin.TestHelper; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptTimeoutException; +import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin; +import org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException; +import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; import org.javatuples.Pair; import org.junit.Test; @@ -30,13 +30,10 @@ import javax.script.CompiledScript; import javax.script.SimpleBindings; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; @@ -166,8 +163,7 @@ public void shouldEvalScriptWithMapBindings() throws Exception { @Test public void shouldEvalScriptWithMapBindingsAndLanguage() throws Exception { - final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap()).create(); + final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create(); final Map b = new HashMap<>(); b.put("x", 1); assertEquals(2, gremlinExecutor.eval("1+x", "gremlin-groovy", b).get()); @@ -176,8 +172,7 @@ public void shouldEvalScriptWithMapBindingsAndLanguage() throws Exception { @Test public void shouldEvalScriptWithMapBindingsAndLanguageThenTransform() throws Exception { - final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap()).create(); + final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create(); final Map b = new HashMap<>(); b.put("x", 1); assertEquals(4, gremlinExecutor.eval("1+x", "gremlin-groovy", b, r -> (int) r * 2).get()); @@ -186,8 +181,7 @@ public void shouldEvalScriptWithMapBindingsAndLanguageThenTransform() throws Exc @Test public void shouldEvalScriptWithMapBindingsAndLanguageThenConsume() throws Exception { - final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyMap()).create(); + final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create(); final Map b = new HashMap<>(); b.put("x", 1); @@ -452,55 +446,15 @@ public void shouldNotExhaustThreads() throws Exception { executorService.awaitTermination(30000, TimeUnit.MILLISECONDS); } - @Test - public void shouldFailUntilImportExecutes() throws Exception { - final GremlinExecutor gremlinExecutor = GremlinExecutor.build().create(); - - final Set imports = new HashSet() {{ - add("import java.awt.Color"); - }}; - - final AtomicInteger successes = new AtomicInteger(0); - final AtomicInteger failures = new AtomicInteger(0); - - // issue 1000 scripts in one thread using a class that isn't imported. this will result in failure. - // while that thread is running start a new thread that issues an addImports to include that class. - // this should block further evals in the first thread until the import is complete at which point - // evals in the first thread will resume and start to succeed - final Thread t1 = new Thread(() -> - IntStream.range(0, 1000).mapToObj(i -> gremlinExecutor.eval("Color.BLACK")) - .forEach(f -> { - f.exceptionally(t -> failures.incrementAndGet()).join(); - if (!f.isCompletedExceptionally()) - successes.incrementAndGet(); - }) - ); - - final Thread t2 = new Thread(() -> { - while (failures.get() < 500) { } - gremlinExecutor.getScriptEngines().addImports(imports); - }); - - t1.start(); - t2.start(); - - t1.join(); - t2.join(); - - assertTrue(successes.intValue() > 0); - assertTrue(failures.intValue() >= 500); - - gremlinExecutor.close(); - } - @Test public void shouldInitializeWithScript() throws Exception { + final Map> config = new HashMap<>(); + final Map scriptPluginConfig = new HashMap<>(); + scriptPluginConfig.put("files", Collections.singletonList(PATHS.get("GremlinExecutorInit.groovy"))); + config.put(ScriptFileGremlinPlugin.class.getName(), scriptPluginConfig); + final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", - Collections.emptyList(), - Collections.emptyList(), - Arrays.asList(PATHS.get("GremlinExecutorInit.groovy")), - Collections.emptyMap()) + .addPlugins("gremlin-groovy", config) .create(); assertEquals(2, gremlinExecutor.eval("add(1,1)").get()); @@ -510,12 +464,13 @@ public void shouldInitializeWithScript() throws Exception { @Test public void shouldInitializeWithScriptAndMakeGlobalBinding() throws Exception { + final Map> config = new HashMap<>(); + final Map scriptPluginConfig = new HashMap<>(); + scriptPluginConfig.put("files", Collections.singletonList(PATHS.get("GremlinExecutorInit.groovy"))); + config.put(ScriptFileGremlinPlugin.class.getName(), scriptPluginConfig); + final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", - Collections.emptyList(), - Collections.emptyList(), - Arrays.asList(PATHS.get("GremlinExecutorInit.groovy")), - Collections.emptyMap()) + .addPlugins("gremlin-groovy", config) .create(); assertEquals(2, gremlinExecutor.eval("add(1,1)").get()); @@ -529,20 +484,17 @@ public void shouldInitializeWithScriptAndMakeGlobalBinding() throws Exception { @Test public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception { - final Map> compilerCustomizerConfig = new HashMap<>(); - final List args = new ArrayList<>(); - args.add(250); - compilerCustomizerConfig.put(TimedInterruptCustomizerProvider.class.getName(), args); + final Map> config = new HashMap<>(); + final Map scriptPluginConfig = new HashMap<>(); + scriptPluginConfig.put("files", Collections.singletonList(PATHS.get("GremlinExecutorInit.groovy"))); + config.put(ScriptFileGremlinPlugin.class.getName(), scriptPluginConfig); - final Map config = new HashMap<>(); - config.put("compilerCustomizerProviders", compilerCustomizerConfig); + final Map groovyPluginConfig = new HashMap<>(); + groovyPluginConfig.put("timedInterrupt", 250); + config.put(GroovyCompilerGremlinPlugin.class.getName(), groovyPluginConfig); final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", - Collections.emptyList(), - Collections.emptyList(), - Arrays.asList(PATHS.get("GremlinExecutorInit.groovy")), - config) + .addPlugins("gremlin-groovy", config) .create(); for (int ix = 0; ix < 5; ix++) { @@ -563,18 +515,17 @@ public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception @Test public void shouldInterruptWhile() throws Exception { - final Map> compilerCustomizerConfig = new HashMap<>(); - compilerCustomizerConfig.put(ThreadInterruptCustomizerProvider.class.getName(), new ArrayList<>()); + final Map> config = new HashMap<>(); + final Map scriptPluginConfig = new HashMap<>(); + scriptPluginConfig.put("files", Collections.singletonList(PATHS.get("GremlinExecutorInit.groovy"))); + config.put(ScriptFileGremlinPlugin.class.getName(), scriptPluginConfig); - final Map config = new HashMap<>(); - config.put("compilerCustomizerProviders", compilerCustomizerConfig); + final Map groovyPluginConfig = new HashMap<>(); + groovyPluginConfig.put("enableThreadInterrupt", true); + config.put(GroovyCompilerGremlinPlugin.class.getName(), groovyPluginConfig); final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", - Collections.emptyList(), - Collections.emptyList(), - Arrays.asList(PATHS.get("GremlinExecutorInit.groovy")), - config) + .addPlugins("gremlin-groovy", config) .create(); final AtomicBoolean asserted = new AtomicBoolean(false); @@ -594,25 +545,6 @@ public void shouldInterruptWhile() throws Exception { assertTrue(asserted.get()); } - @Test - public void shouldInitializeWithScriptAndWorkAfterReset() throws Exception { - final GremlinExecutor gremlinExecutor = GremlinExecutor.build() - .addEngineSettings("gremlin-groovy", - Collections.emptyList(), - Collections.emptyList(), - Arrays.asList(PATHS.get("GremlinExecutorInit.groovy")), - Collections.emptyMap()) - .create(); - - assertEquals(2, gremlinExecutor.eval("add(1,1)").get()); - - gremlinExecutor.getScriptEngines().reset(); - - assertEquals(2, gremlinExecutor.eval("add(1,1)").get()); - - gremlinExecutor.close(); - } - @Test public void shouldNotShutdownExecutorServicesSuppliedToGremlinExecutor() throws Exception { final ScheduledExecutorService service = Executors.newScheduledThreadPool(4, testingThreadFactory); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEnginesTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEnginesTest.java deleted file mode 100644 index 3a4b23359b2..00000000000 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEnginesTest.java +++ /dev/null @@ -1,218 +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.groovy.engine; - -import groovy.lang.MissingPropertyException; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -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.junit.Test; - -import javax.script.Bindings; -import javax.script.SimpleBindings; -import java.awt.*; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.IntStream; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class ScriptEnginesTest { - @Test - public void shouldNotPreserveInstantiatedVariablesBetweenEvals() throws Exception { - final ScriptEngines engines = new ScriptEngines(se -> {}); - engines.reload("gremlin-groovy", Collections.emptySet(), - Collections.emptySet(), Collections.emptyMap()); - - final Bindings localBindingsFirstRequest = new SimpleBindings(); - localBindingsFirstRequest.put("x", "there"); - assertEquals("herethere", engines.eval("z = 'here' + x", localBindingsFirstRequest, "gremlin-groovy")); - - try { - final Bindings localBindingsSecondRequest = new SimpleBindings(); - engines.eval("z", localBindingsSecondRequest, "gremlin-groovy"); - fail("Should not have knowledge of z"); - } catch (Exception ex) { - final Throwable root = ExceptionUtils.getRootCause(ex); - assertThat(root, instanceOf(MissingPropertyException.class)); - } - } - - @Test - public void shouldMergeBindingsFromLocalAndGlobal() throws Exception { - final ScriptEngines engines = new ScriptEngines(se -> {}); - engines.reload("gremlin-groovy", Collections.emptySet(), - Collections.emptySet(), Collections.emptyMap()); - - engines.loadPlugins(Arrays.asList(new GremlinPlugin() { - @Override - public String getName() { - return "mock"; - } - - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - pluginAcceptor.addBinding("y", "here"); - } - })); - - final Bindings localBindings = new SimpleBindings(); - localBindings.put("x", "there"); - - assertEquals("herethere", engines.eval("y+x", localBindings, "gremlin-groovy")); - } - - @Test - public void shouldMergeBindingsFromLocalAndGlobalWithMultiplePlugins() throws Exception { - final ScriptEngines engines = new ScriptEngines(se -> {}); - engines.reload("gremlin-groovy", Collections.emptySet(), - Collections.emptySet(), Collections.emptyMap()); - - engines.loadPlugins(Arrays.asList(new GremlinPlugin() { - @Override - public String getName() { - return "mock1"; - } - - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - pluginAcceptor.addBinding("y", "here"); - } - })); - - final Bindings localBindings = new SimpleBindings(); - localBindings.put("x", "there"); - - assertEquals("herethere", engines.eval("y+x", localBindings, "gremlin-groovy")); - - engines.loadPlugins(Arrays.asList(new GremlinPlugin() { - @Override - public String getName() { - return "mock2"; - } - - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - pluginAcceptor.addBinding("z", "where"); - pluginAcceptor.addImports(new HashSet<>(Arrays.asList("import java.awt.Color"))); - } - })); - - assertEquals("heretherewhere", engines.eval("y+x+z", localBindings, "gremlin-groovy")); - assertEquals(Color.RED, engines.eval("Color.RED", localBindings, "gremlin-groovy")); - - } - - @Test - public void shouldMergeBindingsWhereLocalOverridesGlobal() throws Exception { - final ScriptEngines engines = new ScriptEngines(se -> {}); - engines.reload("gremlin-groovy", Collections.emptySet(), - Collections.emptySet(), Collections.emptyMap()); - - engines.loadPlugins(Arrays.asList(new GremlinPlugin() { - @Override - public String getName() { - return "mock"; - } - - @Override - public void pluginTo(final PluginAcceptor pluginAcceptor) throws IllegalEnvironmentException, PluginInitializationException { - pluginAcceptor.addBinding("y", "here"); - } - })); - - // the "y" below should override the global variable setting. - final Bindings localBindings = new SimpleBindings(); - localBindings.put("y", "there"); - localBindings.put("z", "where"); - - assertEquals("therewhere", engines.eval("y+z", localBindings, "gremlin-groovy")); - } - - @Test - public void shouldFailUntilImportExecutes() throws Exception { - final ScriptEngines engines = new ScriptEngines(se -> {}); - engines.reload("gremlin-groovy", Collections.emptySet(), - Collections.emptySet(), Collections.emptyMap()); - - final Set imports = new HashSet() {{ - add("import java.awt.Color"); - }}; - - final AtomicInteger successes = new AtomicInteger(0); - final AtomicInteger failures = new AtomicInteger(0); - final CountDownLatch latch = new CountDownLatch(1); - - final Thread threadImport = new Thread(() -> { - engines.addImports(imports); - latch.countDown(); - }); - - // issue 1000 scripts in one thread using a class that isn't imported. this will result in failure. - // while that thread is running start a new thread that issues an addImports to include that class. - // this should block further evals in the first thread until the import is complete at which point - // evals in the first thread will resume and start to succeed - final Thread threadEvalAndTriggerImport = new Thread(() -> - IntStream.range(0, 1000).forEach(i -> { - try { - - engines.eval("Color.BLACK", new SimpleBindings(), "gremlin-groovy"); - successes.incrementAndGet(); - } catch (Exception ex) { - // stop the failures halfway and allow the import thread to start - if (failures.incrementAndGet() == 500) { - threadImport.start(); - - // block until the import occurs - try { - latch.await(30000, TimeUnit.MILLISECONDS); - } catch (Exception inner) { - // this test should fail given that the nubmer of asserts for successes will not implement - // appropriately if this RuntimeException is thrown. - throw new RuntimeException(inner); - } - } - } - }) - ); - - threadEvalAndTriggerImport.start(); - - threadEvalAndTriggerImport.join(); - - assertTrue("Success: " + successes.intValue() + " - Success: " + failures.intValue(), successes.intValue() == 500); - assertTrue("Failures: " + successes.intValue() + " - Failures: " + failures.intValue(), failures.intValue() == 500); - - engines.close(); - } -} diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProviderTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationCustomizerProviderTest.java similarity index 86% rename from gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProviderTest.java rename to gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationCustomizerProviderTest.java index 54b55b1603d..1a06455241e 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/ConfigurationCustomizerProviderTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/ConfigurationCustomizerProviderTest.java @@ -16,9 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer; +package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.commons.lang.exception.ExceptionUtils; import org.codehaus.groovy.control.CompilerConfiguration; import org.junit.Test; @@ -33,19 +32,19 @@ public class ConfigurationCustomizerProviderTest { @Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForNoSettings() { - new ConfigurationCustomizerProvider(); + new ConfigurationGroovyCustomizer(); } @Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForInvalidSettings() { - new ConfigurationCustomizerProvider("only-one-arg"); + new ConfigurationGroovyCustomizer("only-one-arg"); } @Test public void shouldThrowExceptionForNotFoundSetting() { final CompilerConfiguration configuration = new CompilerConfiguration(); try { - final ConfigurationCustomizerProvider provider = new ConfigurationCustomizerProvider( + final ConfigurationGroovyCustomizer provider = new ConfigurationGroovyCustomizer( "Tolerance", 3, "NotRealSettingThatWouldEverOccur2", new java.util.Date()); @@ -64,7 +63,7 @@ public void shouldApplyConfigurationChanges() { assertNull(configuration.getScriptBaseClass()); assertEquals(false, configuration.getDebug()); - final ConfigurationCustomizerProvider provider = new ConfigurationCustomizerProvider( + final ConfigurationGroovyCustomizer provider = new ConfigurationGroovyCustomizer( "Tolerance", 3, "ScriptBaseClass", "Something", "Debug", true); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java index 6f3383eb929..b47c9c41e63 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java @@ -19,7 +19,6 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.codehaus.groovy.control.MultipleCompilationErrorsException; import org.junit.Test; @@ -34,23 +33,6 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public class GremlinGroovyScriptEngineCompileStaticTest { - @Test - public void shouldCompileStaticDeprecated() throws Exception { - // with no type checking this should pass - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) { - assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()")); - } - - final CompileStaticCustomizerProvider provider = new CompileStaticCustomizerProvider(); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) { - scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - final Throwable root = ExceptionUtils.getRootCause(se); - assertEquals(MultipleCompilationErrorsException.class, root.getClass()); - assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists.")); - } - } @Test public void shouldCompileStatic() throws Exception { @@ -70,25 +52,6 @@ public void shouldCompileStatic() throws Exception { } } - @Test - public void shouldCompileStaticWithExtensionDeprecated() throws Exception { - // with no type checking extension this should pass - final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider(); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) { - assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red")); - } - - final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider( - PrecompiledExtensions.PreventColorUsageExtension.class.getName()); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { - scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass()); - assertThat(se.getMessage(), containsString("Method call is not allowed!")); - } - } - @Test public void shouldCompileStaticWithExtension() throws Exception { // with no type checking extension this should pass @@ -108,35 +71,6 @@ public void shouldCompileStaticWithExtension() throws Exception { } } - @Test - public void shouldCompileStaticWithMultipleExtensionDeprecated() throws Exception { - // with no type checking extension this should pass - final CompileStaticCustomizerProvider providerNoExtension = new CompileStaticCustomizerProvider(); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) { - assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red")); - assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count")); - } - - final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider( - PrecompiledExtensions.PreventColorUsageExtension.class.getName() + - "," + PrecompiledExtensions.PreventCountDownLatchUsageExtension.class.getName()); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { - scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass()); - assertThat(se.getMessage(), containsString("Method call is not allowed!")); - } - - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { - scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass()); - assertThat(se.getMessage(), containsString("Method call is not allowed!")); - } - } - @Test public void shouldCompileStaticWithMultipleExtension() throws Exception { // with no type checking extension this should pass diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java index 289b2ca1f39..841427423b7 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java @@ -18,8 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider; import org.junit.Test; import javax.script.ScriptEngine; @@ -30,14 +28,6 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public class GremlinGroovyScriptEngineConfigTest { - @Test - public void shouldAddBaseScriptClassDeprecated() throws Exception { - final ScriptEngine engine = new GremlinGroovyScriptEngine( - new ConfigurationCustomizerProvider("ScriptBaseClass", BaseScriptForTesting.class.getName()), - new DefaultImportCustomizerProvider()); - - assertEquals("hello, stephen", engine.eval("hello('stephen')")); - } @Test public void shouldAddBaseScriptClass() throws Exception { diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java index 6018a488162..2b27dd01534 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java @@ -20,8 +20,6 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.TestHelper; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.FileSandboxExtension; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -69,7 +67,7 @@ public static void destroy() { @Test public void shouldEvalAsTheMethodIsWhiteListed() throws Exception { - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(FileSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(FileSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { assertEquals(123, engine.eval("java.lang.Math.abs(-123)")); assertThat(engine.eval("new Boolean(true)"), is(true)); @@ -79,7 +77,7 @@ public void shouldEvalAsTheMethodIsWhiteListed() throws Exception { @Test public void shouldEvalAsGroovyPropertiesWhenWhiteListed() throws Exception { - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(FileSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(FileSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { assertThat(Arrays.equals("test".getBytes(), (byte[]) engine.eval("'test'.bytes")), is(true)); } @@ -87,10 +85,10 @@ public void shouldEvalAsGroovyPropertiesWhenWhiteListed() throws Exception { @Test public void shouldPreventMaliciousStuffWithSystemButAllowSomeMethodsOnSystem() throws Exception { - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(FileSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(FileSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { - assertThat((long) engine.eval("System.currentTimeMillis()"), greaterThan(0l)); - assertThat((long) engine.eval("System.nanoTime()"), greaterThan(0l)); + assertThat((long) engine.eval("System.currentTimeMillis()"), greaterThan(0L)); + assertThat((long) engine.eval("System.nanoTime()"), greaterThan(0L)); engine.eval("System.exit(0)"); fail("Should have a compile error because class/method is not white listed"); @@ -102,7 +100,7 @@ public void shouldPreventMaliciousStuffWithSystemButAllowSomeMethodsOnSystem() t @Test public void shouldPreventMaliciousStuffWithFile() throws Exception { - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(FileSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(FileSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { engine.eval("java.nio.file.FileSystems.getDefault()"); fail("Should have a compile error because class/method is not white listed"); @@ -115,7 +113,7 @@ public void shouldPreventMaliciousStuffWithFile() throws Exception { @Test @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldEvalOnGAsTheMethodIsWhiteListed() throws Exception { - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(FileSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(FileSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java index 84542e10caf..4b52a5e0d3b 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineOverGraphTest.java @@ -20,10 +20,6 @@ import groovy.lang.MissingPropertyException; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Direction; @@ -32,7 +28,6 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory; import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.apache.tinkerpop.gremlin.util.config.YamlConfiguration; import org.junit.Assert; import org.junit.Test; @@ -42,7 +37,6 @@ import javax.script.ScriptException; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.concurrent.CountDownLatch; @@ -78,15 +72,7 @@ public void shouldDoSomeGremlin() throws Exception { public void shouldLoadImports() throws Exception { final Graph graph = TinkerFactory.createModern(); final GraphTraversalSource g = graph.traversal(); - final ScriptEngine engineNoImports = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); - try { - engineNoImports.eval("Vertex.class.getName()"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - final ScriptEngine engineWithImports = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) new DefaultImportCustomizerProvider()); + final ScriptEngine engineWithImports = new GremlinGroovyScriptEngine(); engineWithImports.put("g", g); assertEquals(Vertex.class.getName(), engineWithImports.eval("Vertex.class.getName()")); assertEquals(2l, engineWithImports.eval("g.V().has('age',gt(30)).count().next()")); @@ -95,36 +81,6 @@ public void shouldLoadImports() throws Exception { assertEquals(Direction.BOTH, engineWithImports.eval("Direction.BOTH")); } - - @Test - public void shouldLoadStandardImportsAndThenAddToThem() throws Exception { - final Graph graph = TinkerFactory.createModern(); - final GraphTraversalSource g = graph.traversal(); - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) new DefaultImportCustomizerProvider()); - engine.put("g", g); - assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()")); - assertEquals(2l, engine.eval("g.V().has('age',gt(30)).count().next()")); - assertEquals(Direction.IN, engine.eval("Direction.IN")); - assertEquals(Direction.OUT, engine.eval("Direction.OUT")); - assertEquals(Direction.BOTH, engine.eval("Direction.BOTH")); - - try { - engine.eval("YamlConfiguration.class.getName()"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.addImports(new HashSet<>(Arrays.asList("import " + YamlConfiguration.class.getCanonicalName()))); - engine.put("g", g); - assertEquals(YamlConfiguration.class.getName(), engine.eval("YamlConfiguration.class.getName()")); - assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()")); - assertEquals(2l, engine.eval("g.V().has('age',gt(30)).count().next()")); - assertEquals(Direction.IN, engine.eval("Direction.IN")); - assertEquals(Direction.OUT, engine.eval("Direction.OUT")); - assertEquals(Direction.BOTH, engine.eval("Direction.BOTH")); - } - @Test public void shouldProperlyHandleBindings() throws Exception { final Graph graph = TinkerFactory.createClassic(); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java index 349fcd5dccf..c3bac74cbe1 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineSandboxedStandardTest.java @@ -18,11 +18,7 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -48,18 +44,18 @@ public class GremlinGroovyScriptEngineSandboxedStandardTest { @Parameterized.Parameters(name = "{0}") public static Iterable data() { return Arrays.asList(new Object[][]{ - {TypeCheckedCustomizerProvider.class.getSimpleName(), new TypeCheckedCustomizerProvider(), new TypeCheckedCustomizerProvider(SimpleSandboxExtension.class.getName())}, - {CompileStaticCustomizerProvider.class.getSimpleName(), new CompileStaticCustomizerProvider(), new CompileStaticCustomizerProvider(SimpleSandboxExtension.class.getName())}}); + {TypeCheckedGroovyCustomizer.class.getSimpleName(), new TypeCheckedGroovyCustomizer(), new TypeCheckedGroovyCustomizer(SimpleSandboxExtension.class.getName())}, + {CompileStaticGroovyCustomizer.class.getSimpleName(), new CompileStaticGroovyCustomizer(), new CompileStaticGroovyCustomizer(SimpleSandboxExtension.class.getName())}}); } @Parameterized.Parameter(value = 0) public String name; @Parameterized.Parameter(value = 1) - public CompilerCustomizerProvider notSandboxed; + public GroovyCustomizer notSandboxed; @Parameterized.Parameter(value = 2) - public CompilerCustomizerProvider sandboxed; + public GroovyCustomizer sandboxed; @Test public void shouldEvalGraphTraversalSource() throws Exception { diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java index eb0a44b701c..f21b4c4577a 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java @@ -22,11 +22,6 @@ import groovy.lang.MissingPropertyException; import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.NoImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import org.javatuples.Pair; import org.junit.Test; import org.slf4j.Logger; @@ -37,27 +32,19 @@ import javax.script.ScriptEngine; import javax.script.ScriptException; import javax.script.SimpleBindings; -import java.awt.*; import java.io.StringWriter; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertEquals; @@ -98,28 +85,6 @@ public void shouldEvalWithNoBindings() throws Exception { assertEquals(3, engine.eval("addItUp(1,2)")); } - @Test - public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindingsDeprecated() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider()); - engine.eval("def addItUp = { x, y -> x + y }"); - assertEquals(3, engine.eval("int xxx = 1 + 2")); - assertEquals(4, engine.eval("yyy = xxx + 1")); - assertEquals(7, engine.eval("def zzz = yyy + xxx")); - assertEquals(4, engine.eval("zzz - xxx")); - assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer")); - assertEquals("accessible-globally", engine.eval("outer")); - - try { - engine.eval("inner"); - fail("Should not have been able to access 'inner'"); - } catch (Exception ex) { - final Throwable root = ExceptionUtils.getRootCause(ex); - assertThat(root, instanceOf(MissingPropertyException.class)); - } - - assertEquals(10, engine.eval("addItUp(zzz,xxx)")); - } - @Test public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exception { final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeGroovyCustomizer()); @@ -142,30 +107,6 @@ public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exc assertEquals(10, engine.eval("addItUp(zzz,xxx)")); } - @Test - public void shouldPromoteDefinedVarsInInterpreterModeWithBindingsDeprecated() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider()); - final Bindings b = new SimpleBindings(); - b.put("x", 2); - engine.eval("def addItUp = { x, y -> x + y }", b); - assertEquals(3, engine.eval("int xxx = 1 + x", b)); - assertEquals(4, engine.eval("yyy = xxx + 1", b)); - assertEquals(7, engine.eval("def zzz = yyy + xxx", b)); - assertEquals(4, engine.eval("zzz - xxx", b)); - assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer", b)); - assertEquals("accessible-globally", engine.eval("outer", b)); - - try { - engine.eval("inner", b); - fail("Should not have been able to access 'inner'"); - } catch (Exception ex) { - final Throwable root = ExceptionUtils.getRootCause(ex); - assertThat(root, instanceOf(MissingPropertyException.class)); - } - - assertEquals(10, engine.eval("addItUp(zzz,xxx)", b)); - } - @Test public void shouldPromoteDefinedVarsInInterpreterModeWithBindings() throws Exception { final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeGroovyCustomizer()); @@ -218,106 +159,6 @@ public void shouldEvalFailingAssert() throws Exception { engine.eval("assert 1==0"); } - @Test - public void shouldLoadImportsViaDependencyManagerInterface() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); - try { - engine.eval("Vertex.class.getName()"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.addImports(new HashSet<>(Arrays.asList("import org.apache.tinkerpop.gremlin.structure.Vertex"))); - assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()")); - } - - @Test - public void shouldLoadImportsViaDependencyManagerInterfaceAdditively() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); - try { - engine.eval("Vertex.class.getName()"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - try { - engine.eval("StreamFactory.class.getName()"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.addImports(new HashSet<>(Arrays.asList("import " + Vertex.class.getCanonicalName()))); - assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()")); - - try { - engine.eval("IteratorUtils.class.getName()"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.addImports(new HashSet<>(Arrays.asList("import " + IteratorUtils.class.getCanonicalName()))); - assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()")); - assertEquals(IteratorUtils.class.getName(), engine.eval("IteratorUtils.class.getName()")); - } - - @Test - public void shouldLoadImportsViaDependencyManagerFromDependencyGatheredByUse() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); - try { - engine.eval("org.apache.commons.math3.util.FastMath.abs(-1235)"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.addImports(new HashSet<>(Arrays.asList("import org.apache.commons.math3.util.FastMath"))); - engine.use("org.apache.commons", "commons-math3", "3.2"); - assertEquals(1235, engine.eval("org.apache.commons.math3.util.FastMath.abs(-1235)")); - } - - @Test - public void shouldAllowsUseToBeExecutedAfterImport() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); - try { - engine.eval("org.apache.commons.math3.util.FastMath.abs(-1235)"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.use("org.apache.commons", "commons-math3", "3.2"); - engine.addImports(new HashSet<>(Arrays.asList("import org.apache.commons.math3.util.FastMath"))); - assertEquals(1235, engine.eval("org.apache.commons.math3.util.FastMath.abs(-1235)")); - } - - @Test - public void shouldAllowsMultipleImports() throws Exception { - final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine((CompilerCustomizerProvider) NoImportCustomizerProvider.INSTANCE); - try { - engine.eval("Color.RED"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - try { - engine.eval("SystemColor.ACTIVE_CAPTION"); - fail("Should have thrown an exception because no imports were supplied"); - } catch (Exception se) { - assertTrue(se instanceof ScriptException); - } - - engine.addImports(new HashSet<>(Arrays.asList("import java.awt.Color"))); - assertEquals(Color.RED, engine.eval("Color.RED")); - - engine.addImports(new HashSet<>(Arrays.asList("import java.awt.SystemColor"))); - assertEquals(Color.RED, engine.eval("Color.RED")); - assertEquals(SystemColor.ACTIVE_CAPTION, engine.eval("SystemColor.ACTIVE_CAPTION")); - } @Test public void shouldClearEngineScopeOnReset() throws Exception { @@ -347,62 +188,6 @@ public void shouldClearEngineScopeOnReset() throws Exception { assertEquals(3, ((Closure) b.get("x")).call(1)); } - @Test - public void shouldReloadClassLoaderWhileDoingEvalInSeparateThread() throws Exception { - final AtomicBoolean fail = new AtomicBoolean(false); - final AtomicInteger counter = new AtomicInteger(0); - final CountDownLatch latch = new CountDownLatch(1); - final AtomicReference color = new AtomicReference<>(Color.RED); - - final GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(NoImportCustomizerProvider.INSTANCE); - - try { - scriptEngine.eval("Color.BLACK"); - fail("Should fail as class is not yet imported"); - } catch (ScriptException se) { - // should get here as Color.BLACK is not imported yet. - logger.info("Failed to execute Color.BLACK as expected."); - } - - final Thread evalThread = new Thread(() -> { - try { - // execute scripts until the other thread releases this latch (i.e. after import) - while (latch.getCount() == 1) { - scriptEngine.eval("1+1"); - counter.incrementAndGet(); - } - - color.set((Color) scriptEngine.eval("Color.BLACK")); - } catch (Exception se) { - fail.set(true); - } - }, "test-reload-classloader-1"); - - evalThread.start(); - - // let the first thread execute a bit. - Thread.sleep(1000); - - final Thread importThread = new Thread(() -> { - logger.info("Importing java.awt.Color..."); - final Set imports = new HashSet() {{ - add("import java.awt.Color"); - }}; - scriptEngine.addImports(imports); - latch.countDown(); - }, "test-reload-classloader-2"); - - importThread.start(); - - // block until both threads are done - importThread.join(); - evalThread.join(); - - assertEquals(Color.BLACK, color.get()); - assertThat(counter.get(), greaterThan(0)); - assertFalse(fail.get()); - } - @Test public void shouldResetClassLoader() throws Exception { final GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java index 499373fe858..10f8e1f174f 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineThreadInterruptTest.java @@ -18,7 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider; import org.junit.Test; import javax.script.ScriptEngine; @@ -32,26 +31,6 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public class GremlinGroovyScriptEngineThreadInterruptTest { - @Test - public void shouldInterruptWhileDeprecated() throws Exception { - final ScriptEngine engine = new GremlinGroovyScriptEngine(new ThreadInterruptCustomizerProvider()); - final AtomicBoolean asserted = new AtomicBoolean(false); - - final Thread t = new Thread(() -> { - try { - engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}"); - } catch (ScriptException se) { - asserted.set(se.getCause().getCause() instanceof InterruptedException); - } - }); - - t.start(); - Thread.sleep(100); - t.interrupt(); - while(t.isAlive()) {} - - assertTrue(asserted.get()); - } @Test public void shouldInterruptWhile() throws Exception { diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java index 1745b5d3b11..bde5e6fbc2d 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java @@ -18,9 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptTimeoutException; import org.junit.Test; import javax.script.ScriptEngine; @@ -34,18 +31,6 @@ */ public class GremlinGroovyScriptEngineTimedInterruptTest { - @Test - public void shouldTimeoutScriptOnTimedWhileDeprecated() throws Exception { - final ScriptEngine engine = new GremlinGroovyScriptEngine( - new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider()); - try { - engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}"); - fail("This should have timed out"); - } catch (ScriptException se) { - assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass()); - } - } - @Test public void shouldTimeoutScriptOnTimedWhile() throws Exception { final ScriptEngine engine = new GremlinGroovyScriptEngine(new TimedInterruptGroovyCustomizer(1000)); @@ -57,22 +42,6 @@ public void shouldTimeoutScriptOnTimedWhile() throws Exception { } } - @Test - public void shouldTimeoutScriptOnTimedWhileOnceEngineHasBeenAliveForLongerThanTimeoutDeprecated() throws Exception { - final ScriptEngine engine = new GremlinGroovyScriptEngine( - new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider()); - Thread.sleep(2000); - try { - engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}"); - fail("This should have timed out"); - } catch (ScriptException se) { - assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass()); - } - - assertEquals(2, engine.eval("1+1")); - } - - @Test public void shouldTimeoutScriptOnTimedWhileOnceEngineHasBeenAliveForLongerThanTimeout() throws Exception { final ScriptEngine engine = new GremlinGroovyScriptEngine(new TimedInterruptGroovyCustomizer(1000)); @@ -87,27 +56,6 @@ public void shouldTimeoutScriptOnTimedWhileOnceEngineHasBeenAliveForLongerThanTi assertEquals(2, engine.eval("1+1")); } - @Test - public void shouldContinueToEvalScriptsEvenWithTimedInterruptDeprecated() throws Exception { - final ScriptEngine engine = new GremlinGroovyScriptEngine( - new TimedInterruptCustomizerProvider(1000), new DefaultImportCustomizerProvider()); - - for (int ix = 0; ix < 5; ix++) { - try { - // this script takes 1000 ms longer than the interruptionTimeout - engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {}"); - fail("This should have timed out"); - } catch (ScriptException se) { - assertEquals(TimedInterruptTimeoutException.class, se.getCause().getCause().getClass()); - } - - // this script takes 500 ms less than the interruptionTimeout - assertEquals("test", engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 500) {};'test'")); - } - - assertEquals(2, engine.eval("1+1")); - } - @Test public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception { final ScriptEngine engine = new GremlinGroovyScriptEngine( @@ -129,16 +77,6 @@ public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception assertEquals(2, engine.eval("1+1")); } - @Test - public void shouldNotTimeoutStandaloneFunctionDeprecated() throws Exception { - // use a super fast timeout which should not prevent the call of a cached function - final ScriptEngine engine = new GremlinGroovyScriptEngine( - new TimedInterruptCustomizerProvider(1), new DefaultImportCustomizerProvider()); - engine.eval("def addItUp(x,y) { x + y }"); - - assertEquals(3, engine.eval("addItUp(1,2)")); - } - @Test public void shouldNotTimeoutStandaloneFunction() throws Exception { // use a super fast timeout which should not prevent the call of a cached function diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java index 0ff2706213d..c2d555f0d80 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTinkerPopSandboxTest.java @@ -18,9 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TinkerPopSandboxExtension; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Graph; @@ -42,7 +39,7 @@ public class GremlinGroovyScriptEngineTinkerPopSandboxTest { @Test public void shouldNotEvalAsTheMethodIsNotWhiteListed() throws Exception { - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(TinkerPopSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(TinkerPopSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { engine.eval("java.lang.Math.abs(123)"); fail("Should have a compile error because class/method is not white listed"); @@ -56,7 +53,7 @@ public void shouldNotEvalAsTheMethodIsNotWhiteListed() throws Exception { public void shouldEvalOnGAsTheMethodIsWhiteListed() throws Exception { final Graph graph = TinkerFactory.createModern(); final GraphTraversalSource g = graph.traversal(); - final CompilerCustomizerProvider standardSandbox = new CompileStaticCustomizerProvider(TinkerPopSandboxExtension.class.getName()); + final CompileStaticGroovyCustomizer standardSandbox = new CompileStaticGroovyCustomizer(TinkerPopSandboxExtension.class.getName()); try (GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(standardSandbox)) { final Bindings bindings = engine.createBindings(); bindings.put("g", g); diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java index 6c70e8e161a..4299f3da3a5 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java @@ -19,8 +19,6 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223; import org.apache.commons.lang.exception.ExceptionUtils; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider; import org.codehaus.groovy.control.MultipleCompilationErrorsException; import org.junit.Test; @@ -35,23 +33,6 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public class GremlinGroovyScriptEngineTypeCheckedTest { - @Test - public void shouldTypeCheckDeprecated() throws Exception { - // with no type checking this should pass - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) { - assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()")); - } - - final TypeCheckedCustomizerProvider provider = new TypeCheckedCustomizerProvider(); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) { - scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - final Throwable root = ExceptionUtils.getRootCause(se); - assertEquals(MultipleCompilationErrorsException.class, root.getClass()); - assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists.")); - } - } @Test public void shouldTypeCheck() throws Exception { @@ -71,25 +52,6 @@ public void shouldTypeCheck() throws Exception { } } - @Test - public void shouldTypeCheckWithExtensionDeprecated() throws Exception { - // with no type checking extension this should pass - final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider(); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) { - assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red")); - } - - final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider( - PrecompiledExtensions.PreventColorUsageExtension.class.getName()); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { - scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass()); - assertThat(se.getMessage(), containsString("Method call is not allowed!")); - } - } - @Test public void shouldTypeCheckWithExtension() throws Exception { // with no type checking extension this should pass @@ -98,7 +60,7 @@ public void shouldTypeCheckWithExtension() throws Exception { assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red")); } - final CompileStaticCustomizerProvider providerWithExtension = new CompileStaticCustomizerProvider( + final TypeCheckedGroovyCustomizer providerWithExtension = new TypeCheckedGroovyCustomizer( PrecompiledExtensions.PreventColorUsageExtension.class.getName()); try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"); @@ -109,35 +71,6 @@ public void shouldTypeCheckWithExtension() throws Exception { } } - @Test - public void shouldTypeCheckWithMultipleExtensionDeprecated() throws Exception { - // with no type checking extension this should pass - final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider(); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) { - assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red")); - assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count")); - } - - final TypeCheckedCustomizerProvider providerWithExtension = new TypeCheckedCustomizerProvider( - PrecompiledExtensions.PreventColorUsageExtension.class.getName() + - "," + PrecompiledExtensions.PreventCountDownLatchUsageExtension.class.getName()); - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { - scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass()); - assertThat(se.getMessage(), containsString("Method call is not allowed!")); - } - - try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) { - scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"); - fail("Should have failed type checking"); - } catch (ScriptException se) { - assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass()); - assertThat(se.getMessage(), containsString("Method call is not allowed!")); - } - } - @Test public void shouldTypeCheckWithMultipleExtension() throws Exception { // with no type checking extension this should pass diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java index f795fa76167..4cdf15820b1 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyCompilerGremlinPluginTest.java @@ -18,12 +18,6 @@ */ package org.apache.tinkerpop.gremlin.groovy.jsr223; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ConfigurationCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.InterpreterModeCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider; import org.apache.tinkerpop.gremlin.jsr223.Customizer; import org.codehaus.groovy.control.CompilerConfiguration; import org.junit.Test; diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java deleted file mode 100644 index f3c96f9e050..00000000000 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java +++ /dev/null @@ -1,85 +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.groovy.plugin; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * @author Nghia Tran (https://github.com/n-tran) - */ -public class ArtifactTest { - @Test - public void shouldBeEqualIfSame() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final Artifact b = a; - - assertThat(a.equals(b), is(true)); - } - - @Test - public void shouldNotBeEqualIfArgumentIsNull() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final Artifact b = null; - - assertThat(a.equals(b), is(false)); - } - - @Test - public void shouldNotBeEqualIfArgumentIsNotAnArtifact() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final String b = " "; - - assertThat(a.equals(b), is(false)); - } - - @Test - public void shouldNotBeEqualIfTheGroupIsNotEqual() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final Artifact b = new Artifact("com.apacheTest.tinkerpop2","tinkergraph-gremlin","3.0.0"); - - assertThat(a.equals(b), is(false)); - } - - @Test - public void shouldNotBeEqualIfTheArtifactIsNotEqual() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-artifact","3.0.0"); - - assertThat(a.equals(b), is(false)); - } - - @Test - public void shouldNotBeEqualIfTheVersionIsNotEqual() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","4.0.0"); - - assertThat(a.equals(b), is(false)); - } - - @Test - public void shouldBeEqual() { - final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0"); - - assertThat(a.equals(b), is(true)); - } -} diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java index 517ce8f68e2..4f1c9007f54 100644 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java +++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java @@ -22,7 +22,6 @@ import java.io.File; import org.apache.commons.io.FileUtils; import org.apache.tinkerpop.gremlin.TestHelper; -import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact; import org.junit.AfterClass; import org.junit.Test; import static org.junit.Assert.assertFalse; diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java deleted file mode 100644 index 0ea9b2b78c7..00000000000 --- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/plugin/dsl/credential/CredentialGraphTest.java +++ /dev/null @@ -1,118 +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.plugin.dsl.credential; - -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; -import org.hamcrest.MatcherAssert; -import org.junit.Test; - -import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph.credentials; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class CredentialGraphTest { - - @Test - public void shouldCreateUser() { - final Graph graph = TinkerGraph.open(); - final Vertex v = credentials(graph).createUser("stephen", "secret"); - assertEquals("stephen", v.value("username")); - assertEquals("user", v.label()); - assertNotEquals("secret", v.value("password")); // hashed to something - assertThat(v.value("password").toString().length(), greaterThan(0)); - } - - @Test - public void shouldRemoveUser() { - final Graph graph = TinkerGraph.open(); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - credentials(graph).createUser("stephen", "secret"); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - - assertEquals(1, credentials(graph).removeUser("stephen")); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - } - - @Test - public void shouldNotRemoveUser() { - final Graph graph = TinkerGraph.open(); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - credentials(graph).createUser("stephen", "secret"); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - - assertEquals(0, credentials(graph).removeUser("stephanie")); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - } - - @Test - public void shouldFindUser() { - final Graph graph = TinkerGraph.open(); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - credentials(graph).createUser("marko", "secret"); - final Vertex stephen = credentials(graph).createUser("stephen", "secret"); - credentials(graph).createUser("daniel", "secret"); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - - assertEquals(stephen, credentials(graph).findUser("stephen")); - } - - @Test - public void shouldNotFindUser() { - final Graph graph = TinkerGraph.open(); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - credentials(graph).createUser("marko", "secret"); - credentials(graph).createUser("stephen", "secret"); - credentials(graph).createUser("daniel", "secret"); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - - assertNull(credentials(graph).findUser("stephanie")); - } - - @Test - public void shouldCountUsers() { - final Graph graph = TinkerGraph.open(); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - credentials(graph).createUser("marko", "secret"); - credentials(graph).createUser("stephen", "secret"); - credentials(graph).createUser("daniel", "secret"); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - - assertEquals(3, credentials(graph).countUsers()); - } - - @Test(expected = IllegalStateException.class) - public void shouldThrowIfFindingMultipleUsers() { - final Graph graph = TinkerGraph.open(); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(false)); - credentials(graph).createUser("stephen", "secret"); - credentials(graph).createUser("stephen", "secret"); - MatcherAssert.assertThat(graph.vertices().hasNext(), is(true)); - - assertNull(credentials(graph).findUser("stephen")); - } -} diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java index b87092e1f89..53aa1fb68ff 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java @@ -203,15 +203,6 @@ public Settings() { public AuthenticationSettings authentication = new AuthenticationSettings(); - /** - * The list of plugins to enable for the server. Plugins may be available on the classpath, but with this - * configuration it is possible to explicitly include or omit them. - * - * @deprecated As of release 3.2.5, replaced by specific {@link GremlinPlugin} settings on {@link #scriptEngines} - */ - @Deprecated - public List plugins = new ArrayList<>(); - /** * Custom settings for {@link OpProcessor} implementations. Implementations are loaded via * {@link ServiceLoader} but custom configurations can be supplied through this configuration. diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java index 10c3531a7f8..c3b1f87294e 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java @@ -35,8 +35,8 @@ import java.util.HashMap; import java.util.Map; -import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphTokens.PROPERTY_PASSWORD; -import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphTokens.PROPERTY_USERNAME; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_PASSWORD; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_USERNAME; /** * A simple implementation of an {@link Authenticator} that uses a {@link Graph} instance as a credential store. diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthenticationHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthenticationHandler.java index d8cbd5c2fa4..0ff899d703a 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthenticationHandler.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpBasicAuthenticationHandler.java @@ -38,8 +38,8 @@ import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED; import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; -import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphTokens.PROPERTY_PASSWORD; -import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphTokens.PROPERTY_USERNAME; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_PASSWORD; +import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens.PROPERTY_USERNAME; /** * Implements basic HTTP authentication for use with the {@link HttpGremlinEndpointHandler} and HTTP based API calls. diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java index 2b12406cb88..727f02d836a 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/AbstractEvalOpProcessor.java @@ -25,7 +25,7 @@ import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage; import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode; import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor; -import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptTimeoutException; +import org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException; import org.apache.tinkerpop.gremlin.process.traversal.Operator; import org.apache.tinkerpop.gremlin.process.traversal.Order; import org.apache.tinkerpop.gremlin.process.traversal.Pop; @@ -289,11 +289,6 @@ protected void evalOpInternal(final Context context, final Supplier select(final Context ctx) throws OpProcessorException { - final RequestMessage message = ctx.getRequestMessage(); - logger.debug("Selecting processor for RequestMessage {}", message); - - final ThrowingConsumer op; - switch (message.getOp()) { - case Tokens.OPS_VERSION: - op = ControlOps::versionOp; - break; - case Tokens.OPS_IMPORT: - op = validateImportMessage(message).orElse(ControlOps::importOp); - break; - case Tokens.OPS_RESET: - op = ControlOps::resetOp; - break; - case Tokens.OPS_SHOW: - op = validateShowMessage(message).orElse(ControlOps::showOp); - break; - case Tokens.OPS_USE: - op = validateUseMessage(message).orElse(ControlOps::useOp); - break; - case Tokens.OPS_INVALID: - final String msgInvalid = String.format("Message could not be parsed. Check the format of the request. [%s]", message); - throw new OpProcessorException(msgInvalid, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_MALFORMED_REQUEST).statusMessage(msgInvalid).create()); - default: - final String msgDefault = String.format("Message with op code [%s] is not recognized.", message.getOp()); - throw new OpProcessorException(msgDefault, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_MALFORMED_REQUEST).statusMessage(msgDefault).create()); - } - - controlOpMeter.mark(); - return op; - } - - @Override - public void close() throws Exception { - // do nothing = no resources to release - } - - private static Optional> validateImportMessage(final RequestMessage message) throws OpProcessorException { - final Optional l = message.optionalArgs(Tokens.ARGS_IMPORTS); - if (!l.isPresent()) { - final String msg = String.format("A message with an [%s] op code requires a [%s] argument.", Tokens.OPS_IMPORT, Tokens.ARGS_IMPORTS); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - if (l.orElse(new ArrayList()).size() == 0) { - final String msg = String.format( - "A message with an [%s] op code requires that the [%s] argument has at least one import string specified.", - Tokens.OPS_IMPORT, Tokens.ARGS_IMPORTS); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - return Optional.empty(); - } - - private static Optional> validateShowMessage(final RequestMessage message) throws OpProcessorException { - final Optional infoType = message.optionalArgs(Tokens.ARGS_INFO_TYPE); - if (!infoType.isPresent()) { - final String msg = String.format("A message with an [%s] op code requires a [%s] argument.", - Tokens.OPS_SHOW, Tokens.ARGS_INFO_TYPE); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - if (!Tokens.INFO_TYPES.contains(infoType.get())) { - final String msg = String.format("A message with an [%s] op code requires a [%s] argument with one of the following values [%s].", - Tokens.OPS_SHOW, Tokens.ARGS_INFO_TYPE, Tokens.INFO_TYPES); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - - return Optional.empty(); - - } - - private static Optional> validateUseMessage(final RequestMessage message) throws OpProcessorException { - final Optional l = message.optionalArgs(Tokens.ARGS_COORDINATES); - if (!l.isPresent()) { - final String msg = String.format("A message with an [%s] op code requires a [%s] argument.", - Tokens.OPS_USE, Tokens.ARGS_COORDINATES); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - final List coordinates = l.orElse(new ArrayList()); - if (coordinates.size() == 0) { - final String msg = String.format( - "A message with an [%s] op code requires that the [%s] argument has at least one set of valid maven coordinates specified.", - Tokens.OPS_USE, Tokens.ARGS_COORDINATES); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - if (!coordinates.stream().allMatch(ControlOpProcessor::validateCoordinates)) { - final String msg = String.format( - "A message with an [%s] op code requires that all [%s] specified are valid maven coordinates with a group, artifact, and version.", - Tokens.OPS_USE, Tokens.ARGS_COORDINATES); - throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create()); - } - - return Optional.empty(); - } - - private static boolean validateCoordinates(final Object coordinates) { - if (!(coordinates instanceof Map)) - return false; - - final Map m = (Map) coordinates; - return m.containsKey(Tokens.ARGS_COORDINATES_GROUP) - && m.containsKey(Tokens.ARGS_COORDINATES_ARTIFACT) - && m.containsKey(Tokens.ARGS_COORDINATES_VERSION); - } -} \ No newline at end of file diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/control/ControlOps.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/control/ControlOps.java deleted file mode 100644 index be8955288e0..00000000000 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/control/ControlOps.java +++ /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.server.op.control; - -import io.netty.channel.ChannelHandlerContext; -import org.apache.tinkerpop.gremlin.driver.Tokens; -import org.apache.tinkerpop.gremlin.driver.message.RequestMessage; -import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage; -import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode; -import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor; -import org.apache.tinkerpop.gremlin.groovy.engine.ScriptEngines; -import org.apache.tinkerpop.gremlin.server.Context; -import org.apache.tinkerpop.gremlin.util.Gremlin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -/** - * @author Stephen Mallette (http://stephen.genoprime.com) - * @deprecated As for release 3.2.2, not replaced as this feature was never really published as official. - */ -@Deprecated -class ControlOps { - private static final Logger logger = LoggerFactory.getLogger(ControlOps.class); - - public static void versionOp(final Context context) { - final ChannelHandlerContext ctx = context.getChannelHandlerContext(); - final RequestMessage msg = context.getRequestMessage(); - context.getChannelHandlerContext().writeAndFlush(ResponseMessage.build(msg).code(ResponseStatusCode.SUCCESS).result(Gremlin.version()), ctx.voidPromise()); - } - - /** - * Modify the imports on the {@code ScriptEngine}. - */ - public static void importOp(final Context context) { - final RequestMessage msg = context.getRequestMessage(); - final List l = (List) msg.getArgs().get(Tokens.ARGS_IMPORTS); - context.getGremlinExecutor().getScriptEngines().addImports(new HashSet<>(l)); - } - - /** - * List the dependencies, imports, or variables in the {@code ScriptEngine}. - */ - public static void showOp(final Context context) { - final ChannelHandlerContext ctx = context.getChannelHandlerContext(); - final RequestMessage msg = context.getRequestMessage(); - final String infoType = msg.optionalArgs(Tokens.ARGS_INFO_TYPE).get(); - final GremlinExecutor executor = context.getGremlinExecutor(); - final ScriptEngines scriptEngines = executor.getScriptEngines(); - - final Object infoToShow; - if (infoType.equals(Tokens.ARGS_INFO_TYPE_DEPDENENCIES)) - infoToShow = scriptEngines.dependencies(); - else if (infoType.equals(Tokens.ARGS_INFO_TYPE_IMPORTS)) - infoToShow = scriptEngines.imports(); - else { - // this shouldn't happen if validations are working properly. will bomb and log as error to server logs - // thus killing the connection - throw new RuntimeException(String.format("Validation for the show operation is not properly checking the %s", Tokens.ARGS_INFO_TYPE)); - } - - try { - context.getChannelHandlerContext().writeAndFlush(ResponseMessage.build(msg).code(ResponseStatusCode.SUCCESS).result(infoToShow).create(), ctx.voidPromise()); - } catch (Exception ex) { - logger.warn("The result [{}] in the request {} could not be serialized and returned.", - infoToShow, context.getRequestMessage(), ex); - } - } - - /** - * Resets the {@code ScriptEngine} thus forcing a reload of scripts and classes. - */ - public static void resetOp(final Context context) { - final ChannelHandlerContext ctx = context.getChannelHandlerContext(); - final RequestMessage msg = context.getRequestMessage(); - context.getGremlinExecutor().getScriptEngines().reset(); - context.getChannelHandlerContext().writeAndFlush(ResponseMessage.build(msg).code(ResponseStatusCode.SUCCESS).create(), ctx.voidPromise()); - } - - /** - * Pull in maven based dependencies and load Gremlin plugins. - */ - public static void useOp(final Context context) { - final ChannelHandlerContext ctx = context.getChannelHandlerContext(); - final RequestMessage msg = context.getRequestMessage(); - final List> usings = (List>) msg.getArgs().get(Tokens.ARGS_COORDINATES); - usings.forEach(c -> { - final String group = c.get(Tokens.ARGS_COORDINATES_GROUP); - final String artifact = c.get(Tokens.ARGS_COORDINATES_ARTIFACT); - final String version = c.get(Tokens.ARGS_COORDINATES_VERSION); - logger.info("Loading plugin [group={},artifact={},version={}]", group, artifact, version); - context.getGremlinExecutor().getScriptEngines().use(group, artifact, version); - - final Map coords = new HashMap() {{ - put("group", group); - put("artifact", artifact); - put("version", version); - }}; - - context.getChannelHandlerContext().writeAndFlush(ResponseMessage.build(msg).code(ResponseStatusCode.SUCCESS).result(coords).create(), ctx.voidPromise()); - }); - } -} diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java index 9b16a3b4caa..62a08cbda00 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java @@ -22,7 +22,6 @@ import org.apache.tinkerpop.gremlin.server.Context; import org.apache.tinkerpop.gremlin.server.GraphManager; import org.apache.tinkerpop.gremlin.server.Settings; -import org.apache.tinkerpop.gremlin.server.util.LifeCycleHook; import org.apache.tinkerpop.gremlin.server.util.ThreadFactoryUtil; import org.apache.tinkerpop.gremlin.structure.Graph; import org.slf4j.Logger; @@ -30,7 +29,6 @@ import javax.script.Bindings; import javax.script.SimpleBindings; -import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -222,20 +220,13 @@ private GremlinExecutor.Builder initializeGremlinExecutor() { this.bindings.clear(); this.bindings.putAll(b); }) - .enabledPlugins(new HashSet<>(settings.plugins)) .globalBindings(graphManager.getAsBindings()) .executorService(executor) .scheduledExecutorService(scheduledExecutorService); settings.scriptEngines.forEach((k, v) -> { - // use plugins if they are present and the old approach if not - if (v.plugins.isEmpty()) { - // make sure that server related classes are available at init - ultimately this body of code will be - // deleted when deprecation is removed - v.imports.add(LifeCycleHook.class.getCanonicalName()); - v.imports.add(LifeCycleHook.Context.class.getCanonicalName()); - gremlinExecutorBuilder.addEngineSettings(k, v.imports, v.staticImports, v.scripts, v.config); - } else { + // use plugins if they are present + if (!v.plugins.isEmpty()) { // make sure that server related classes are available at init - new approach. the LifeCycleHook stuff // will be added explicitly via configuration using GremlinServerGremlinModule in the yaml gremlinExecutorBuilder.addPlugins(k, v.plugins); diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java index c5a05e4eb40..cefa0455c82 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java @@ -28,7 +28,6 @@ import org.apache.tinkerpop.gremlin.driver.message.RequestMessage; import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage; import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode; -import org.apache.tinkerpop.gremlin.groovy.engine.ScriptEngines; import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator; import org.apache.tinkerpop.gremlin.process.traversal.Bytecode; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java index 03317d340f4..b5e46fc3567 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.gremlin.server.util; -import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact; +import org.apache.tinkerpop.gremlin.groovy.util.Artifact; import org.apache.tinkerpop.gremlin.groovy.util.DependencyGrabber; import groovy.lang.GroovyClassLoader; diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java index b9b728058f5..116d627fc00 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java @@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -121,20 +120,13 @@ public ServerGremlinExecutor(final Settings settings, final ExecutorService grem .afterFailure((b, e) -> this.graphManager.rollbackAll()) .beforeEval(b -> this.graphManager.rollbackAll()) .afterTimeout(b -> this.graphManager.rollbackAll()) - .enabledPlugins(new HashSet<>(settings.plugins)) .globalBindings(this.graphManager.getAsBindings()) .executorService(this.gremlinExecutorService) .scheduledExecutorService(this.scheduledExecutorService); settings.scriptEngines.forEach((k, v) -> { - // use plugins if they are present and the old approach if not - if (v.plugins.isEmpty()) { - // make sure that server related classes are available at init - ultimately this body of code will be - // deleted when deprecation is removed - v.imports.add(LifeCycleHook.class.getCanonicalName()); - v.imports.add(LifeCycleHook.Context.class.getCanonicalName()); - gremlinExecutorBuilder.addEngineSettings(k, v.imports, v.staticImports, v.scripts, v.config); - } else { + // use plugins if they are present + if (!v.plugins.isEmpty()) { // make sure that server related classes are available at init - new approach. the LifeCycleHook stuff // will be added explicitly via configuration using GremlinServerGremlinModule in the yaml gremlinExecutorBuilder.addPlugins(k, v.plugins); diff --git a/gremlin-server/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.server.OpProcessor b/gremlin-server/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.server.OpProcessor index 315dd7b9742..4f1bf104553 100644 --- a/gremlin-server/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.server.OpProcessor +++ b/gremlin-server/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.server.OpProcessor @@ -1,4 +1,3 @@ org.apache.tinkerpop.gremlin.server.op.standard.StandardOpProcessor -org.apache.tinkerpop.gremlin.server.op.control.ControlOpProcessor org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor \ No newline at end of file diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java index 3f7009f9e37..2bce560583b 100644 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java +++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGremlinSuite.java @@ -20,7 +20,6 @@ package org.apache.tinkerpop.gremlin.hadoop; import org.apache.tinkerpop.gremlin.AbstractGremlinSuite; -import org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPluginCheck; import org.apache.tinkerpop.gremlin.hadoop.structure.io.FileSystemStorageCheck; import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine; import org.junit.runners.model.InitializationError; @@ -31,6 +30,6 @@ */ public class HadoopGremlinSuite extends AbstractGremlinSuite { public HadoopGremlinSuite(final Class klass, final RunnerBuilder builder) throws InitializationError { - super(klass, builder, new Class[]{HadoopGremlinPluginCheck.class, FileSystemStorageCheck.class}, new Class[]{HadoopGremlinPluginCheck.class, FileSystemStorageCheck.class}, true, TraversalEngine.Type.COMPUTER); + super(klass, builder, new Class[]{FileSystemStorageCheck.class}, new Class[]{FileSystemStorageCheck.class}, true, TraversalEngine.Type.COMPUTER); } } diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java deleted file mode 100644 index baa96da05d6..00000000000 --- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/jsr223/HadoopGremlinPluginCheck.java +++ /dev/null @@ -1,397 +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.hadoop.jsr223; - -import org.apache.tinkerpop.gremlin.AbstractGremlinTest; -import org.apache.tinkerpop.gremlin.LoadGraphWith; -import org.apache.tinkerpop.gremlin.TestHelper; -import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader; -import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; -import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor; -import org.apache.tinkerpop.gremlin.hadoop.Constants; -import org.apache.tinkerpop.gremlin.hadoop.HadoopGremlinSuite; -import org.apache.tinkerpop.gremlin.process.traversal.Traversal; -import org.apache.tinkerpop.gremlin.util.Gremlin; -import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; -import org.codehaus.groovy.tools.shell.Groovysh; -import org.codehaus.groovy.tools.shell.IO; -import org.junit.Before; -import org.junit.Test; - -import javax.script.ScriptException; -import javax.tools.JavaCompiler; -import javax.tools.SimpleJavaFileObject; -import javax.tools.ToolProvider; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * This is an test that is mean to be used in the context of the {@link HadoopGremlinSuite} and shouldn't be - * executed on its own. - * - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class HadoopGremlinPluginCheck extends AbstractGremlinTest { - // *********************** - // This test will be removed as the old "plugin" infrastructure was deprecated in 3.2.4. need to rework the - // tests a bi for this to see what the model is for validating the jsr223 plugins. note that the code from - // gremlin-groovy-test, specifically TestableConsolePluginAcceptor, has been copied to the bottom of this - // file for reference - // *********************** - @Test - public void nothing() { - // this is just to stop junit failures until this test gets figured out - } - - /** - @Before - public void setupTest() { - try { - this.console = new TestableConsolePluginAcceptor(); - final HadoopGremlinPlugin plugin = new HadoopGremlinPlugin(); - plugin.pluginTo(this.console); - this.remote = (HadoopRemoteAcceptor) plugin.remoteAcceptor().get(); - } catch (final Exception e) { - throw new IllegalStateException(e.getMessage(), e); - } - } - - /////////////////// - - private HadoopRemoteAcceptor remote; - private TestableConsolePluginAcceptor console; - - @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) - public void shouldSupportRemoteTraversal() throws Exception { - this.console.addBinding("graph", this.graph); - this.console.addBinding("g", this.g); - this.remote.connect(Arrays.asList("graph", "g")); - // - Traversal traversal = (Traversal) this.remote.submit(Arrays.asList("g.V().count()")); - assertEquals(6L, traversal.next()); - assertFalse(traversal.hasNext()); - assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT)); - } - - @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) - public void shouldSupportRemoteSugarTraversal() throws Exception { - SugarTestHelper.clearRegistry(this.graphProvider); - this.console.addBinding("graph", this.graph); - this.console.addBinding("g", this.g); - // - this.remote.connect(Arrays.asList("graph", "g")); - try { - this.remote.submit(Arrays.asList("g.V.name.map{it.length()}.sum")); - fail("Should not allow sugar usage"); - } catch (final Exception e) { - // this is good - } - // - this.remote.configure(Arrays.asList("useSugar", "true")); - this.remote.connect(Arrays.asList("graph", "g")); - Traversal traversal = (Traversal) this.remote.submit(Arrays.asList("g.V.name.map{it.length()}.sum")); - assertEquals(28l, traversal.next()); - assertFalse(traversal.hasNext()); - assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT)); - } - - @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) - public void shouldSupportRemoteGroupTraversal() throws Exception { - SugarTestHelper.clearRegistry(this.graphProvider); - GremlinLoader.load(); - this.console.addBinding("graph", this.graph); - this.console.addBinding("g", this.g); - this.remote.connect(Arrays.asList("graph")); - // - this.remote.connect(Arrays.asList("graph", "g")); - Traversal>> traversal = (Traversal>>) this.remote.submit(Arrays.asList("g.V().out().group().by{it.value('name')[1]}.by('name')")); - Map> map = traversal.next(); - assertEquals(3, map.size()); - assertEquals(1, map.get("a").size()); - assertEquals("vadas", map.get("a").get(0)); - assertEquals(1, map.get("i").size()); - assertEquals("ripple", map.get("i").get(0)); - assertEquals(4, map.get("o").size()); - assertTrue(map.get("o").contains("josh")); - assertTrue(map.get("o").contains("lop")); - assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT)); - // - traversal = (Traversal>>) this.remote.submit(Arrays.asList("g.V().out().group().by(label).by{it.value('name')[1]}")); - map = traversal.next(); - assertEquals(2, map.size()); - assertEquals(4, map.get("software").size()); - assertTrue(map.get("software").contains("o")); - assertTrue(map.get("software").contains("i")); - assertEquals(2, map.get("person").size()); - assertTrue(map.get("person").contains("o")); - assertTrue(map.get("person").contains("a")); - assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT)); - } - - - @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) - public void shouldSupportHDFSMethods() throws Exception { - List ls = (List) this.console.eval("hdfs.ls()"); - for (final String line : ls) { - assertTrue(line.startsWith("-") || line.startsWith("r") || line.startsWith("w") || line.startsWith("x")); - assertEquals(" ", line.substring(9, 10)); - } - ls = (List) this.console.eval("fs.ls()"); - for (final String line : ls) { - assertTrue(line.startsWith("-") || line.startsWith("r") || line.startsWith("w") || line.startsWith("x")); - assertEquals(" ", line.substring(9, 10)); - } - } - - @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) - public void shouldGracefullyHandleBadGremlinHadoopLibs() throws Exception { - System.setProperty(Constants.HADOOP_GREMLIN_LIBS, TestHelper.makeTestDataDirectory(HadoopGremlinPluginCheck.class, "shouldGracefullyHandleBadGremlinHadoopLibs")); - this.graph.configuration().setProperty(Constants.GREMLIN_HADOOP_JARS_IN_DISTRIBUTED_CACHE, true); - this.console.addBinding("graph", this.graph); - this.console.addBinding("g", this.g); - this.remote.connect(Arrays.asList("graph", "g")); - Traversal traversal = (Traversal) this.remote.submit(Arrays.asList("g.V()")); - assertEquals(6, IteratorUtils.count(traversal)); - assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT)); - } - - @Test - @LoadGraphWith(LoadGraphWith.GraphData.MODERN) - public void shouldSupportVariousFileSystemsInGremlinHadoopLibs() throws Exception { - - // The whole point of this test is to verify that HADOOP_GREMLIN_LIBS may contain paths with or without - // a file system scheme prefix and that either path is properly handled. If all jar files, that were specified - // in HADOOP_GREMLIN_LIBS, are found in the GraphComputers temporary directory after using the GraphComputer - // (by submitting a traversal), the test is considered to be successful. - // - // The traversal will likely never fail, since both - Spark and Giraph - run in the same JVM during tests. This - // is unfortunate as it doesn't allow us to verify that GraphComputers load jars properly in a distributed - // environment. The test would fail in a distributed environment, IF loading the jars specified in - // HADOOP_GREMLIN_LIBS wouldn't work. That is because we generate new jar files on the fly that are definitely - // not part of any existing directory or the current classpath. - - final String testDataDirectory = TestHelper.makeTestDataDirectory(HadoopGremlinPluginCheck.class, "shouldHandleLocalGremlinHadoopLibs"); - final File jarFile1 = createJarFile(testDataDirectory + File.separator + "1", "Greeter1"); - final File jarFile2 = createJarFile(testDataDirectory + File.separator + "2", "Greeter2"); - final String graphComputerJarTargetBasePath = System.getProperty("java.io.tmpdir") + File.separator + - "hadoop-gremlin-" + Gremlin.version() + "-libs" + File.separator; - final File graphComputerJarTargetPath1 = new File(graphComputerJarTargetBasePath + "1" + File.separator + "Greeter1.jar"); - final File graphComputerJarTargetPath2 = new File(graphComputerJarTargetBasePath + "2" + File.separator + "Greeter2.jar"); - - for (final boolean withScheme : Arrays.asList(false, true)) { - - Stream hadoopGremlinLibs = Arrays.asList(jarFile1, jarFile2).stream().map(f -> f.getParentFile().getAbsolutePath()); - if (withScheme) { - hadoopGremlinLibs = hadoopGremlinLibs.map(path -> "file://" + path); - } - System.setProperty(Constants.HADOOP_GREMLIN_LIBS, String.join(File.pathSeparator, hadoopGremlinLibs.collect(Collectors.toList()))); - - this.graph.configuration().setProperty(Constants.GREMLIN_HADOOP_JARS_IN_DISTRIBUTED_CACHE, true); - this.console.addBinding("graph", this.graph); - this.console.addBinding("g", this.g); - this.remote.connect(Arrays.asList("graph", "g")); - - Traversal traversal = (Traversal) this.remote.submit(Arrays.asList( - "ClassLoader.getSystemClassLoader().addURL('" + jarFile1.toURI().toURL() + "'.toURL());", - "ClassLoader.getSystemClassLoader().addURL('" + jarFile2.toURI().toURL() + "'.toURL());", - "g.V().choose(hasLabel('person'), " + - "values('name').map {Class.forName('Greeter1').hello(it.get())}, " + - "values('name').map {Class.forName('Greeter2').hello(it.get())})")); - - final List expectedMessages = Arrays.asList("marko", "josh", "peter", "vadas").stream(). - map(name -> "Greeter1 says: Hello " + name + "!").collect(Collectors.toList()); - - expectedMessages.addAll(Arrays.asList("lop", "ripple").stream(). - map(name -> "Greeter2 says: Hello " + name + "!").collect(Collectors.toList())); - - while (traversal.hasNext()) { - final String message = (String) traversal.next(); - assertTrue(expectedMessages.remove(message)); - } - - assertEquals(0, expectedMessages.size()); - } - - assertTrue(graphComputerJarTargetPath1.exists()); - assertTrue(graphComputerJarTargetPath2.exists()); - - assert graphComputerJarTargetPath1.delete(); - assert graphComputerJarTargetPath2.delete(); - } - - private File createJarFile(final String directory, final String className) throws IOException { - - new File(directory).mkdirs(); - - final File classFile = new File(directory + File.separator + className + ".class"); - final File jarFile = new File(directory + File.separator + className + ".jar"); - - jarFile.deleteOnExit(); - - final JavaStringObject source = new JavaStringObject(className, - "public class " + className + " {\n" + - " public static String hello(final String name) {\n" + - " return \"" + className + " says: Hello \" + name + \"!\";\n" + - " }\n" + - "}"); - - final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - final List options = Arrays.asList( - "-d", classFile.getParentFile().getAbsolutePath() - ); - assert compiler.getTask(null, null, null, options, null, Collections.singletonList(source)).call(); - - final Manifest manifest = new Manifest(); - manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); - - try (final JarOutputStream target = new JarOutputStream(new FileOutputStream(jarFile), manifest)) { - final JarEntry entry = new JarEntry(classFile.getName()); - entry.setTime(classFile.lastModified()); - target.putNextEntry(entry); - try (final FileInputStream fis = new FileInputStream(classFile); - final BufferedInputStream in = new BufferedInputStream(fis)) { - final byte buffer[] = new byte[1024]; - while (true) { - final int count = in.read(buffer); - if (count < 0) break; - target.write(buffer, 0, count); - } - } - target.closeEntry(); - } - - assert classFile.delete(); - - return jarFile; - } - - private static class JavaStringObject extends SimpleJavaFileObject { - - private final String code; - - JavaStringObject(final String className, final String code) { - super(URI.create("string:///" + className.replace(".", "/") + Kind.SOURCE.extension), Kind.SOURCE); - this.code = code; - } - - @Override - public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { - return code; - } - } - **/ - - - ///////////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////// - - -//package org.apache.tinkerpop.gremlin.groovy.util; -// -//import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin; -//import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor; -//import org.codehaus.groovy.tools.shell.Groovysh; -//import org.codehaus.groovy.tools.shell.IO; -// -//import javax.script.ScriptException; -//import java.io.IOException; -//import java.io.OutputStream; -//import java.util.Collections; -//import java.util.HashMap; -//import java.util.Map; -//import java.util.Set; -// -// /** -// * @author Marko A. Rodriguez (http://markorodriguez.com) -// */ -// public class TestableConsolePluginAcceptor implements PluginAcceptor { -// -// public static final String ENVIRONMENT_NAME = "console"; -// public static final String ENVIRONMENT_SHELL = "ConsolePluginAcceptor.shell"; -// public static final String ENVIRONMENT_IO = "ConsolePluginAcceptor.io"; -// -// private Groovysh shell = new Groovysh(new IO(System.in, new OutputStream() { -// @Override -// public void write(int b) throws IOException { -// -// } -// }, System.err)); -// -// @Override -// public void addImports(final Set importStatements) { -// importStatements.forEach(this.shell::execute); -// } -// -// @Override -// public void addBinding(final String key, final Object val) { -// this.shell.getInterp().getContext().setVariable(key, val); -// } -// -// @Override -// public Map getBindings() { -// return Collections.unmodifiableMap(this.shell.getInterp().getContext().getVariables()); -// } -// -// @Override -// public Object eval(final String script) throws ScriptException { -// return this.shell.execute(script); -// } -// -// @Override -// public Map environment() { -// final Map env = new HashMap<>(); -// env.put(GremlinPlugin.ENVIRONMENT, ENVIRONMENT_NAME); -// env.put(ENVIRONMENT_IO, this.shell.getIo()); -// env.put(ENVIRONMENT_SHELL, this.shell); -// return env; -// } -// -// } -} diff --git a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java index 74e1207f421..bed2ace6e60 100644 --- a/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java +++ b/spark-gremlin/src/test/java/org/apache/tinkerpop/gremlin/spark/process/computer/SparkHadoopGraphProvider.java @@ -24,7 +24,6 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith; import org.apache.tinkerpop.gremlin.hadoop.Constants; import org.apache.tinkerpop.gremlin.hadoop.HadoopGraphProvider; -import org.apache.tinkerpop.gremlin.hadoop.jsr223.HadoopGremlinPluginCheck; import org.apache.tinkerpop.gremlin.hadoop.structure.io.FileSystemStorageCheck; import org.apache.tinkerpop.gremlin.hadoop.structure.io.HadoopPools; import org.apache.tinkerpop.gremlin.process.computer.Computer; @@ -82,14 +81,6 @@ public Map getBaseConfiguration(final String graphName, final Cl config.put(RANDOM.nextBoolean() ? Constants.GREMLIN_SPARK_GRAPH_OUTPUT_RDD : Constants.GREMLIN_HADOOP_GRAPH_WRITER, PersistedOutputRDD.class.getCanonicalName()); } - // sugar plugin causes meta-method issues with a persisted context - if (test.equals(HadoopGremlinPluginCheck.class)) { - Spark.close(); - HadoopPools.close(); - KryoShimServiceLoader.close(); - SugarTestHelper.clearRegistry(); - } - config.put(Constants.GREMLIN_HADOOP_DEFAULT_GRAPH_COMPUTER, SparkGraphComputer.class.getCanonicalName()); config.put(SparkLauncher.SPARK_MASTER, "local[4]"); config.put(Constants.SPARK_SERIALIZER, KryoSerializer.class.getCanonicalName()); From 9b87acdbcc392e1fbb366eaf251616616594c59e Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 18:51:34 -0500 Subject: [PATCH 26/34] TINKERPOP-1612 Re-wrote RemoteAcceptor stuff for revised model. --- docs/src/dev/provider/index.asciidoc | 13 ++++++------- .../gremlin/console/jsr223/DriverGremlinPlugin.java | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc index 868a6fa11c8..2dd084365d0 100644 --- a/docs/src/dev/provider/index.asciidoc +++ b/docs/src/dev/provider/index.asciidoc @@ -1205,12 +1205,11 @@ find it. [source,java] ---- -include::{basedir}/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/RemoteAcceptor.java[] +include::{basedir}/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/RemoteAcceptor.java[] ---- -The `RemoteAcceptor` implementation ties to a `GremlinPlugin` and will only be executed when in use with the Gremlin -Console plugin host. Simply instantiate and return a `RemoteAcceptor` in the `GremlinPlugin.remoteAcceptor()` method -of the plugin implementation. Generally speaking, each call to `remoteAcceptor()` should produce a new instance of -a `RemoteAcceptor`. It will likely be necessary that you provide context from the `GremlinPlugin` to the -`RemoteAcceptor` plugin. For example, the `RemoteAcceptor` implementation might require an instance of `Groovysh` -to provide a way to dynamically evaluate a script provided to it so that it can process the results in a different way. +The `RemoteAcceptor` can be bound to a `GremlinPlugin` by adding a `ConsoleCustomizer` implementation to the list of +`Customizer` instances that are returned from the `GremlinPlugin`. The `ConsoleCustomizer` will only be executed when +in use with the Gremlin Console plugin host. Simply instantiate and return a `RemoteAcceptor` in the +`ConsoleCustomizer.getRemoteAcceptor(GremlinShellEnvironment)` method. Generally speaking, each call to +`getRemoteAcceptor(GremlinShellEnvironment)` should produce a new instance of a `RemoteAcceptor`. diff --git a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java index fb78ee92eeb..a47700d2744 100644 --- a/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java +++ b/gremlin-console/src/main/java/org/apache/tinkerpop/gremlin/console/jsr223/DriverGremlinPlugin.java @@ -52,6 +52,7 @@ import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer; import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer; import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment; +import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor; /** * @author Stephen Mallette (http://stephen.genoprime.com) @@ -97,7 +98,7 @@ public DriverGremlinPlugin() { private static class DriverConsoleCustomizer implements ConsoleCustomizer { @Override - public org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment environment) { + public RemoteAcceptor getRemoteAcceptor(final GremlinShellEnvironment environment) { return new DriverRemoteAcceptor(environment); } } From b4472c6b0403b177b37c513bf2a547b3be632d2b Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 18:56:48 -0500 Subject: [PATCH 27/34] TINKERPOP-1612 Renamed server-side plugin to not match the driver The console already holds the "tinkerpop.server" plugin for the driver and remoting. Had to name this one something else. --- .../gremlin/server/jsr223/GremlinServerGremlinPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java index a08aa76c943..c34c7a45991 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java @@ -29,7 +29,7 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public final class GremlinServerGremlinPlugin extends AbstractGremlinPlugin { - private static final String MODULE_NAME = "tinkerpop.server"; + private static final String MODULE_NAME = "tinkerpop.server-side"; private static final GremlinServerGremlinPlugin instance = new GremlinServerGremlinPlugin(); private GremlinServerGremlinPlugin() { From 29ed887e63b93f151104f4a270a5c369b015ce4a Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Mon, 27 Feb 2017 19:20:42 -0500 Subject: [PATCH 28/34] TINKERPOP-1612 Re-write server docs given new plugin model. --- .../reference/gremlin-applications.asciidoc | 90 +++++++++---------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc index e620372ff37..f3db936470e 100644 --- a/docs/src/reference/gremlin-applications.asciidoc +++ b/docs/src/reference/gremlin-applications.asciidoc @@ -406,12 +406,9 @@ $ bin/gremlin-server.sh conf/gremlin-server-modern.yaml [INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics [INFO] GraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties]. [INFO] ServerGremlinExecutor - Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-* -[INFO] ScriptEngines - Loaded gremlin-groovy ScriptEngine -[INFO] GremlinExecutor - Initialized gremlin-groovy ScriptEngine with scripts/generate-modern.groovy [INFO] ServerGremlinExecutor - Initialized GremlinExecutor and configured ScriptEngines. [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:0 edges:0], standard] [INFO] OpLoader - Adding the standard OpProcessor. -[INFO] OpLoader - Adding the control OpProcessor. [INFO] OpLoader - Adding the session OpProcessor. [INFO] OpLoader - Adding the traversal OpProcessor. [INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms @@ -420,7 +417,11 @@ $ bin/gremlin-server.sh conf/gremlin-server-modern.yaml [INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 [INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo-lite with org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0 [INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo-stringd with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 -[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1. +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v2.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0 +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0 +[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0 +[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 4 and boss thread pool of 1. [INFO] GremlinServer$1 - Channel started at port 8182. ---- @@ -1141,7 +1142,6 @@ The following table describes the various YAML configuration options that Gremli |metrics.jmxReporter.enabled |Turns on JMX reporting of metrics. |false |metrics.slf4jReporter.enabled |Turns on SLF4j reporting of metrics. |false |metrics.slf4jReporter.interval |Time in milliseconds between reports of metrics to SLF4j. |180000 -|plugins |A list of plugins that should be activated on server startup in the available script engines. It assumes that the plugins are in Gremlin Server's classpath. |_none_ |port |The port to bind the server to. |8182 |processors |A `List` of `Map` settings, where each `Map` represents a `OpProcessor` implementation to use along with its configuration. |_none_ |processors[X].className |The full class name of the `OpProcessor` implementation. |_none_ @@ -1404,7 +1404,7 @@ export JAVA_OPTIONS="$JAVA_OPTIONS -Djava.security.auth.login.config=conf/gremli Protecting Script Execution +++++++++++++++++++++++++++ -It is important to remember that Gremlin Server exposes a `ScriptEngine` instance that allows for remote execution +It is important to remember that Gremlin Server exposes `GremlinScriptEngine` instances that allows for remote execution of arbitrary code on the server. Obviously, this situation can represent a security risk or, more minimally, provide ways for "bad" scripts to be inadvertently executed. A simple example of a "valid" Gremlin script that would cause some problems would be, `while(true) {}`, which would consume a thread in the Gremlin pool indefinitely, thus @@ -1412,30 +1412,33 @@ preventing it from serving other requests. Sending enough of these kinds of scr available threads and Gremlin Server would stop responding. Gremlin Server (more specifically the `GremlinGroovyScriptEngine`) provides methods to protect itself from these -kinds of troublesome scripts. A user can configure the script engine with different `CompilerCustomizerProvider` -implementations. Consider the basic configuration from the Gremlin Server YAML file: +kinds of troublesome scripts. A user can configure the script engine with a `GroovyCompilerGremlinPlugin` +implementation. Consider the basic configuration from the Gremlin Server YAML file: [source,yaml] +---- scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy]}} + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}} +---- -This configuration can be extended to include a `config` key as follows: +This configuration can be expaded to include a the `GroovyCompilerGremlinPlugin`: [source,yaml] +---- scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy], - config: { - compilerCustomizerProviders: { - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000] }}} - -This configuration sets up the script engine with a `CompilerCustomizerProvider` implementation. The -`TimedInterruptCustomizerProvider` injects checks that ensure that loops (like `while`) can only execute for `10000` + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {} + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample-secure.groovy]}, + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {timedInterrupt: 10000}}}} +---- + +This configuration sets up the script engine with to ensure that loops (like `while`) can only execute for `10000` milliseconds. With this configuration in place, a remote execution as follows, now times out rather than consuming the thread continuously: @@ -1445,41 +1448,34 @@ gremlin> :remote connect tinkerpop.server conf/remote.yaml gremlin> :> while(true) { } Execution timed out after 10000 units. Start time: Fri Jul 24 11:04:52 EDT 2015 -There are a number of pre-packaged `CustomizerProvider` implementations: +The `GroovyCompilerGremlinPlugin` has a number of configuration options: [width="100%",cols="3,10a",options="header"] |========================================================= |Customizer |Description -|`CompileStaticCustomizerProvider` |Applies `CompileStatic` annotations to incoming scripts thus removing dynamic dispatch. More information about static compilation can be found in the link:http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation[Groovy Documentation]. It is possible to configure this `CustomizerProvider` by specifying a comma separated list of link:http://docs.groovy-lang.org/latest/html/documentation/#Typecheckingextensions-Workingwithextensions[type checking extensions] that can have the effect of securing calls to various methods. -|`ConfigurationCustomizerProvider` |Allows configuration of the Groovy `CompilerConfiguration` object by taking a `Map` of key/value pairs where the "key" is a property to set on the `CompilerConfiguration`. -|`ThreadInterruptCustomizerProvider` |Injects checks for thread interruption, thus allowing the thread to potentially respect calls to `Thread.interrupt()` -|`TimedInterruptCustomizerProvider` |Injects checks into loops to interrupt them if they exceed the configured timeout in milliseconds. -|`TypeCheckedCustomizerProvider` |Similar to the above mentioned, `CompileStaticCustomizerProvider`, the `TypeCheckedCustomizerProvider` injects `TypeChecked` annotations to incoming scripts. More information on the nature of this annotation can be found in the link:http://docs.groovy-lang.org/latest/html/documentation/#_the_code_typechecked_code_annotation[Groovy Documentation]. It too takes a comma separated list of link:http://docs.groovy-lang.org/latest/html/documentation/#Typecheckingextensions-Workingwithextensions[type checking extensions]. +|`compilation` |Allows for three configurations: `COMPILE_STATIC`, `TYPE_CHECKED` or `NONE` (default). When configured with `COMPILE_STATIC` or `TYPE_CHECKED` it applies `CompileStatic` or `TypeChecked` annotations (respectively) to incoming scripts thus removing dynamic dispatch. More information about static compilation can be found link:http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation[here] and additional information on `TypeChecked` usage can be found link:http://docs.groovy-lang.org/latest/html/documentation/#_the_code_typechecked_code_annotation[here]. +|`compilerConfigurationOptions` |Allows configuration of the Groovy `CompilerConfiguration` object by taking a `Map` of key/value pairs where the "key" is a property to set on the `CompilerConfiguration`. +|`enableThreadInterrupt` |Injects checks for thread interruption, thus allowing the thread to potentially respect calls to `Thread.interrupt()` +|`extensions` | This setting is for use when `compilation` is configured with `COMPILE_STATIC` or `TYPE_CHECKED` and accepts a comma separated list of link:http://docs.groovy-lang.org/latest/html/documentation/#Typecheckingextensions-Workingwithextensions[type checking extensions] that can have the effect of securing calls to various methods. +|`timedInterrupt` |Injects checks into loops to interrupt them if they exceed the configured timeout in milliseconds. |========================================================= +NOTE: Consult the latest link:http://docs.groovy-lang.org/latest/html/documentation/#_typing[Groovy Documentation] +for information on the differences. It is important to understand the impact that these configuration will have on +submitted scripts before enabling this feature. + To provide some basic out-of-the-box protections against troublesome scripts, the following configuration can be used: [source,yaml] +---- scriptEngines: { gremlin-groovy: { - imports: [java.lang.Math], - staticImports: [java.lang.Math.PI], - scripts: [scripts/empty-sample.groovy], - config: { - compilerCustomizerProviders: { - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.ThreadInterruptCustomizerProvider":[], - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000], - "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}} - -NOTE: The above configuration could also use the `TypeCheckedCustomizerProvider` in place of the -`CompileStaticCustomizerProvider`. The differences between `TypeChecked` and `CompileStatic` are beyond the scope of -this documentation. Consult the latest link:http://docs.groovy-lang.org/latest/html/documentation/#_typing[Groovy Documentation] -for information on the differences. It is important to understand the impact that these configuration will have on -submitted scripts before enabling this feature. - -NOTE: The import of classes to the script engine is handled by the `ImportCustomizerProvider`. As the concept of -"imports" is a first-class citizen (i.e. has its own configuration options), it is not recommended that the -`ImportCustomizerProvider` be used as a configuration option to `compilerCustomizerProviders`. + plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {} + org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {enableThreadInterrupt: true, timedInterrupt: 10000, compilation: COMPILE_STATIC, extensions: org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample-secure.groovy]}}}} +---- This configuration uses the `SimpleSandboxExtension`, which blacklists calls to methods on the `System` class, thereby preventing someone from remotely killing the server: @@ -1561,8 +1557,8 @@ The `FileSandboxExtension` provides for a basic configurable security function i sandboxing implementations can be developed by using this white listing model and extending from the `AbstractSandboxExtension`. -A final thought on the topic of `CompilerCustomizerProvider` implementations is that they are not just for -"security" (though they are demonstrated in that capacity here). They can be used for a variety of features that +A final thought on the topic of `GroovyCompilerGremlinPlugin` implementation is that it is not just for +"security" (though is is demonstrated in that capacity here). It can be used for a variety of features that can fine tune the Groovy compilation process. Read more about compilation customization in the link:http://docs.groovy-lang.org/latest/html/documentation/#compilation-customizers[Groovy Documentation]. From 885e14e3f80b3a713285a533eeacbf6901c459c1 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 28 Feb 2017 06:34:25 -0500 Subject: [PATCH 29/34] TINKERPOP-1612 Removed resource file for old plugin system --- .../org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin diff --git a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin deleted file mode 100644 index 79f20cd0b8c..00000000000 --- a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin +++ /dev/null @@ -1,2 +0,0 @@ -org.apache.tinkerpop.gremlin.groovy.plugin.SugarGremlinPlugin -org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphGremlinPlugin \ No newline at end of file From aa468a905597cbfa6248c9f069c239598337b3d5 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 28 Feb 2017 07:54:18 -0500 Subject: [PATCH 30/34] TINKERPOP-1612 Fixed bad reference to neo4j plugin --- gremlin-server/conf/gremlin-server-neo4j.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-server/conf/gremlin-server-neo4j.yaml b/gremlin-server/conf/gremlin-server-neo4j.yaml index 0ca8b9c24d5..d95db9450b6 100644 --- a/gremlin-server/conf/gremlin-server-neo4j.yaml +++ b/gremlin-server/conf/gremlin-server-neo4j.yaml @@ -34,7 +34,7 @@ graphs: { scriptEngines: { gremlin-groovy: { plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, - org.apache.tinkerpop.gremlin.neo4j.jsr223.TinkerGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.neo4j.jsr223.Neo4jGremlinPlugin: {}, org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]}, org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}} serializers: From 2f8c9d84dd60ca3ef624525c98de53f735a1b506 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 28 Feb 2017 07:54:40 -0500 Subject: [PATCH 31/34] TINKERPOP-1612 Renamed gremlin server plugin again No name seems to be really good, but don't want to break the current usage of tinkerpop.server as it pertains to "remote". --- .../gremlin/server/jsr223/GremlinServerGremlinPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java index c34c7a45991..dd7ce9dfdb8 100644 --- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java +++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/jsr223/GremlinServerGremlinPlugin.java @@ -29,7 +29,7 @@ * @author Stephen Mallette (http://stephen.genoprime.com) */ public final class GremlinServerGremlinPlugin extends AbstractGremlinPlugin { - private static final String MODULE_NAME = "tinkerpop.server-side"; + private static final String MODULE_NAME = "tinkerpop.gremlin-server"; private static final GremlinServerGremlinPlugin instance = new GremlinServerGremlinPlugin(); private GremlinServerGremlinPlugin() { From 01b9aa293d54636561512da9d4ae21d2cd3091f7 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 28 Feb 2017 07:55:34 -0500 Subject: [PATCH 32/34] TINKERPOP-1612 More documentation on plugins --- .../reference/gremlin-applications.asciidoc | 54 ++++++++++++++++++- .../reference/implementations-neo4j.asciidoc | 3 +- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc index f3db936470e..74a572eab9d 100644 --- a/docs/src/reference/gremlin-applications.asciidoc +++ b/docs/src/reference/gremlin-applications.asciidoc @@ -2109,15 +2109,65 @@ Gephi plugin configuration parameters as accepted via the `:remote config` comma |visualTraversal |Creates a `TraversalSource` variable in the Console named `vg` which can be used for visualizing traversals. This configuration option takes two parameters. The first is required and is the name of the `Graph` instance variable that will generate the `TraversalSource`. The second parameter is the variable name that the `TraversalSource` should have when referenced in the Console. If left unspecified, this value defaults to `vg`. |vg |========================================================= +NOTE: This plugin is typically only useful to the Gremlin Console and is enabled in the there by default. + +[[giraph-plugin]] +Giraph Plugin +~~~~~~~~~~~~~ + +image:giraph-logo.png[width=100,float=left] The Giraph Plugin installs as part of `giraph-gremlin` and provides +a number of imports and utility functions to the environment within which it is used. Those classes and functions +provide the basis for supporting <> using link:http://giraph.apache.org[Giraph]. +This plugin is defined in greater detail in the <> section and is typically +installed in conjuction with the <>. + +[[graph-plugins]] +Graph Plugins +~~~~~~~~~~~~~ + +This section does not refer to a specific Gremlin Plugin, but a class of them. Graph Plugins are typically created by +graph providers to make it easy to integrate their graph systems into Gremlin Console and Gremlin Server. As TinkerPop +provides two reference `Graph` implementations in <> and <>, +there is also one Gremlin Plugin for each of them. + +The TinkerGraph plugin is installed and activated in the Gremlin Console by default and the sample configurations that +are supplied with the Gremlin Server distribution include the `TinkerGraphGremlinPlugin` as part of the default setup. +If using Neo4j, however, the plugin must be installed manually. Instructions for doing so can be found in the +<> section. + +[[hadoop-plugin]] +Hadoop Plugin +~~~~~~~~~~~~~ + +image:hadoop-logo-notext.png[width=100,float=left] The Hadoop Plugin installs as part of `hadoop-gremlin` and provides +a number of imports and utility functions to the environment within which it is used. Those classes and functions +provide the basis for supporting <> with Gremlin. This plugin is defined in +greater detail in the <> section. + [[server-plugin]] Server Plugin ~~~~~~~~~~~~~ image:gremlin-server.png[width=200,float=left] xref:gremlin-server[Gremlin Server] remotely executes Gremlin scripts that are submitted to it. The Server Plugin provides a way to submit scripts to Gremlin Server for remote -processing. Read more about the plugin and how it works in the Gremlin Server section on xref:connecting-via-console[Connecting via Console]. +processing. Read more about the plugin and how it works in the Gremlin Server section on +<>. + +NOTE: This plugin is typically only useful to the Gremlin Console and is enabled in the there by default. + +The Server Plugin for remoting with the Gremlin Console should not be confused with a plugin of similar name that is +used by the server. `GremlinServerGremlinPlugin` is typically only configured in Gremlin Server and provides a number +of imports that are required for writing <. + +[[spark-plugin]] +Spark Plugin +~~~~~~~~~~~~ -NOTE: The Server Plugin is enabled in the Gremlin Console by default. +image:spark-logo.png[width=175,float=left] The Spark Plugin installs as part of `spark-gremlin` and provides +a number of imports and utility functions to the environment within which it is used. Those classes and functions +provide the basis for supporting <> using link:http://spark.apache.org[Spark]. +This plugin is defined in greater detail in the <> section and is typically +installed in conjuction with the <>. [[sugar-plugin]] Sugar Plugin diff --git a/docs/src/reference/implementations-neo4j.asciidoc b/docs/src/reference/implementations-neo4j.asciidoc index 3d372080f71..26a8dd030a3 100644 --- a/docs/src/reference/implementations-neo4j.asciidoc +++ b/docs/src/reference/implementations-neo4j.asciidoc @@ -58,7 +58,8 @@ gremlin> graph = Neo4jGraph.open('/tmp/neo4j') TIP: To host Neo4j in <>, the dependencies must first be "installed" or otherwise copied to the Gremlin Server path. The automated method for doing this would be to execute -`bin/gremlin-server.sh install org.apache.tinkerpop neo4j-gremlin x.y.z`. +`bin/gremlin-server.sh install org.apache.tinkerpop neo4j-gremlin x.y.z`. Once installed, the Gremlin Server +configuration file must be edited to include the `Neo4jGremlinPlugin` as shown in `conf/gremlin-server.neo4j`. Indices ~~~~~~~ From ae32bf1329c5cb63c3d2a2bc285ffe3f7198d933 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 28 Feb 2017 08:01:28 -0500 Subject: [PATCH 33/34] TINKERPOP-1612 Updated revised Gremlin Server output at startup --- .../gremlin-language-variants/index.asciidoc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/src/tutorials/gremlin-language-variants/index.asciidoc b/docs/src/tutorials/gremlin-language-variants/index.asciidoc index 70387611c64..aa174806c35 100644 --- a/docs/src/tutorials/gremlin-language-variants/index.asciidoc +++ b/docs/src/tutorials/gremlin-language-variants/index.asciidoc @@ -524,14 +524,26 @@ $ bin/gremlin-server.sh conf/gremlin-server-modern-py.yaml ---oOOo-(3)-oOOo--- [INFO] GremlinServer - Configuring Gremlin Server from conf/gremlin-server-modern-py.yaml +[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics [INFO] GraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties]. -[INFO] ScriptEngines - Loaded gremlin-jython ScriptEngine -[INFO] ScriptEngines - Loaded gremlin-groovy ScriptEngine +[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-* [INFO] ServerGremlinExecutor - Initialized GremlinExecutor and configured ScriptEngines. +[INFO] Logger - 56 attributes loaded from 90 stream(s) in 21ms, 56 saved, 1150 ignored: ["Ant-Version", "Archiver-Version", "Bnd-LastModified", "Boot-Class-Path", "Build-Jdk", "Build-Version", "Built-By", "Bundle-Activator", "Bundle-BuddyPolicy", "Bundle-ClassPath", "Bundle-Description", "Bundle-DocURL", "Bundle-License", "Bundle-ManifestVersion", "Bundle-Name", "Bundle-RequiredExecutionEnvironment", "Bundle-SymbolicName", "Bundle-Vendor", "Bundle-Version", "Can-Redefine-Classes", "Created-By", "DynamicImport-Package", "Eclipse-BuddyPolicy", "Export-Package", "Extension-Name", "Extension-name", "Fragment-Host", "Gremlin-Plugin-Dependencies", "Ignore-Package", "Implementation-Build", "Implementation-Title", "Implementation-URL", "Implementation-Vendor", "Implementation-Vendor-Id", "Implementation-Version", "Import-Package", "Include-Resource", "JCabi-Build", "JCabi-Date", "JCabi-Version", "Main-Class", "Main-class", "Manifest-Version", "Originally-Created-By", "Package", "Private-Package", "Require-Capability", "Specification-Title", "Specification-Vendor", "Specification-Version", "Tool", "Url", "X-Compile-Source-JDK", "X-Compile-Target-JDK", "hash", "version"] [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:0 edges:0], standard] +[INFO] OpLoader - Adding the standard OpProcessor. +[INFO] OpLoader - Adding the session OpProcessor. +[INFO] OpLoader - Adding the traversal OpProcessor. [INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms +[INFO] GremlinServer - Executing start up LifeCycleHook +[INFO] Logger$info - Loading 'modern' graph data. +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo-lite with org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0 +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo-stringd with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 [INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 -[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v2.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0 +[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0 +[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0 +[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1. [INFO] GremlinServer$1 - Channel started at port 8182. ---- From da0a05ca8b420a3200d20de31211f4132cb7f046 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Tue, 28 Feb 2017 10:13:30 -0500 Subject: [PATCH 34/34] TINKERPOP-1612 Minor formatting change to image size --- docs/src/reference/gremlin-applications.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc index 74a572eab9d..6e1ea57bc52 100644 --- a/docs/src/reference/gremlin-applications.asciidoc +++ b/docs/src/reference/gremlin-applications.asciidoc @@ -2115,7 +2115,7 @@ NOTE: This plugin is typically only useful to the Gremlin Console and is enabled Giraph Plugin ~~~~~~~~~~~~~ -image:giraph-logo.png[width=100,float=left] The Giraph Plugin installs as part of `giraph-gremlin` and provides +image:giraph-logo.png[width=50,float=left] The Giraph Plugin installs as part of `giraph-gremlin` and provides a number of imports and utility functions to the environment within which it is used. Those classes and functions provide the basis for supporting <> using link:http://giraph.apache.org[Giraph]. This plugin is defined in greater detail in the <> section and is typically