@Test
    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
    public void shouldAllowTraversalToIterateInDifferentThreadThanOriginallyEvaluatedWithoutAutoCommit() throws Exception {
        final TinkerGraph graph = TinkerFactory.createModern();
        final GraphTraversalSource g = graph.traversal();

        // this test sort of simulates Gremlin Server interaction where a Traversal is eval'd in one Thread, but
        // then iterated in another.  this basically tests the state of the Gremlin Server GremlinExecutor when
        // being used in session mode
        final ExecutorService evalExecutor = Executors.newSingleThreadExecutor(testingThreadFactory);
        final GremlinExecutor gremlinExecutor = GremlinExecutor.build().executorService(evalExecutor).create();

        final Map<String,Object> bindings = new HashMap<>();
        bindings.put("g", g);

        final AtomicInteger vertexCount = new AtomicInteger(0);

        final ExecutorService iterationExecutor = Executors.newSingleThreadExecutor(testingThreadFactory);
        gremlinExecutor.eval("g.V().out()", bindings).thenAcceptAsync(o -> {
            final Iterator itty = (Iterator) o;
            itty.forEachRemaining(v -> vertexCount.incrementAndGet());
        }, iterationExecutor).join();

        assertEquals(6, vertexCount.get());

        gremlinExecutor.close();
        evalExecutor.shutdown();
        evalExecutor.awaitTermination(30000, TimeUnit.MILLISECONDS);
        iterationExecutor.shutdown();
        iterationExecutor.awaitTermination(30000, TimeUnit.MILLISECONDS);
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorOverGraphTest.java