Skip to content

Commit

Permalink
Tests WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 committed Feb 29, 2024
1 parent b3f54a7 commit 7112ebb
Showing 1 changed file with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.apache.tinkerpop.gremlin.driver;

import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
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.Vertex;
import org.junit.Test;

import java.util.List;
import java.util.concurrent.ExecutionException;

import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;

public class ClientWithOptionsTest {
@Test
public void aliasedClientWithBytecode() throws Exception {
Cluster cluster = Cluster.build().create();
Client client = cluster.connect().alias("g");
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client, "g"));
GraphTraversal traversal = g.with("evaluationTimeout", 3).V().both().both().both();
try {
List<Result> res = client.submit(traversal).all().get(); // bytecode
System.out.println("Results: " + res);
} catch (Exception e) {
e.printStackTrace();
}
}

@Test(expected = ResponseException.class)
public void nonAliasedClientWithByteCode() throws Exception {
Cluster cluster = Cluster.build().create();
Client client = cluster.connect();
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client, "g"));
try {
List<Vertex> res = g.with("evaluationTimeout", 2).V().both().both().both().toList();
System.out.println("Results: " + res);
} catch (Exception e) {
e.printStackTrace();
}

}

@Test(expected = ResponseException.class)
public void aliasedClientWithScript() throws Exception {
Cluster cluster = Cluster.build().create();
Client client = cluster.connect().alias("g");
try {
List<Result> res = client.submit("g.with(\"evaluationTimeout\", 4).V().both().both().both();").all().get();
System.out.println("Results: " + res);
} catch (Exception e) {
e.printStackTrace();
}
}

@Test(expected = ExecutionException.class)
public void nonAliasedClientWithScript() throws Exception {
Cluster cluster = Cluster.build().create();
Client client = cluster.connect();
try {
List<Result> res = client.submit("g.with(\"evaluationTimeout\",5).V().both().both().both();").all().get();
System.out.println("Results: " + res);
} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit 7112ebb

Please sign in to comment.