Split GraphSONIO into reader writer

not an ideal design by itself, but follows the Java API precedence, which has
other requirements


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

Branch: refs/heads/master
Commit: 0e211d6b763df2ee6260759c91b57b57770fc02b
Parents: d296eb7
Author: Adam Holmberg <adam.holmb...@datastax.com>
Authored: Tue Oct 11 14:15:07 2016 -0500
Committer: Adam Holmberg <adam.holmb...@datastax.com>
Committed: Tue Oct 11 14:15:07 2016 -0500

----------------------------------------------------------------------
 .../driver/driver_remote_connection.py          |  17 +-
 .../gremlin_python/structure/io/graphson.py     | 154 +++++++++----------
 .../jython/tests/structure/io/test_graphson.py  | 113 ++++++++------
 .../python/jsr223/JythonScriptEngineSetup.java  |   5 +-
 .../jsr223/PythonGraphSONJavaTranslator.java    |   2 +-
 .../io/graphson/GraphSONReaderTest.java         |  68 ++++----
 .../io/graphson/GraphSONWriterTest.java         |  54 +++----
 7 files changed, 219 insertions(+), 194 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git 
a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
 
b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index 20129e9..eab06f1 100644
--- 
a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ 
b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -23,7 +23,7 @@ from tornado import gen
 from tornado import ioloop
 from tornado import websocket
 
-from gremlin_python.structure.io.graphson import GraphSONIO
+from gremlin_python.structure.io.graphson import GraphSONReader, GraphSONWriter
 from .remote_connection import RemoteConnection
 from .remote_connection import RemoteTraversal
 from .remote_connection import RemoteTraversalSideEffects
@@ -34,14 +34,15 @@ class GremlinServerError(Exception):
 
 
 class DriverRemoteConnection(RemoteConnection):
-    def __init__(self, url, traversal_source, username="", password="", 
loop=None, graphson_io=None):
+    def __init__(self, url, traversal_source, username="", password="", 
loop=None, graphson_reader=None, graphson_writer=None):
         super(DriverRemoteConnection, self).__init__(url, traversal_source)
         self._url = url
         self._username = username
         self._password = password
         if loop is None: self._loop = ioloop.IOLoop.current()
         self._websocket = self._loop.run_sync(lambda: 
websocket.websocket_connect(self.url))
-        self._graphson_io = graphson_io or GraphSONIO()
+        self._graphson_reader = graphson_reader or GraphSONReader()
+        self._graphson_writer = graphson_writer or GraphSONWriter()
 
     def submit(self, bytecode):
         '''
@@ -65,7 +66,7 @@ class DriverRemoteConnection(RemoteConnection):
             "op": "bytecode",
             "processor": "traversal",
             "args": {
-                "gremlin": self._graphson_io.writeObject(bytecode),
+                "gremlin": self._graphson_writer.writeObject(bytecode),
                 "aliases": {"g": self.traversal_source}
             }
         }
@@ -142,7 +143,7 @@ class DriverRemoteConnection(RemoteConnection):
         if self._websocket.protocol is None:
             self._websocket = yield websocket.websocket_connect(self.url)
         self._websocket.write_message(send_message, binary=True)
-        response = Response(self._websocket, self._username, self._password, 
self._graphson_io)
+        response = Response(self._websocket, self._username, self._password, 
self._graphson_reader)
         results = None
         while True:
             recv_message = yield response.receive()
@@ -183,12 +184,12 @@ class DriverRemoteConnection(RemoteConnection):
 
 
 class Response:
-    def __init__(self, websocket, username, password, graphson_io):
+    def __init__(self, websocket, username, password, graphson_reader):
         self._websocket = websocket
         self._username = username
         self._password = password
         self._closed = False
-        self._graphson_io = graphson_io
+        self._graphson_reader = graphson_reader
 
     @gen.coroutine
     def receive(self):
@@ -225,7 +226,7 @@ class Response:
         elif status_code in [200, 206]:
             results = []
             for item in recv_message["result"]["data"]:
-                results.append(self._graphson_io.toObject(item))
+                results.append(self._graphson_reader.toObject(item))
             if status_code == 200:
                 self._closed = True
             raise gen.Return((aggregateTo, results))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
----------------------------------------------------------------------
diff --git 
a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py 
b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
index 50db7cb..45aec9d 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
@@ -16,24 +16,14 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-import json
 from aenum import Enum
-
+import json
 import six
 
 from gremlin_python import statics
 from gremlin_python.statics import FloatType, FunctionType, IntType, LongType, 
TypeType
-from gremlin_python.process.traversal import Binding
-from gremlin_python.process.traversal import Bytecode
-from gremlin_python.process.traversal import P
-from gremlin_python.process.traversal import Traversal
-from gremlin_python.process.traversal import Traverser
-from gremlin_python.process.traversal import TraversalStrategy
-from gremlin_python.structure.graph import Edge
-from gremlin_python.structure.graph import Property
-from gremlin_python.structure.graph import Vertex
-from gremlin_python.structure.graph import VertexProperty
-from gremlin_python.structure.graph import Path
+from gremlin_python.process.traversal import Binding, Bytecode, P, Traversal, 
Traverser, TraversalStrategy
+from gremlin_python.structure.graph import Edge, Property, Vertex, 
VertexProperty, Path
 
 
 _serializers = {}
@@ -51,32 +41,33 @@ class GraphSONTypeType(type):
         return cls
 
 
-class GraphSONIO(object):
+class _GraphSONIO(object):
+    TYPE_KEY = "@type"
+    VALUE_KEY = "@value"
+
+    @classmethod
+    def typedValue(cls, type_name, value, prefix="g"):
+        out = {cls.TYPE_KEY: prefix + ":" + type_name}
+        if value is not None:
+            out[cls.VALUE_KEY] = value
+        return out
 
-    _TYPE_KEY = "@type"
-    _VALUE_KEY = "@value"
 
-    def __init__(self, serializer_map=None, deserializer_map=None):
+# Read/Write classes split to follow precedence of the Java API
+class GraphSONWriter(object):
+
+    def __init__(self, serializer_map=None):
         """
         :param serializer_map: map from Python type to serializer instance 
implementing `dictify`
-        :param deserializer_map: map from GraphSON type tag to deserializer 
instance implementing `objectify`
         """
         self.serializers = _serializers.copy()
         if serializer_map:
             self.serializers.update(serializer_map)
 
-        self.deserializers = _deserializers.copy()
-        if deserializer_map:
-            self.deserializers.update(deserializer_map)
-
     def writeObject(self, objectData):
         # to JSON
         return json.dumps(self.toDict(objectData), separators=(',', ':'))
 
-    def readObject(self, jsonData):
-        # from JSON
-        return self.toObject(json.loads(jsonData))
-
     def toDict(self, obj):
         """
         Encodes python objects in GraphSON type-tagged dict values
@@ -92,13 +83,28 @@ class GraphSONIO(object):
         else:
             return obj
 
+
+class GraphSONReader(object):
+
+    def __init__(self, deserializer_map=None):
+        """
+        :param deserializer_map: map from GraphSON type tag to deserializer 
instance implementing `objectify`
+        """
+        self.deserializers = _deserializers.copy()
+        if deserializer_map:
+            self.deserializers.update(deserializer_map)
+
+    def readObject(self, jsonData):
+        # from JSON
+        return self.toObject(json.loads(jsonData))
+
     def toObject(self, obj):
         """
         Unpacks GraphSON type-tagged dict values into objects mapped in 
self.deserializers
         """
         if isinstance(obj, dict):
             try:
-                return 
self.deserializers[obj[self._TYPE_KEY]].objectify(obj[self._VALUE_KEY], self)
+                return 
self.deserializers[obj[_GraphSONIO.TYPE_KEY]].objectify(obj[_GraphSONIO.VALUE_KEY],
 self)
             except KeyError:
                 pass
             # list and map are treated as normal json objs (could be isolated 
deserializers)
@@ -108,12 +114,6 @@ class GraphSONIO(object):
         else:
             return obj
 
-    def typedValue(self, type_name, value, prefix="g"):
-        out = {self._TYPE_KEY: prefix + ":" + type_name}
-        if value is not None:
-            out[self._VALUE_KEY] = value
-        return out
-
 
 @six.add_metaclass(GraphSONTypeType)
 class _GraphSONTypeIO(object):
@@ -128,34 +128,34 @@ class _GraphSONTypeIO(object):
     def unmangleKeyword(cls, symbol):
         return cls.symbolMap.get(symbol, symbol)
 
-    def dictify(self, obj, graphson_io):
+    def dictify(self, obj, writer):
         raise NotImplementedError()
 
-    def objectify(self, d, graphson_io):
+    def objectify(self, d, reader):
         raise NotImplementedError()
 
 
 class _BytecodeSerializer(_GraphSONTypeIO):
 
     @classmethod
-    def _dictify_instructions(cls, instructions, graphson_io):
+    def _dictify_instructions(cls, instructions, writer):
         out = []
         for instruction in instructions:
             inst = [instruction[0]]
-            inst.extend(graphson_io.toDict(arg) for arg in instruction[1:])
+            inst.extend(writer.toDict(arg) for arg in instruction[1:])
             out.append(inst)
         return out
 
     @classmethod
-    def dictify(cls, bytecode, graphson_io):
+    def dictify(cls, bytecode, writer):
         if isinstance(bytecode, Traversal):
             bytecode = bytecode.bytecode
         out = {}
         if bytecode.source_instructions:
-            out["source"] = 
cls._dictify_instructions(bytecode.source_instructions, graphson_io)
+            out["source"] = 
cls._dictify_instructions(bytecode.source_instructions, writer)
         if bytecode.step_instructions:
-            out["step"] = 
cls._dictify_instructions(bytecode.step_instructions, graphson_io)
-        return graphson_io.typedValue("Bytecode", out)
+            out["step"] = 
cls._dictify_instructions(bytecode.step_instructions, writer)
+        return _GraphSONIO.typedValue("Bytecode", out)
 
 
 class TraversalSerializer(_BytecodeSerializer):
@@ -170,8 +170,8 @@ class TraversalStrategySerializer(_GraphSONTypeIO):
     python_type = TraversalStrategy
 
     @classmethod
-    def dictify(cls, strategy, graphson_io):
-        return graphson_io.typedValue(strategy.strategy_name, 
graphson_io.toDict(strategy.configuration))
+    def dictify(cls, strategy, writer):
+        return _GraphSONIO.typedValue(strategy.strategy_name, 
writer.toDict(strategy.configuration))
 
 
 class TraverserIO(_GraphSONTypeIO):
@@ -179,22 +179,22 @@ class TraverserIO(_GraphSONTypeIO):
     graphson_type = "g:Traverser"
 
     @classmethod
-    def dictify(cls, traverser, graphson_io):
-        return graphson_io.typedValue("Traverser", {"value": 
graphson_io.toDict(traverser.object),
-                                                     "bulk": 
graphson_io.toDict(traverser.bulk)})
+    def dictify(cls, traverser, writer):
+        return _GraphSONIO.typedValue("Traverser", {"value": 
writer.toDict(traverser.object),
+                                                     "bulk": 
writer.toDict(traverser.bulk)})
 
     @classmethod
-    def objectify(cls, d, graphson_io):
-        return Traverser(graphson_io.toObject(d["value"]),
-                         graphson_io.toObject(d["bulk"]))
+    def objectify(cls, d, reader):
+        return Traverser(reader.toObject(d["value"]),
+                         reader.toObject(d["bulk"]))
 
 
 class EnumSerializer(_GraphSONTypeIO):
     python_type = Enum
 
     @classmethod
-    def dictify(cls, enum, graphson_io):
-        return graphson_io.typedValue(cls.unmangleKeyword(type(enum).__name__),
+    def dictify(cls, enum, _):
+        return _GraphSONIO.typedValue(cls.unmangleKeyword(type(enum).__name__),
                                       cls.unmangleKeyword(str(enum.name)))
 
 
@@ -202,28 +202,28 @@ class PSerializer(_GraphSONTypeIO):
     python_type = P
 
     @classmethod
-    def dictify(cls, p, graphson_io):
+    def dictify(cls, p, writer):
         out = {"predicate": p.operator,
-               "value": [graphson_io.toDict(p.value), 
graphson_io.toDict(p.other)] if p.other is not None else
-                        graphson_io.toDict(p.value)}
-        return graphson_io.typedValue("P", out)
+               "value": [writer.toDict(p.value), writer.toDict(p.other)] if 
p.other is not None else
+                        writer.toDict(p.value)}
+        return _GraphSONIO.typedValue("P", out)
 
 
 class BindingSerializer(_GraphSONTypeIO):
     python_type = Binding
 
     @classmethod
-    def dictify(cls, binding, graphson_io):
+    def dictify(cls, binding, writer):
         out = {"key": binding.key,
-               "value": graphson_io.toDict(binding.value)}
-        return graphson_io.typedValue("Binding", out)
+               "value": writer.toDict(binding.value)}
+        return _GraphSONIO.typedValue("Binding", out)
 
 
 class LambdaSerializer(_GraphSONTypeIO):
     python_type = FunctionType
 
     @classmethod
-    def dictify(cls, lambda_object, graphson_io):
+    def dictify(cls, lambda_object, writer):
         lambda_result = lambda_object()
         script = lambda_result if isinstance(lambda_result, str) else 
lambda_result[0]
         language = statics.default_lambda_language if 
isinstance(lambda_result, str) else lambda_result[1]
@@ -236,24 +236,24 @@ class LambdaSerializer(_GraphSONTypeIO):
             out["arguments"] = 
six.get_function_code(eval(out["script"])).co_argcount
         else:
             out["arguments"] = -1
-        return graphson_io.typedValue("Lambda", out)
+        return _GraphSONIO.typedValue("Lambda", out)
 
 
 class TypeSerializer(_GraphSONTypeIO):
     python_type = TypeType
 
     @classmethod
-    def dictify(cls, typ, graphson_io):
-        return graphson_io.toDict(typ())
+    def dictify(cls, typ, writer):
+        return writer.toDict(typ())
 
 
 class _NumberIO(_GraphSONTypeIO):
 
     @classmethod
-    def dictify(cls, n, graphson_io):
+    def dictify(cls, n, writer):
         if isinstance(n, bool):  # because isinstance(False, int) and 
isinstance(True, int)
             return n
-        return graphson_io.typedValue(cls.graphson_base_type, n)
+        return _GraphSONIO.typedValue(cls.graphson_base_type, n)
 
     @classmethod
     def objectify(cls, v, _):
@@ -287,43 +287,43 @@ class VertexDeserializer(_GraphSONTypeIO):
     graphson_type = "g:Vertex"
 
     @classmethod
-    def objectify(cls, d, graphson_io):
-        return Vertex(graphson_io.toObject(d["id"]), d.get("label", ""))
+    def objectify(cls, d, reader):
+        return Vertex(reader.toObject(d["id"]), d.get("label", ""))
 
 
 class EdgeDeserializer(_GraphSONTypeIO):
     graphson_type = "g:Edge"
 
     @classmethod
-    def objectify(cls, d, graphson_io):
-        return Edge(graphson_io.toObject(d["id"]),
-                    Vertex(graphson_io.toObject(d["outV"]), ""),
+    def objectify(cls, d, reader):
+        return Edge(reader.toObject(d["id"]),
+                    Vertex(reader.toObject(d["outV"]), ""),
                     d.get("label", "vertex"),
-                    Vertex(graphson_io.toObject(d["inV"]), ""))
+                    Vertex(reader.toObject(d["inV"]), ""))
 
 
 class VertexPropertyDeserializer(_GraphSONTypeIO):
     graphson_type = "g:VertexProperty"
 
     @classmethod
-    def objectify(cls, d, graphson_io):
-        return VertexProperty(graphson_io.toObject(d["id"]), d["label"],
-                              graphson_io.toObject(d["value"]))
+    def objectify(cls, d, reader):
+        return VertexProperty(reader.toObject(d["id"]), d["label"],
+                              reader.toObject(d["value"]))
 
 
 class PropertyDeserializer(_GraphSONTypeIO):
     graphson_type = "g:Property"
 
     @classmethod
-    def objectify(cls, d, graphson_io):
-        return Property(d["key"], graphson_io.toObject(d["value"]))
+    def objectify(cls, d, reader):
+        return Property(d["key"], reader.toObject(d["value"]))
 
 
 class PathDeserializer(_GraphSONTypeIO):
     graphson_type = "g:Path"
 
     @classmethod
-    def objectify(cls, d, graphson_io):
+    def objectify(cls, d, reader):
         labels = [set(label) for label in d["labels"]]
-        objects = [graphson_io.toObject(o) for o in d["objects"]]
+        objects = [reader.toObject(o) for o in d["objects"]]
         return Path(labels, objects)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py 
b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
index 90866aa..a192cd2 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
@@ -29,39 +29,39 @@ import six
 from gremlin_python.statics import *
 from gremlin_python.structure.graph import Vertex
 from gremlin_python.structure.graph import Path
-from gremlin_python.structure.io.graphson import GraphSONIO
+from gremlin_python.structure.io.graphson import GraphSONWriter, 
GraphSONReader, _GraphSONIO
 import gremlin_python.structure.io.graphson
 from gremlin_python.process.traversal import P
 from gremlin_python.process.strategies import SubgraphStrategy
 from gremlin_python.process.graph_traversal import __
 
-graphson_io = GraphSONIO()
 
+class TestGraphSONReader(TestCase):
+    graphson_reader = GraphSONReader()
 
-class TestGraphSONIO(TestCase):
     def test_number_input(self):
-        x = graphson_io.readObject(json.dumps({
+        x = self.graphson_reader.readObject(json.dumps({
             "@type": "g:Int32",
             "@value": 31
         }))
         assert isinstance(x, int)
         assert 31 == x
         ##
-        x = graphson_io.readObject(json.dumps({
+        x = self.graphson_reader.readObject(json.dumps({
             "@type": "g:Int64",
             "@value": 31
         }))
         assert isinstance(x, long)
         assert long(31) == x
         ##
-        x = graphson_io.readObject(json.dumps({
+        x = self.graphson_reader.readObject(json.dumps({
             "@type": "g:Float",
             "@value": 31.3
         }))
         assert isinstance(x, float)
         assert 31.3 == x
         ##
-        x = graphson_io.readObject(json.dumps({
+        x = self.graphson_reader.readObject(json.dumps({
             "@type": "g:Double",
             "@value": 31.2
         }))
@@ -69,7 +69,7 @@ class TestGraphSONIO(TestCase):
         assert 31.2 == x
 
     def test_graph(self):
-        vertex = graphson_io.readObject(
+        vertex = self.graphson_reader.readObject(
             """{"@type":"g:Vertex", 
"@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9},"inV":{"@type":"g:Int32","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int32","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int32","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}}""")
         assert isinstance(vertex, Vertex)
         assert "person" == vertex.label
@@ -78,7 +78,7 @@ class TestGraphSONIO(TestCase):
         assert vertex == Vertex(1)
 
     def test_path(self):
-        path = graphson_io.readObject(
+        path = self.graphson_reader.readObject(
             
"""{"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},"lop"]}}"""
         )
         assert isinstance(path, Path)
@@ -91,28 +91,65 @@ class TestGraphSONIO(TestCase):
         assert "lop" == path[2]
         assert 3 == len(path)
 
+    def test_custom_mapping(self):
+
+        # extended mapping
+        class X(object):
+            pass
+
+        type_string = "test:Xtype"
+        override_string = "g:Int64"
+        serdes = Mock()
+
+        reader = GraphSONReader(deserializer_map={type_string: serdes})
+        assert type_string in reader.deserializers
+
+        # base dicts are not modified
+        assert type_string not in 
gremlin_python.structure.io.graphson._deserializers
+
+        x = X()
+        o = reader.toObject({_GraphSONIO.TYPE_KEY: type_string, 
_GraphSONIO.VALUE_KEY: x})
+        serdes.objectify.assert_called_once_with(x, reader)
+        assert o is serdes.objectify()
+
+        # overridden mapping
+        type_string = "g:Int64"
+        serdes = Mock()
+        reader = GraphSONReader(deserializer_map={type_string: serdes, 
override_string: serdes})
+        assert 
gremlin_python.structure.io.graphson._deserializers[type_string] is not 
reader.deserializers[type_string]
+
+        value = 3
+        o = reader.toObject({_GraphSONIO.TYPE_KEY: type_string, 
_GraphSONIO.VALUE_KEY: value})
+        serdes.objectify.assert_called_once_with(value, reader)
+        assert o is serdes.objectify()
+
+
+class TestGraphSONWriter(TestCase):
+
+    graphson_writer = GraphSONWriter()
+
     def test_number_output(self):
-        assert {"@type":"g:Int64","@value":2} == 
json.loads(graphson_io.writeObject(long(2)))
-        assert {"@type":"g:Int32","@value":1} == 
json.loads(graphson_io.writeObject(1))
-        assert {"@type":"g:Double","@value":3.2} == 
json.loads(graphson_io.writeObject(3.2))
-        assert """true""" == graphson_io.writeObject(True)
+        assert {"@type":"g:Int64","@value":2} == 
json.loads(self.graphson_writer.writeObject(long(2)))
+        assert {"@type":"g:Int32","@value":1} == 
json.loads(self.graphson_writer.writeObject(1))
+        assert {"@type":"g:Double","@value":3.2} == 
json.loads(self.graphson_writer.writeObject(3.2))
+        assert """true""" == self.graphson_writer.writeObject(True)
 
     def test_numbers(self):
-        assert {"@type": "g:Int64", "@value": 2} == 
json.loads(graphson_io.writeObject(long(2)))
-        assert {"@type": "g:Int32", "@value": 1} == 
json.loads(graphson_io.writeObject(1))
-        assert {"@type": "g:Double", "@value": 3.2} == 
json.loads(graphson_io.writeObject(3.2))
-        assert """true""" == graphson_io.writeObject(True)
+        assert {"@type": "g:Int64", "@value": 2} == 
json.loads(self.graphson_writer.writeObject(long(2)))
+        assert {"@type": "g:Int32", "@value": 1} == 
json.loads(self.graphson_writer.writeObject(1))
+        assert {"@type": "g:Double", "@value": 3.2} == 
json.loads(self.graphson_writer.writeObject(3.2))
+        assert """true""" == self.graphson_writer.writeObject(True)
 
     def test_P(self):
-        assert 
"""{"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}}"""
 == graphson_io.writeObject(
+        assert 
"""{"@type":"g:P","@value":{"predicate":"and","value":[{"@type":"g:P","@value":{"predicate":"or","value":[{"@type":"g:P","@value":{"predicate":"lt","value":"b"}},{"@type":"g:P","@value":{"predicate":"gt","value":"c"}}]}},{"@type":"g:P","@value":{"predicate":"neq","value":"d"}}]}}"""
 == self.graphson_writer.writeObject(
             P.lt("b").or_(P.gt("c")).and_(P.neq("d")))
 
     def test_strategies(self):
         # we have a proxy model for now given that we don't want to have to 
have g:XXX all registered on the Gremlin traversal machine (yet)
-        assert {"@type": "g:SubgraphStrategy", "@value": {}} == 
json.loads(graphson_io.writeObject(SubgraphStrategy))
+        assert {"@type": "g:SubgraphStrategy", "@value": {}} == 
json.loads(self.graphson_writer.writeObject(SubgraphStrategy))
         assert {"@type": "g:SubgraphStrategy", "@value": {
             "vertices": {"@type": "g:Bytecode", "@value": {"step": [["has", 
"name", "marko"]]}}}} == json.loads(
-            graphson_io.writeObject(SubgraphStrategy(vertices=__.has("name", 
"marko"))))
+            
self.graphson_writer.writeObject(SubgraphStrategy(vertices=__.has("name", 
"marko"))))
 
     def test_custom_mapping(self):
 
@@ -120,42 +157,28 @@ class TestGraphSONIO(TestCase):
         class X(object):
             pass
 
-        type_string = "test:Xtype"
-        override_string = "g:Int64"
         serdes = Mock()
-
-        gio = GraphSONIO(serializer_map={X: serdes}, 
deserializer_map={type_string: serdes, })
-        self.assertIn(X, gio.serializers)
-        self.assertIn(type_string, gio.deserializers)
+        writer = GraphSONWriter(serializer_map={X: serdes})
+        assert X in writer.serializers
 
         # base dicts are not modified
-        self.assertNotIn(X, gremlin_python.structure.io.graphson._serializers)
-        self.assertNotIn(type_string, 
gremlin_python.structure.io.graphson._deserializers)
+        assert X not in gremlin_python.structure.io.graphson._serializers
 
         obj = X()
-        d = gio.toDict(obj)
-        serdes.dictify.assert_called_once_with(obj, gio)
-        self.assertIs(d, serdes.dictify())
-
-        o = gio.toObject({GraphSONIO._TYPE_KEY: type_string, 
GraphSONIO._VALUE_KEY: obj})
-        serdes.objectify.assert_called_once_with(obj, gio)
-        self.assertIs(o, serdes.objectify())
+        d = writer.toDict(obj)
+        serdes.dictify.assert_called_once_with(obj, writer)
+        assert d is serdes.dictify()
 
         # overridden mapping
-        type_string = "g:Int64"
         serdes = Mock()
-        gio = GraphSONIO(serializer_map={int: serdes}, 
deserializer_map={type_string: serdes, override_string: serdes})
-        
self.assertIsNot(gremlin_python.structure.io.graphson._serializers[int], 
gio.serializers[int])
-        
self.assertIsNot(gremlin_python.structure.io.graphson._deserializers[type_string],
 gio.deserializers[type_string])
+        writer = GraphSONWriter(serializer_map={int: serdes})
+        assert gremlin_python.structure.io.graphson._serializers[int] is not 
writer.serializers[int]
 
         value = 3
-        d = gio.toDict(value)
-        serdes.dictify.assert_called_once_with(value, gio)
-        self.assertIs(d, serdes.dictify())
+        d = writer.toDict(value)
+        serdes.dictify.assert_called_once_with(value, writer)
+        assert d is serdes.dictify()
 
-        o = gio.toObject({GraphSONIO._TYPE_KEY: type_string, 
GraphSONIO._VALUE_KEY: value})
-        serdes.objectify.assert_called_once_with(value, gio)
-        self.assertIs(o, serdes.objectify())
 
 if __name__ == '__main__':
     unittest.main()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
----------------------------------------------------------------------
diff --git 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
index d5305dc..a16ce30 100644
--- 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
+++ 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/JythonScriptEngineSetup.java
@@ -49,8 +49,9 @@ public class JythonScriptEngineSetup {
             jythonEngine.eval("from gremlin_python.structure.graph import 
Edge");
             jythonEngine.eval("from gremlin_python.structure.graph import 
VertexProperty");
             jythonEngine.eval("from gremlin_python.structure.graph import 
Property");
-            jythonEngine.eval("from gremlin_python.structure.io.graphson 
import GraphSONIO");
-            jythonEngine.eval("graphson_io = GraphSONIO()");
+            jythonEngine.eval("from gremlin_python.structure.io.graphson 
import GraphSONReader, GraphSONWriter");
+            jythonEngine.eval("graphson_reader = GraphSONReader()");
+            jythonEngine.eval("graphson_writer = GraphSONWriter()");
             return jythonEngine;
         } catch (final ScriptException e) {
             throw new IllegalStateException(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
----------------------------------------------------------------------
diff --git 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
index e57afd2..cdeb407 100644
--- 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
+++ 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
@@ -69,7 +69,7 @@ final class PythonGraphSONJavaTranslator<S extends 
TraversalSource, T extends Tr
             
bindings.putAll(jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE));
             bindings.put(this.pythonTranslator.getTraversalSource(), 
jythonEngine.eval("Graph().traversal()"));
             bindings.putAll(bytecode.getBindings());
-            final String graphsonBytecode = 
jythonEngine.eval("graphson_io.writeObject(" + 
this.pythonTranslator.translate(bytecode) + ")", bindings).toString();
+            final String graphsonBytecode = 
jythonEngine.eval("graphson_writer.writeObject(" + 
this.pythonTranslator.translate(bytecode) + ")", bindings).toString();
             // System.out.println(graphsonBytecode);
             return this.javaTranslator.translate(this.reader.readObject(new 
ByteArrayInputStream(graphsonBytecode.getBytes()), Bytecode.class));
         } catch (final Exception e) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONReaderTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONReaderTest.java
 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONReaderTest.java
index 7bbf364..86bdd21 100644
--- 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONReaderTest.java
+++ 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONReaderTest.java
@@ -60,49 +60,49 @@ public class GraphSONReaderTest {
     public void shouldDeserializeGraphObjects() throws Exception {
         final Vertex vertex = g.V(1).next();
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(vertex));
-        assertEquals(vertex.toString(), 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),Vertex)"));
+        assertEquals(vertex.toString(), 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),Vertex)"));
         //
         final Edge edge = g.V(1).outE("created").next();
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(edge));
-        assertEquals(edge.toString(), 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),Edge)"));
+        assertEquals(edge.toString(), 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),Edge)"));
         //
         final VertexProperty vertexProperty = (VertexProperty) 
g.V(1).properties("name").next();
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(vertexProperty));
-        assertEquals(vertexProperty.toString(), 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),VertexProperty)"));
+        assertEquals(vertexProperty.toString(), 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),VertexProperty)"));
         //
         final Property property = 
g.V(1).outE("created").properties("weight").next();
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(property));
-        assertEquals(property.toString(), 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),Property)"));
+        assertEquals(property.toString(), 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),Property)"));
         //
         final Traverser<Vertex> traverser = new 
DefaultRemoteTraverser<>(vertex, 3L);
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(traverser));
-        assertEquals(traverser.toString(), 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertEquals(BigInteger.valueOf(3L), 
jythonEngine.eval("graphson_io.readObject(x).bulk")); // jython uses big 
integer in Java
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x).object,Vertex)"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),Traverser)"));
+        assertEquals(traverser.toString(), 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertEquals(BigInteger.valueOf(3L), 
jythonEngine.eval("graphson_reader.readObject(x).bulk")); // jython uses big 
integer in Java
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x).object,Vertex)"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),Traverser)"));
     }
 
     @Test
     public void shouldDeserializeNumbers() throws Exception {
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(1));
-        assertEquals("1", jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),int)"));
+        assertEquals("1", 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),int)"));
         //
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(1L));
-        assertEquals("1", jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),long)"));
+        assertEquals("1", 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),long)"));
         //
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(1.2f));
-        assertEquals("1.2", 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),float)"));
+        assertEquals("1.2", 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),float)"));
         //
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(1.3d));
-        assertEquals("1.3", 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x),float)"));
+        assertEquals("1.3", 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x),float)"));
     }
 
     @Test
@@ -111,23 +111,23 @@ public class GraphSONReaderTest {
         map.put("a", 2);
         map.put("b", 2.3d);
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(map));
-        assertEquals("{u'a': 2, u'b': 2.3}", 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertEquals(2, jythonEngine.eval("graphson_io.readObject(x)['a']"));
-        assertEquals(2.3d, 
jythonEngine.eval("graphson_io.readObject(x)['b']")); // jython is smart about 
double
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x)['a'],int)"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x)['b'],float)"));
+        assertEquals("{u'a': 2, u'b': 2.3}", 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertEquals(2, 
jythonEngine.eval("graphson_reader.readObject(x)['a']"));
+        assertEquals(2.3d, 
jythonEngine.eval("graphson_reader.readObject(x)['b']")); // jython is smart 
about double
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x)['a'],int)"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x)['b'],float)"));
         //
         final List<Object> list = Arrays.asList(g.V(1).next(), "hello", map, 
true);
         jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", 
mapper.writeValueAsString(list));
-        assertEquals("[v[1], u'hello', {u'a': 2, u'b': 2.3}, True]", 
jythonEngine.eval("str(graphson_io.readObject(x))"));
-        assertEquals(g.V(1).next().toString(), 
jythonEngine.eval("str(graphson_io.readObject(x)[0])"));
-        assertEquals("hello", 
jythonEngine.eval("graphson_io.readObject(x)[1]"));
-        assertEquals("{u'a': 2, u'b': 2.3}", 
jythonEngine.eval("str(graphson_io.readObject(x)[2])"));
-        assertTrue((Boolean) 
jythonEngine.eval("graphson_io.readObject(x)[3]"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x)[0],Vertex)"));
-        // assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x)[1],str)")); // its 
python unicode jython object
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x)[2],dict)"));
-        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_io.readObject(x)[3],bool)"));
+        assertEquals("[v[1], u'hello', {u'a': 2, u'b': 2.3}, True]", 
jythonEngine.eval("str(graphson_reader.readObject(x))"));
+        assertEquals(g.V(1).next().toString(), 
jythonEngine.eval("str(graphson_reader.readObject(x)[0])"));
+        assertEquals("hello", 
jythonEngine.eval("graphson_reader.readObject(x)[1]"));
+        assertEquals("{u'a': 2, u'b': 2.3}", 
jythonEngine.eval("str(graphson_reader.readObject(x)[2])"));
+        assertTrue((Boolean) 
jythonEngine.eval("graphson_reader.readObject(x)[3]"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x)[0],Vertex)"));
+        // assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x)[1],str)")); // its 
python unicode jython object
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x)[2],dict)"));
+        assertTrue((Boolean) 
jythonEngine.eval("isinstance(graphson_reader.readObject(x)[3],bool)"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e211d6b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONWriterTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONWriterTest.java
 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONWriterTest.java
index 01e8c23..58211c6 100644
--- 
a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONWriterTest.java
+++ 
b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/structure/io/graphson/GraphSONWriterTest.java
@@ -56,14 +56,14 @@ public class GraphSONWriterTest {
 
     @Test
     public void shouldSerializeNumbers() throws Exception {
-        assertEquals(1, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(1)").toString(), 
Object.class));
-        assertEquals(mapper.writeValueAsString(1), 
jythonEngine.eval("graphson_io.writeObject(1)").toString().replace(" ", ""));
+        assertEquals(1, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(1)").toString(),
 Object.class));
+        assertEquals(mapper.writeValueAsString(1), 
jythonEngine.eval("graphson_writer.writeObject(1)").toString().replace(" ", 
""));
         //
-        assertEquals(2L, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(2L)").toString(), 
Object.class));
-        assertEquals(mapper.writeValueAsString(2L), 
jythonEngine.eval("graphson_io.writeObject(2L)").toString().replace(" ", ""));
+        assertEquals(2L, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(2L)").toString(),
 Object.class));
+        assertEquals(mapper.writeValueAsString(2L), 
jythonEngine.eval("graphson_writer.writeObject(2L)").toString().replace(" ", 
""));
         //
-        assertEquals(3.4, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(3.4)").toString(), 
Object.class));
-        assertEquals(mapper.writeValueAsString(3.4), 
jythonEngine.eval("graphson_io.writeObject(3.4)").toString().replace(" ", ""));
+        assertEquals(3.4, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(3.4)").toString(),
 Object.class));
+        assertEquals(mapper.writeValueAsString(3.4), 
jythonEngine.eval("graphson_writer.writeObject(3.4)").toString().replace(" ", 
""));
     }
 
     @Test
@@ -71,60 +71,60 @@ public class GraphSONWriterTest {
         final Map<String, Number> map = new LinkedHashMap<>();
         map.put("a", 2);
         map.put("b", 2.3);
-        assertEquals(map, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject({'a':2,'b':2.3})").toString(),
 Object.class));
+        assertEquals(map, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject({'a':2,'b':2.3})").toString(),
 Object.class));
         //
         final List<Object> list = Arrays.asList(new 
DefaultRemoteTraverser<>("hello", 3L), "hello", map, true);
         assertTrue((Boolean) 
jythonEngine.eval("isinstance([Traverser('hello',3L),'hello',{'a':2,'b':2.3},True],list)"));
-        assertEquals(list, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject([Traverser('hello',3L),'hello',{'a':2,'b':2.3},True])").toString(),
 Object.class));
+        assertEquals(list, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject([Traverser('hello',3L),'hello',{'a':2,'b':2.3},True])").toString(),
 Object.class));
     }
 
     @Test
     public void shouldSerializeTraverser() throws Exception {
         assertEquals(
                 new DefaultRemoteTraverser<>("hello", 3L),
-                
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Traverser('hello',3L))").toString(),
 Object.class));
-        assertEquals(3L, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Traverser('hello',3L))").toString(),
 Traverser.class).bulk());
-        assertEquals("hello", 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Traverser('hello',3L))").toString(),
 Traverser.class).get());
+                
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Traverser('hello',3L))").toString(),
 Object.class));
+        assertEquals(3L, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Traverser('hello',3L))").toString(),
 Traverser.class).bulk());
+        assertEquals("hello", 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Traverser('hello',3L))").toString(),
 Traverser.class).get());
     }
 
     @Test
     public void shouldSerializeBytecode() throws Exception {
-        assertEquals(P.eq(7L), 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(P.eq(7L))").toString(),
 Object.class));
-        // TODO: assertEquals(mapper.writeValueAsString(P.between(1, 
2).and(P.eq(7L))), 
jythonEngine.eval("graphson_io.writeObject(P.eq(7L)._and(P.between(1,2)))").toString().replace("
 ",""));
-        assertEquals(AndP.class, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(P.eq(7L).and_(P.between(1,2)))").toString(),
 Object.class).getClass());
+        assertEquals(P.eq(7L), 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(P.eq(7L))").toString(),
 Object.class));
+        // TODO: assertEquals(mapper.writeValueAsString(P.between(1, 
2).and(P.eq(7L))), 
jythonEngine.eval("graphson_writer.writeObject(P.eq(7L)._and(P.between(1,2)))").toString().replace("
 ",""));
+        assertEquals(AndP.class, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(P.eq(7L).and_(P.between(1,2)))").toString(),
 Object.class).getClass());
         //
-        assertEquals(new Bytecode.Binding<>("a", 5L), 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Binding('a',5L))").toString(),
 Object.class));
+        assertEquals(new Bytecode.Binding<>("a", 5L), 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Binding('a',5L))").toString(),
 Object.class));
         //
         for (final Column t : Column.values()) {
-            assertEquals(t, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Column." + t.name() 
+ ")").toString(), Object.class));
+            assertEquals(t, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Column." + 
t.name() + ")").toString(), Object.class));
         }
         for (final T t : T.values()) {
-            assertEquals(t, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(T." + t.name() + 
")").toString(), Object.class));
+            assertEquals(t, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(T." + t.name() 
+ ")").toString(), Object.class));
         }
-        assertEquals(Pop.first, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Pop.first)").toString(),
 Object.class));
-        assertEquals(Pop.last, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Pop.last)").toString(),
 Object.class));
-        assertEquals(Pop.all, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Pop.all_)").toString(),
 Object.class));
-        assertEquals(Scope.global, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Scope.global_)").toString(),
 Object.class));
-        assertEquals(Scope.local, 
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(Scope.local)").toString(),
 Object.class));
+        assertEquals(Pop.first, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Pop.first)").toString(),
 Object.class));
+        assertEquals(Pop.last, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Pop.last)").toString(),
 Object.class));
+        assertEquals(Pop.all, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Pop.all_)").toString(),
 Object.class));
+        assertEquals(Scope.global, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Scope.global_)").toString(),
 Object.class));
+        assertEquals(Scope.local, 
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(Scope.local)").toString(),
 Object.class));
     }
 
     @Test
     public void shouldSerializeLambda() throws Exception {
         assertEquals(
                 Lambda.function("lambda z : 1+2", "gremlin-python"),
-                
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(lambda : 'z : 
1+2')").toString(), Object.class));
+                
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 'z : 
1+2')").toString(), Object.class));
         assertEquals(
                 Lambda.function("lambda z : z+ 7", "gremlin-python"),
-                
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(lambda : 'lambda z 
: z+ 7')").toString(), Object.class));
+                
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 
'lambda z : z+ 7')").toString(), Object.class));
         assertEquals(
                 Lambda.supplier("lambda : 23", "gremlin-python"),
-                
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(lambda : 'lambda : 
23')").toString(), Object.class));
+                
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 
'lambda : 23')").toString(), Object.class));
         assertEquals(
                 Lambda.consumer("lambda z : z + 23", "gremlin-python"),
-                
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(lambda : 'lambda z 
: z + 23')").toString(), Object.class));
+                
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 
'lambda z : z + 23')").toString(), Object.class));
         assertEquals(
                 Lambda.biFunction("lambda z,y : z - y + 2", "gremlin-python"),
-                
mapper.readValue(jythonEngine.eval("graphson_io.writeObject(lambda : 'lambda 
z,y : z - y + 2')").toString(), Object.class));
+                
mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 
'lambda z,y : z - y + 2')").toString(), Object.class));
     }
 
 }

Reply via email to