diff --git a/gremlin-driver/pom.xml b/gremlin-driver/pom.xml
index 49fc17b25e0..f61ec74fead 100644
--- a/gremlin-driver/pom.xml
+++ b/gremlin-driver/pom.xml
@@ -268,11 +268,6 @@ limitations under the License.
org.apache.maven.plugins
maven-compiler-plugin
-
-
- examples/**
-
-
diff --git a/gremlin-driver/src/main/java/examples/pom.xml b/gremlin-driver/src/main/java/examples/pom.xml
deleted file mode 100644
index 85417eff1dc..00000000000
--- a/gremlin-driver/src/main/java/examples/pom.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
- 4.0.0
-
- org.apache.tinkerpop
- run-examples
- 3.7.1
-
-
- UTF-8
- ${project.version}
-
-
-
-
- org.apache.tinkerpop
- gremlin-core
- ${project.version}
-
-
- org.apache.tinkerpop
- gremlin-driver
- ${project.version}
-
-
- org.apache.tinkerpop
- tinkergraph-gremlin
- ${project.version}
-
-
-
-
- .
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.4.1
-
-
- package
-
- shade
-
-
- run-examples-shaded
- false
-
-
-
- *:*
-
- META-INF/*.SF
- META-INF/*.DSA
- META-INF/*.RSA
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/gremlin-driver/src/main/java/examples/BasicGremlin.java b/gremlin-server/src/test/java/examples/BasicGremlin.java
similarity index 89%
rename from gremlin-driver/src/main/java/examples/BasicGremlin.java
rename to gremlin-server/src/test/java/examples/BasicGremlin.java
index 13bc53b7ed0..ffee2dabaea 100644
--- a/gremlin-driver/src/main/java/examples/BasicGremlin.java
+++ b/gremlin-server/src/test/java/examples/BasicGremlin.java
@@ -29,9 +29,9 @@ Licensed to the Apache Software Foundation (ASF) under one
import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
public class BasicGremlin {
- static final String SERVER_HOST = System.getenv().getOrDefault("GREMLIN_SERVER_HOST", "localhost");
- static final int SERVER_PORT = Integer.parseInt(System.getenv().getOrDefault("GREMLIN_SERVER_PORT", "8182"));
- static final String VERTEX_LABEL = System.getenv().getOrDefault("VERTEX_LABEL", "person");
+ static final String SERVER_HOST = System.getProperty("GREMLIN_SERVER_HOST", "localhost");
+ static final int SERVER_PORT = Integer.parseInt(System.getProperty("GREMLIN_SERVER_PORT", "8182"));
+ static final String VERTEX_LABEL = System.getProperty("VERTEX_LABEL", "person");
public static void main(String[] args) throws Exception {
Cluster cluster = Cluster.build(SERVER_HOST).port(SERVER_PORT).create();
diff --git a/gremlin-driver/src/main/java/examples/Connections.java b/gremlin-server/src/test/java/examples/Connections.java
similarity index 93%
rename from gremlin-driver/src/main/java/examples/Connections.java
rename to gremlin-server/src/test/java/examples/Connections.java
index 549c8c7bb95..f48b1b811b2 100644
--- a/gremlin-driver/src/main/java/examples/Connections.java
+++ b/gremlin-server/src/test/java/examples/Connections.java
@@ -35,9 +35,9 @@ Licensed to the Apache Software Foundation (ASF) under one
import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
public class Connections {
- static final String SERVER_HOST = System.getenv().getOrDefault("GREMLIN_SERVER_HOST", "localhost");
- static final int SERVER_PORT = Integer.parseInt(System.getenv().getOrDefault("GREMLIN_SERVER_PORT", "8182"));
- static final String VERTEX_LABEL = System.getenv().getOrDefault("VERTEX_LABEL", "connection");
+ static final String SERVER_HOST = System.getProperty("GREMLIN_SERVER_HOST", "localhost");
+ static final int SERVER_PORT = Integer.parseInt(System.getProperty("GREMLIN_SERVER_PORT", "8182"));
+ static final String VERTEX_LABEL = System.getProperty("VERTEX_LABEL", "connection");
public static void main(String[] args) throws Exception {
withEmbedded();
diff --git a/gremlin-driver/src/main/java/examples/ModernTraversals.java b/gremlin-server/src/test/java/examples/ModernTraversals.java
similarity index 93%
rename from gremlin-driver/src/main/java/examples/ModernTraversals.java
rename to gremlin-server/src/test/java/examples/ModernTraversals.java
index 375d17c6972..4ba5415b991 100644
--- a/gremlin-driver/src/main/java/examples/ModernTraversals.java
+++ b/gremlin-server/src/test/java/examples/ModernTraversals.java
@@ -33,13 +33,13 @@ Licensed to the Apache Software Foundation (ASF) under one
import static org.apache.tinkerpop.gremlin.structure.T.id;
public class ModernTraversals {
- static final String SERVER_HOST = System.getenv().getOrDefault("GREMLIN_SERVER_HOST", "localhost");
- static final int SERVER_PORT = Integer.parseInt(System.getenv().getOrDefault("GREMLIN_SERVER_PORT", "8182"));
+ static final String SERVER_HOST = System.getProperty("GREMLIN_SERVER_HOST", "localhost");
+ static final int SERVER_PORT = Integer.parseInt(System.getProperty("GREMLIN_SERVER_PORT", "8182"));
public static void main(String[] args) throws Exception {
// Performs basic traversals on the Modern toy graph loaded on the server
Cluster cluster = Cluster.build(SERVER_HOST).port(SERVER_PORT).create();
- GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster, "g"));
+ GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster, "gmodern"));
List e1 = g.V(1).bothE().toList(); // (1)
List e2 = g.V(1).bothE().where(otherV().hasId(2)).toList(); // (2)
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/DriverExamplesIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/DriverExamplesIntegrateTest.java
new file mode 100644
index 00000000000..742468ae611
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/DriverExamplesIntegrateTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.driver;
+
+import examples.BasicGremlin;
+import examples.Connections;
+import examples.ModernTraversals;
+import org.apache.tinkerpop.gremlin.server.AbstractGremlinServerIntegrationTest;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Integration tests for driver examples to ensure they work with the current driver.
+ * These tests catch breaking changes that would affect example code.
+ */
+public class DriverExamplesIntegrateTest extends AbstractGremlinServerIntegrationTest {
+
+ @BeforeClass
+ public static void setUpEnvironment() {
+ // Set environment variables for examples to connect to test server
+ System.setProperty("GREMLIN_SERVER_HOST", "localhost");
+ System.setProperty("GREMLIN_SERVER_PORT", "45940");
+ }
+
+ @AfterClass
+ public static void tearDownEnvironment() {
+ // Clean up system properties
+ System.clearProperty("GREMLIN_SERVER_HOST");
+ System.clearProperty("GREMLIN_SERVER_PORT");
+ }
+
+ @Test
+ public void shouldRunBasicGremlinExample() throws Exception {
+ try {
+ BasicGremlin.main(new String[]{});
+ } catch (Exception e) {
+ fail("BasicGremlin example failed: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void shouldRunModernTraversalsExample() throws Exception {
+ try {
+ ModernTraversals.main(new String[]{});
+ } catch (Exception e) {
+ fail("ModernTraversals example failed: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void shouldRunConnectionsExample() throws Exception {
+ try {
+ Connections.main(new String[]{});
+ } catch (Exception e) {
+ fail("Connections example failed: " + e.getMessage());
+ }
+ }
+}