This is an automated email from the ASF dual-hosted git repository.

Cole-Greer pushed a commit to branch 3.7-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/3.7-dev by this push:
     new 98f0952adf Integrate Java driver examples into automated build process 
(#3297)
98f0952adf is described below

commit 98f0952adf535b2b24b6c1f7bd118b5fa197aea8
Author: kirill-stepanishin <[email protected]>
AuthorDate: Mon Jul 20 11:10:09 2026 -0700

    Integrate Java driver examples into automated build process (#3297)
    
    - Move examples from gremlin-driver to gremlin-server test sources
    - Add DriverExamplesIntegrateTest to run examples against test server
    - Change examples to use System.getProperty for test compatibility
    - Update ModernTraversals to use gmodern traversal source
    - Remove compiler exclusion for examples in gremlin-driver pom
---
 gremlin-driver/pom.xml                             |  5 --
 gremlin-driver/src/main/java/examples/pom.xml      | 91 ----------------------
 .../src/test}/java/examples/BasicGremlin.java      |  6 +-
 .../src/test}/java/examples/Connections.java       |  6 +-
 .../src/test}/java/examples/ModernTraversals.java  |  6 +-
 .../driver/DriverExamplesIntegrateTest.java        | 77 ++++++++++++++++++
 6 files changed, 86 insertions(+), 105 deletions(-)

diff --git a/gremlin-driver/pom.xml b/gremlin-driver/pom.xml
index 191ed18568..1602aa4a92 100644
--- a/gremlin-driver/pom.xml
+++ b/gremlin-driver/pom.xml
@@ -268,11 +268,6 @@ limitations under the License.
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>examples/**</exclude>
-                    </excludes>
-                </configuration>
             </plugin>
         </plugins>
     </build>
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 85417eff1d..0000000000
--- a/gremlin-driver/src/main/java/examples/pom.xml
+++ /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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>org.apache.tinkerpop</groupId>
-    <artifactId>run-examples</artifactId>
-    <version>3.7.1</version>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <gremlin.version>${project.version}</gremlin.version>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-driver</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>tinkergraph-gremlin</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <sourceDirectory>.</sourceDirectory>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>3.4.1</version>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                        <configuration>
-                            <finalName>run-examples-shaded</finalName>
-                            
<createDependencyReducedPom>false</createDependencyReducedPom>
-                            <filters>
-                                <filter>
-                                    <!--
-                                        Shading signed JARs will fail without 
this.
-                                        
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-                                    -->
-                                    <artifact>*:*</artifact>
-                                    <excludes>
-                                        <exclude>META-INF/*.SF</exclude>
-                                        <exclude>META-INF/*.DSA</exclude>
-                                        <exclude>META-INF/*.RSA</exclude>
-                                    </excludes>
-                                </filter>
-                            </filters>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            </plugins>
-    </build>
-
-
-</project>
\ 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 f0c71dc10d..20a6c3773b 100644
--- a/gremlin-driver/src/main/java/examples/BasicGremlin.java
+++ b/gremlin-server/src/test/java/examples/BasicGremlin.java
@@ -29,9 +29,9 @@ import java.util.List;
 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 12ac87a65a..a385c1c169 100644
--- a/gremlin-driver/src/main/java/examples/Connections.java
+++ b/gremlin-server/src/test/java/examples/Connections.java
@@ -35,9 +35,9 @@ import 
org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1;
 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 90e1c0cda5..d90c9d470e 100644
--- a/gremlin-driver/src/main/java/examples/ModernTraversals.java
+++ b/gremlin-server/src/test/java/examples/ModernTraversals.java
@@ -33,13 +33,13 @@ import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;
 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<Edge> e1 = g.V(1).bothE().toList(); // (1)
         List<Edge> 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 0000000000..742468ae61
--- /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());
+        }
+    }
+}

Reply via email to