You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/04/17 13:30:06 UTC

[4/7] tinkerpop git commit: Update docs acc. to GraphManager changes

Update docs acc. to GraphManager changes


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/32374d94
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/32374d94
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/32374d94

Branch: refs/heads/master
Commit: 32374d9442229930b2713a35ec4c44aadff6c732
Parents: 4f9f90b
Author: dpitera <dp...@us.ibm.com>
Authored: Wed Mar 15 15:34:09 2017 -0400
Committer: dpitera <dp...@us.ibm.com>
Committed: Mon Mar 27 13:38:49 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   3 +
 .../src/reference/gremlin-applications.asciidoc |   1 +
 .../upgrade/release-3.2.x-incubating.asciidoc   |  10 +
 .../tinkerpop/gremlin/server/Settings.java      |   4 +-
 .../gremlin/server/util/BasicGraphManager.java  | 178 ----------------
 .../server/util/DefaultGraphManager.java        | 201 +++++++++++++++++++
 .../server/util/BasicGraphManagerTest.java      |  64 ------
 .../server/util/DefaultGraphManagerTest.java    |  88 ++++++++
 8 files changed, 305 insertions(+), 244 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index af41d1f..1e85497 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -56,6 +56,9 @@ TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Improved error handling of compilation failures for very large or highly parameterized script sent to Gremlin Server.
 * Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals.
 * Improved Gremlin-Python Driver implementation by adding a threaded client with basic connection pooling and support for pluggable websocket clients.
+* Changed GraphManager from a final class implementation to an interface.
+* Updated GraphManager interface to include methods for opening/instantiating a graph and closing a graph.
+* Implemented DefaultGraphManager to include previous GraphManager functionality and adhere to updated interface.
 
 [[release-3-2-4]]
 TinkerPop 3.2.4 (Release Date: February 8, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index bfaa153..3f4f72f 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -1075,6 +1075,7 @@ The following table describes the various configuration options that Gremlin Ser
 |authentication.className |The fully qualified classname of an `Authenticator` implementation to use.  If this setting is not present, then authentication is effectively disabled. |`AllowAllAuthenticator`
 |authentication.config |A `Map` of configuration settings to be passes to the `Authenticator` when it is constructed.  The settings available are dependent on the implementation. |_none_
 |channelizer |The fully qualified classname of the `Channelizer` implementation to use.  A `Channelizer` is a "channel initializer" which Gremlin Server uses to define the type of processing pipeline to use.  By allowing different `Channelizer` implementations, Gremlin Server can support different communication protocols (e.g. Websockets, Java NIO, etc.). |`WebSocketChannelizer`
+|graphManager |The fully qualified classname of the `GraphManager` implementation to use.  A `GraphManager` is a class that adheres to the Tinkerpop GraphManager interface, allowing custom implementations for storing and managing graph references, as well as defining custom methods to open and close graphs instantiations. It is important to note that the Tinkerpop Http and WebSocketChannelizers auto-commit and auto-rollback based on the graphs stored in the graphManager upon script execution completion. |`DefaultGraphManager`
 |graphs |A `Map` of `Graph` configuration files where the key of the `Map` becomes the name to which the `Graph` will be bound and the value is the file name of a `Graph` configuration file. |_none_
 |gremlinPool |The number of "Gremlin" threads available to execute actual scripts in a `ScriptEngine`. This pool represents the workers available to handle blocking operations in Gremlin Server. When set to `0`, Gremlin Server will use the value provided by `Runtime.availableProcessors()`. |0
 |host |The name of the host to bind the server to. |localhost

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index fbe31bd..7fa9e90 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -66,6 +66,16 @@ is determined by projections of the path data. This extension is fully backwards
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1387[TINKERPOP-1387]
 
+GraphManager versus DefaultGraphManager
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The Gremlin-Server previously implemented its own final GraphManager class. Now, the GraphManager has been 
+updated to an interface, and users can supply their own GraphManager implementations in their YAML. The
+previous GraphManager class was traditionally only to be used by internal Gremlin-Server classes; however,
+if you previously used the GraphManager, then this changeset will be `breaking` for you. To fix the break,
+you can upgrade your code to use the new DefaultGraphManager.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1438[TINKERPOP-1438]
+
 Gremlin-Python Driver
 ^^^^^^^^^^^^^^^^^^^^^
 Gremlin-Python now offers a more complete driver implementation that uses connection pooling and

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
index 36435a0..bbc34b9 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
@@ -28,7 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator;
 import org.apache.tinkerpop.gremlin.server.auth.Authenticator;
 import org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer;
-import org.apache.tinkerpop.gremlin.server.util.BasicGraphManager;
+import org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager;
 import info.ganglia.gmetric4j.gmetric.GMetric;
 import org.apache.tinkerpop.gremlin.server.util.LifeCycleHook;
 import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -178,7 +178,7 @@ public class Settings {
     /**
      * The full class name of the {@link GraphManager} to use in Gremlin Server.
      */
-    public String graphManager = BasicGraphManager.class.getName();
+    public String graphManager = DefaultGraphManager.class.getName();
 
     /**
      * Configured metrics for Gremlin Server.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManager.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManager.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManager.java
deleted file mode 100644
index af5432f..0000000
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManager.java
+++ /dev/null
@@ -1,178 +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.
- */
-package org.apache.tinkerpop.gremlin.server.util;
-
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
-import org.apache.tinkerpop.gremlin.server.GraphManager;
-import org.apache.tinkerpop.gremlin.server.GremlinServer;
-import org.apache.tinkerpop.gremlin.server.Settings;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Transaction;
-import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.script.Bindings;
-import javax.script.SimpleBindings;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Predicate;
-
-/**
- * Holder for {@link Graph} and {@link TraversalSource} instances configured for the server to be passed to script
- * engine bindings. The {@link Graph} instances are read from the {@link Settings} for Gremlin Server as defined in
- * the configuration file. The {@link TraversalSource} instances are rebound to the {@code GraphManager} once
- * initialization scripts construct them.
- */
-public final class BasicGraphManager implements GraphManager {
-    private static final Logger logger = LoggerFactory.getLogger(GremlinServer.class);
-
-    private final Map<String, Graph> graphs = new ConcurrentHashMap<>();
-    private final Map<String, TraversalSource> traversalSources = new ConcurrentHashMap<>();
-
-    /**
-     * Create a new instance using the {@link Settings} from Gremlin Server.
-     */
-    public BasicGraphManager(final Settings settings) {
-        settings.graphs.entrySet().forEach(e -> {
-            try {
-                final Graph newGraph = GraphFactory.open(e.getValue());
-                graphs.put(e.getKey(), newGraph);
-                logger.info("Graph [{}] was successfully configured via [{}].", e.getKey(), e.getValue());
-            } catch (RuntimeException re) {
-                logger.warn(String.format("Graph [%s] configured at [%s] could not be instantiated and will not be available in Gremlin Server.  GraphFactory message: %s",
-                        e.getKey(), e.getValue(), re.getMessage()), re);
-                if (re.getCause() != null) logger.debug("GraphFactory exception", re.getCause());
-            }
-        });
-    }
-
-    /**
-     * Get a list of the {@link Graph} instances and their binding names as defined in the Gremlin Server
-     * configuration file.
-     *
-     * @return a {@link Map} where the key is the name of the {@link Graph} and the value is the {@link Graph} itself
-     */
-    public Map<String, Graph> getGraphs() {
-        return graphs;
-    }
-
-    public Graph getGraph(String gName) {
-        return graphs.get(gName);
-    }
-
-    public void addGraph(String gName, Graph g) {
-        graphs.put(gName, g);
-    }
-
-    /**
-     * Get a list of the {@link TraversalSource} instances and their binding names as defined by Gremlin Server
-     * initialization scripts.
-     *
-     * @return a {@link Map} where the key is the name of the {@link TraversalSource} and the value is the
-     *         {@link TraversalSource} itself
-     */
-    public Map<String, TraversalSource> getTraversalSources() {
-        return traversalSources;
-    }
-
-    public TraversalSource getTraversalSource(String tsName) {
-        return traversalSources.get(tsName);
-    }
-
-    public void addTraversalSource(String tsName, TraversalSource ts) {
-        traversalSources.put(tsName, ts);
-    }
-
-    /**
-     * Get the {@link Graph} and {@link TraversalSource} list as a set of bindings.
-     */
-    public Bindings getAsBindings() {
-        final Bindings bindings = new SimpleBindings();
-        graphs.forEach(bindings::put);
-        traversalSources.forEach(bindings::put);
-        return bindings;
-    }
-
-    /**
-     * Rollback transactions across all {@link Graph} objects.
-     */
-    public void rollbackAll() {
-        graphs.entrySet().forEach(e -> {
-            final Graph graph = e.getValue();
-            if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
-                graph.tx().rollback();
-        });
-    }
-
-    /**
-     * Selectively rollback transactions on the specified graphs or the graphs of traversal sources.
-     */
-    public void rollback(final Set<String> graphSourceNamesToCloseTxOn) {
-        closeTx(graphSourceNamesToCloseTxOn, Transaction.Status.ROLLBACK);
-    }
-
-    /**
-     * Commit transactions across all {@link Graph} objects.
-     */
-    public void commitAll() {
-        graphs.entrySet().forEach(e -> {
-            final Graph graph = e.getValue();
-            if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
-                graph.tx().commit();
-        });
-    }
-
-    /**
-     * Selectively commit transactions on the specified graphs or the graphs of traversal sources.
-     */
-    public void commit(final Set<String> graphSourceNamesToCloseTxOn) {
-        closeTx(graphSourceNamesToCloseTxOn, Transaction.Status.COMMIT);
-    }
-
-    /**
-     * Selectively close transactions on the specified graphs or the graphs of traversal sources.
-     */
-    private void closeTx(final Set<String> graphSourceNamesToCloseTxOn, final Transaction.Status tx) {
-        final Set<Graph> graphsToCloseTxOn = new HashSet<>();
-
-        // by the time this method has been called, it should be validated that the source/graph is present.
-        // might be possible that it could have been removed dynamically, but that i'm not sure how one would do
-        // that as of right now unless they were embedded in which case they'd need to know what they were doing
-        // anyway
-        graphSourceNamesToCloseTxOn.forEach(r -> {
-            if (graphs.containsKey(r))
-                graphsToCloseTxOn.add(graphs.get(r));
-            else
-                graphsToCloseTxOn.add(traversalSources.get(r).getGraph());
-        });
-
-        graphsToCloseTxOn.forEach(graph -> {
-            if (graph.features().graph().supportsTransactions() && graph.tx().isOpen()) {
-                if (tx == Transaction.Status.COMMIT)
-                    graph.tx().commit();
-                else
-                    graph.tx().rollback();
-            }
-        });
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
new file mode 100644
index 0000000..807213a
--- /dev/null
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManager.java
@@ -0,0 +1,201 @@
+/*
+ * 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.server.util;
+
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
+import org.apache.tinkerpop.gremlin.server.GraphManager;
+import org.apache.tinkerpop.gremlin.server.GremlinServer;
+import org.apache.tinkerpop.gremlin.server.Settings;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.script.Bindings;
+import javax.script.SimpleBindings;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * Holder for {@link Graph} and {@link TraversalSource} instances configured for the server to be passed to script
+ * engine bindings. The {@link Graph} instances are read from the {@link Settings} for Gremlin Server as defined in
+ * the configuration file. The {@link TraversalSource} instances are rebound to the {@code GraphManager} once
+ * initialization scripts construct them.
+ */
+public final class DefaultGraphManager implements GraphManager {
+    private static final Logger logger = LoggerFactory.getLogger(GremlinServer.class);
+
+    private final Map<String, Graph> graphs = new ConcurrentHashMap<>();
+    private final Map<String, TraversalSource> traversalSources = new ConcurrentHashMap<>();
+
+    /**
+     * Create a new instance using the {@link Settings} from Gremlin Server.
+     */
+    public DefaultGraphManager(final Settings settings) {
+        settings.graphs.entrySet().forEach(e -> {
+            try {
+                final Graph newGraph = GraphFactory.open(e.getValue());
+                graphs.put(e.getKey(), newGraph);
+                logger.info("Graph [{}] was successfully configured via [{}].", e.getKey(), e.getValue());
+            } catch (RuntimeException re) {
+                logger.warn(String.format("Graph [%s] configured at [%s] could not be instantiated and will not be available in Gremlin Server.  GraphFactory message: %s",
+                        e.getKey(), e.getValue(), re.getMessage()), re);
+                if (re.getCause() != null) logger.debug("GraphFactory exception", re.getCause());
+            }
+        });
+    }
+
+    /**
+     * Get a list of the {@link Graph} instances and their binding names as defined in the Gremlin Server
+     * configuration file.
+     *
+     * @return a {@link Map} where the key is the name of the {@link Graph} and the value is the {@link Graph} itself
+     */
+    public Map<String, Graph> getGraphs() {
+        return graphs;
+    }
+
+    public Graph getGraph(String gName) {
+        return graphs.get(gName);
+    }
+
+    public void addGraph(String gName, Graph g) {
+        graphs.put(gName, g);
+    }
+
+    /**
+     * Get a list of the {@link TraversalSource} instances and their binding names as defined by Gremlin Server
+     * initialization scripts.
+     *
+     * @return a {@link Map} where the key is the name of the {@link TraversalSource} and the value is the
+     *         {@link TraversalSource} itself
+     */
+    public Map<String, TraversalSource> getTraversalSources() {
+        return traversalSources;
+    }
+
+    public TraversalSource getTraversalSource(String tsName) {
+        return traversalSources.get(tsName);
+    }
+
+    public void addTraversalSource(String tsName, TraversalSource ts) {
+        traversalSources.put(tsName, ts);
+    }
+
+    /**
+     * Get the {@link Graph} and {@link TraversalSource} list as a set of bindings.
+     */
+    public Bindings getAsBindings() {
+        final Bindings bindings = new SimpleBindings();
+        graphs.forEach(bindings::put);
+        traversalSources.forEach(bindings::put);
+        return bindings;
+    }
+
+    /**
+     * Rollback transactions across all {@link Graph} objects.
+     */
+    public void rollbackAll() {
+        graphs.entrySet().forEach(e -> {
+            final Graph graph = e.getValue();
+            if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
+                graph.tx().rollback();
+        });
+    }
+
+    /**
+     * Selectively rollback transactions on the specified graphs or the graphs of traversal sources.
+     */
+    public void rollback(final Set<String> graphSourceNamesToCloseTxOn) {
+        closeTx(graphSourceNamesToCloseTxOn, Transaction.Status.ROLLBACK);
+    }
+
+    /**
+     * Commit transactions across all {@link Graph} objects.
+     */
+    public void commitAll() {
+        graphs.entrySet().forEach(e -> {
+            final Graph graph = e.getValue();
+            if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
+                graph.tx().commit();
+        });
+    }
+
+    /**
+     * Selectively commit transactions on the specified graphs or the graphs of traversal sources.
+     */
+    public void commit(final Set<String> graphSourceNamesToCloseTxOn) {
+        closeTx(graphSourceNamesToCloseTxOn, Transaction.Status.COMMIT);
+    }
+
+    /**
+     * Basic graphManager has basic openGraph function.
+     */
+    public Graph openGraph(String graphName, Supplier<Graph> supplier) {
+        final Graph graph = graphs.get(graphName);
+        if (null != graph) {
+            return graph;
+        }
+        return supplier.get();
+    }
+
+    /**
+     *  Close graph
+     */
+    public void closeGraph(Graph graph) {
+        try {
+            graph.close();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Selectively close transactions on the specified graphs or the graphs of traversal sources.
+     */
+    private void closeTx(final Set<String> graphSourceNamesToCloseTxOn, final Transaction.Status tx) {
+        final Set<Graph> graphsToCloseTxOn = new HashSet<>();
+
+        // by the time this method has been called, it should be validated that the source/graph is present.
+        // might be possible that it could have been removed dynamically, but that i'm not sure how one would do
+        // that as of right now unless they were embedded in which case they'd need to know what they were doing
+        // anyway
+        graphSourceNamesToCloseTxOn.forEach(r -> {
+            if (graphs.containsKey(r))
+                graphsToCloseTxOn.add(graphs.get(r));
+            else
+                graphsToCloseTxOn.add(traversalSources.get(r).getGraph());
+        });
+
+        graphsToCloseTxOn.forEach(graph -> {
+            if (graph.features().graph().supportsTransactions() && graph.tx().isOpen()) {
+                if (tx == Transaction.Status.COMMIT)
+                    graph.tx().commit();
+                else
+                    graph.tx().rollback();
+            }
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManagerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManagerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManagerTest.java
deleted file mode 100644
index 2b72c62..0000000
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/BasicGraphManagerTest.java
+++ /dev/null
@@ -1,64 +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.
- */
-package org.apache.tinkerpop.gremlin.server.util;
-
-import org.apache.tinkerpop.gremlin.server.GraphManager;
-import org.apache.tinkerpop.gremlin.server.Settings;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Test;
-
-import javax.script.Bindings;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class BasicGraphManagerTest {
-
-    @Test
-    public void shouldReturnGraphs() {
-        final Settings settings = Settings.read(BasicGraphManagerTest.class.getResourceAsStream("../gremlin-server-integration.yaml"));
-        final GraphManager graphManager = new BasicGraphManager(settings);
-        final Map<String, Graph> m = graphManager.getGraphs();
-
-        assertNotNull(m);
-        assertEquals(1, m.size());
-        assertThat(m.containsKey("graph"), is(true));
-        assertThat(m.get("graph"), instanceOf(TinkerGraph.class));
-    }
-
-    @Test
-    public void shouldGetAsBindings() {
-        final Settings settings = Settings.read(BasicGraphManagerTest.class.getResourceAsStream("../gremlin-server-integration.yaml"));
-        final GraphManager graphManager = new BasicGraphManager(settings);
-        final Bindings bindings = graphManager.getAsBindings();
-
-        assertNotNull(bindings);
-        assertEquals(1, bindings.size());
-        assertThat(bindings.get("graph"), instanceOf(TinkerGraph.class));
-        assertThat(bindings.containsKey("graph"), is(true));
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/32374d94/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java
new file mode 100644
index 0000000..a2ec75d
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/DefaultGraphManagerTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.server.util;
+
+import org.apache.tinkerpop.gremlin.server.GraphManager;
+import org.apache.tinkerpop.gremlin.server.Settings;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Test;
+
+import javax.script.Bindings;
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DefaultGraphManagerTest {
+
+    @Test
+    public void shouldReturnGraphs() {
+        final Settings settings = Settings.read(DefaultGraphManagerTest.class.getResourceAsStream("../gremlin-server-integration.yaml"));
+        final GraphManager graphManager = new DefaultGraphManager(settings);
+        final Map<String, Graph> m = graphManager.getGraphs();
+
+        assertNotNull(m);
+        assertEquals(1, m.size());
+        assertThat(m.containsKey("graph"), is(true));
+        assertThat(m.get("graph"), instanceOf(TinkerGraph.class));
+    }
+
+    @Test
+    public void shouldGetAsBindings() {
+        final Settings settings = Settings.read(DefaultGraphManagerTest.class.getResourceAsStream("../gremlin-server-integration.yaml"));
+        final GraphManager graphManager = new DefaultGraphManager(settings);
+        final Bindings bindings = graphManager.getAsBindings();
+
+        assertNotNull(bindings);
+        assertEquals(1, bindings.size());
+        assertThat(bindings.get("graph"), instanceOf(TinkerGraph.class));
+        assertThat(bindings.containsKey("graph"), is(true));
+    }
+    
+    @Test
+    public void shouldGetGraph() {
+        final Settings settings = Settings.read(DefaultGraphManagerTest.class.getResourceAsStream("../gremlin-server-integration.yaml"));
+        final GraphManager graphManager = new DefaultGraphManager(settings);
+        final Graph graph = graphManager.getGraph("graph");
+
+        assertNotNull(graph);
+        assertThat(graph, instanceOf(TinkerGraph.class));
+    }
+    
+    @Test
+    public void shouldGetDynamicallyAddedGraph() {
+        final Settings settings = Settings.read(DefaultGraphManagerTest.class.getResourceAsStream("../gremlin-server-integration.yaml"));
+        final GraphManager graphManager = new DefaultGraphManager(settings);
+        final Graph graph = graphManager.getGraph("graph"); //fake out a graph instance
+        graphManager.addGraph("newGraph", graph);
+        
+        final Map<String, Graph> m = graphManager.getGraphs();
+        assertNotNull(m);
+        assertEquals(2, m.size());
+        assertThat(m.containsKey("newGraph"), is(true));
+        assertThat(m.get("newGraph"), instanceOf(TinkerGraph.class));
+    }
+}