Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions gremlin-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
91 changes: 0 additions & 91 deletions gremlin-driver/src/main/java/examples/pom.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Edge> e1 = g.V(1).bothE().toList(); // (1)
List<Edge> e2 = g.V(1).bothE().where(otherV().hasId(2)).toList(); // (2)
Expand Down
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit odd to me that this file runs the main function of other classes. I know those classes are there to mimic the ones from gremlin-examples, but seeing as how this is going to be tied to integration test, you might as well just make each of those classes a test in this file instead? Just a thought, doesn't really need to be changed if you feel that it makes more sense this way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that making the examples complete tests makes more sense in this isolated context. It's done more to mimic the rest of the GLVs, where currently the examples are also simply executed as part of the integration tests. Perhaps adding output validation and converting examples into proper tests could be a future piece of work.
As of now, I think it makes sense to keep the current approach to stay consistent with the other GLVs, and the main goal of catching the breaking changes that affect examples is still achieved.

Original file line number Diff line number Diff line change
@@ -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());
}
}
}
Loading