Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E78CE200ACA for ; Thu, 9 Jun 2016 17:26:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E6214160A58; Thu, 9 Jun 2016 15:26:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6C282160A29 for ; Thu, 9 Jun 2016 17:26:14 +0200 (CEST) Received: (qmail 36766 invoked by uid 500); 9 Jun 2016 15:26:13 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 36757 invoked by uid 99); 9 Jun 2016 15:26:13 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 15:26:13 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 393781A08C3 for ; Thu, 9 Jun 2016 15:26:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id j_8v43HiZhYI for ; Thu, 9 Jun 2016 15:26:07 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 12C375F3A0 for ; Thu, 9 Jun 2016 15:26:05 +0000 (UTC) Received: (qmail 36709 invoked by uid 99); 9 Jun 2016 15:26:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 15:26:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E3811DFDEF; Thu, 9 Jun 2016 15:26:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: okram@apache.org To: commits@tinkerpop.incubator.apache.org Date: Thu, 09 Jun 2016 15:26:04 -0000 Message-Id: <2150cce617994740a890cbcea535d38f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] incubator-tinkerpop git commit: Have GroovyTranslator implemented and connected with ProcessStandard and ProcessComputer suites. Moved packages around -- now its tinkerpop.gremlin.python -- tinkerpop.gremlin.groovy. Things are looking good. archived-at: Thu, 09 Jun 2016 15:26:16 -0000 Repository: incubator-tinkerpop Updated Branches: refs/heads/TINKERPOP-1278 47e71228f -> 97b12a405 http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java new file mode 100644 index 0000000..57f94ca --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessComputerTest.java @@ -0,0 +1,33 @@ +/* + * 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.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 = GroovyComputerProvider.class, graph = TinkerGraph.class) +public class GroovyProcessComputerTest { +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java new file mode 100644 index 0000000..a8252d1 --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProcessStandardTest.java @@ -0,0 +1,33 @@ +/* + * 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.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 = GroovyProvider.class, graph = TinkerGraph.class) +public class GroovyProcessStandardTest { +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java new file mode 100644 index 0000000..310307e --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/groovy/GroovyProvider.java @@ -0,0 +1,39 @@ +/* + * 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.VariantGraphProvider; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Graph; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public class GroovyProvider extends VariantGraphProvider { + + @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 + return graph.traversal(GroovyTranslator.of("g")); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphProvider.java deleted file mode 100644 index dc999cd..0000000 --- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/VariantGraphProvider.java +++ /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.variant; - -import org.apache.commons.configuration.Configuration; -import org.apache.tinkerpop.gremlin.AbstractGraphProvider; -import org.apache.tinkerpop.gremlin.LoadGraphWith; -import org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest; -import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest; -import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest; -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.PartitionStrategyProcessTest; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategyProcessTest; -import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategyProcessTest; -import org.apache.tinkerpop.gremlin.structure.Graph; -import org.apache.tinkerpop.gremlin.structure.VertexProperty; -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.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public abstract class VariantGraphProvider extends AbstractGraphProvider { - - private static Set SKIP_TESTS = new HashSet<>(Arrays.asList( - "testProfileStrategyCallback", - "testProfileStrategyCallbackSideEffect", - "g_withSideEffectXa_g_VX2XX_VX1X_out_whereXneqXaXX", - "g_withSackXBigInteger_TEN_powX1000X_assignX_V_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack", - "g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX", - "shouldSupportJobChaining", - InjectTest.Traversals.class.getCanonicalName(), - ProgramTest.Traversals.class.getCanonicalName(), - CoreTraversalTest.class.getCanonicalName(), - TraversalInterruptionTest.class.getCanonicalName(), - TraversalInterruptionComputerTest.class.getCanonicalName(), - ElementIdStrategyProcessTest.class.getCanonicalName(), - EventStrategyProcessTest.class.getCanonicalName(), - ReadOnlyStrategyProcessTest.class.getCanonicalName(), - PartitionStrategyProcessTest.class.getCanonicalName(), - SubgraphStrategyProcessTest.class.getCanonicalName())); - - 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) ? selectIdMakerFromGraphData(loadGraphWith) : 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); - put("skipTest", SKIP_TESTS.contains(testMethodName) || SKIP_TESTS.contains(test.getCanonicalName())); - if (loadGraphWith == LoadGraphWith.GraphData.CREW) - put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name()); - }}; - } - - @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; - } - - /** - * 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())); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonComputerProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonComputerProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonComputerProvider.java deleted file mode 100644 index a9e9a2d..0000000 --- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonComputerProvider.java +++ /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.variant.python; - -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 PythonComputerProvider extends PythonProvider { - - public GraphTraversalSource traversal(final Graph graph) { - return super.traversal(graph).withComputer(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessComputerTest.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessComputerTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessComputerTest.java deleted file mode 100644 index 1d3bef8..0000000 --- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessComputerTest.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.process.variant.python; - -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 = PythonComputerProvider.class, graph = TinkerGraph.class) -public class PythonProcessComputerTest { - -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessStandardTest.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessStandardTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessStandardTest.java deleted file mode 100644 index b6cce22..0000000 --- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProcessStandardTest.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.process.variant.python; - -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 = PythonProvider.class, graph = TinkerGraph.class) -public class PythonProcessStandardTest { - -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProvider.java deleted file mode 100644 index 2b2aeb0..0000000 --- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/process/variant/python/PythonProvider.java +++ /dev/null @@ -1,40 +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.variant.python; - -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.script.ScriptGraphTraversalSource; -import org.apache.tinkerpop.gremlin.process.variant.VariantGraphProvider; -import org.apache.tinkerpop.gremlin.structure.Graph; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class PythonProvider extends VariantGraphProvider { - - 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 - return new ScriptGraphTraversalSource(graph, graph.traversal().getStrategies(), new PythonTranslator("gremlin-groovy", "g")); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java new file mode 100644 index 0000000..70bbf4f --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonComputerProvider.java @@ -0,0 +1,37 @@ +/* + * 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.python; + +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 PythonComputerProvider extends PythonProvider { + + @Override + public GraphTraversalSource traversal(final Graph graph) { + return super.traversal(graph).withComputer(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java new file mode 100644 index 0000000..5f79f9a --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessComputerTest.java @@ -0,0 +1,34 @@ +/* + * 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.python; + +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 = PythonComputerProvider.class, graph = TinkerGraph.class) +public class PythonProcessComputerTest { + +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java new file mode 100644 index 0000000..a170408 --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProcessStandardTest.java @@ -0,0 +1,34 @@ +/* + * 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.python; + +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 = PythonProvider.class, graph = TinkerGraph.class) +public class PythonProcessStandardTest { + +} http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97b12a40/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java ---------------------------------------------------------------------- diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java new file mode 100644 index 0000000..28cdcfe --- /dev/null +++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java @@ -0,0 +1,75 @@ +/* + * 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.python; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.VariantGraphProvider; +import org.apache.tinkerpop.gremlin.python.GremlinPythonGenerator; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.util.ScriptEngineCache; + +import javax.script.ScriptEngine; +import javax.script.ScriptException; +import java.io.File; +import java.util.Random; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public class PythonProvider extends VariantGraphProvider { + + private static final Random RANDOM = new Random(); + + static { + try { + final String rootPackageName = (new File("gremlin-variant").exists() ? "gremlin-variant/" : "") + "src/main/jython/"; + final String gremlinPythonPackageName = rootPackageName + "/gremlin_python"; + final String gremlinDriverPackageName = rootPackageName + "/gremlin_driver"; + final String gremlinPythonModuleName = gremlinPythonPackageName + "/gremlin_python.py"; + GremlinPythonGenerator.create(gremlinPythonModuleName); + final ScriptEngine jythonEngine = ScriptEngineCache.get("jython"); + jythonEngine.eval("import sys"); + jythonEngine.eval("sys.path.append('" + gremlinPythonPackageName + "')"); + jythonEngine.eval("sys.path.append('" + gremlinDriverPackageName + "')"); + jythonEngine.eval("from gremlin_python import *"); + jythonEngine.eval("from gremlin_python import __"); + } catch (final ScriptException e) { + throw new IllegalStateException(e.getMessage(), e); + } + } + + @Override + public GraphTraversalSource traversal(final Graph graph) { + final boolean importStatics = RANDOM.nextBoolean(); + try { + if (importStatics) + ScriptEngineCache.get("jython").eval("for k in statics:\n globals()[k] = statics[k]"); + } catch (final ScriptException e) { + throw new IllegalStateException(e.getMessage(), e); + } + // + if ((Boolean) graph.configuration().getProperty("skipTest")) + return graph.traversal(); + //throw new VerificationException("This test current does not work with Gremlin-Python", EmptyTraversal.instance()); + else + return graph.traversal(PythonTranslator.of("gremlin-groovy", "g", importStatics)); + } + +}