tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [2/3] tinkerpop git commit: TINKERPOP-1698 Folded Gryo lite tests into main gryo tests
Date Mon, 26 Jun 2017 17:25:45 GMT
TINKERPOP-1698 Folded Gryo lite tests into main gryo tests


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

Branch: refs/heads/TINKERPOP-1698
Commit: 955ade6876d32b4ac0b848593d17934ff33776cc
Parents: 1c0aec7
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Mon Jun 26 11:28:29 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Mon Jun 26 11:28:29 2017 -0400

----------------------------------------------------------------------
 .../ser/GryoLiteMessageSerializerV1d0Test.java  | 150 -------------------
 .../ser/GryoMessageSerializerV1d0Test.java      | 120 +++++++++------
 2 files changed, 78 insertions(+), 192 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/955ade68/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
deleted file mode 100644
index 2a23d02..0000000
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
+++ /dev/null
@@ -1,150 +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.driver.ser;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.UnpooledByteBufAllocator;
-import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Serializer tests that cover non-lossy serialization/deserialization methods.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class GryoLiteMessageSerializerV1d0Test {
-    private static final Map<String, Object> config = new HashMap<String, Object>()
{{
-        put(AbstractGryoMessageSerializerV1d0.TOKEN_SERIALIZE_RESULT_TO_STRING, true);
-    }};
-
-    private UUID requestId = UUID.fromString("6457272A-4018-4538-B9AE-08DD5DDC0AA1");
-    private ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(requestId);
-    private static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
-
-    public MessageSerializer binarySerializer = new GryoLiteMessageSerializerV1d0();
-
-    @Test
-    public void shouldSerializeEdge() throws Exception {
-        final Graph g = TinkerGraph.open();
-        final Vertex v1 = g.addVertex();
-        final Vertex v2 = g.addVertex();
-        final Edge e = v1.addEdge("test", v2);
-        e.property("abc", 123);
-
-        final Iterable<Edge> iterable = IteratorUtils.list(g.edges());
-
-        final ResponseMessage response = convertBinary(iterable);
-        assertCommon(response);
-
-        final List<ReferenceEdge> edgeList = (List<ReferenceEdge>) response.getResult().getData();
-        assertEquals(1, edgeList.size());
-
-        final ReferenceEdge deserializedEdge = edgeList.get(0);
-        assertEquals(e.id(), deserializedEdge.id());
-        assertEquals("test", deserializedEdge.label());
-
-        assertEquals(0, IteratorUtils.count(deserializedEdge.properties()));
-        assertEquals(v1.id(), deserializedEdge.outVertex().id());
-        assertEquals("", deserializedEdge.outVertex().label());
-        assertEquals(v2.id(), deserializedEdge.inVertex().id());
-        assertEquals("", deserializedEdge.inVertex().label());
-    }
-
-    @Test
-    public void shouldSerializeVertexWithEmbeddedMap() throws Exception {
-        final Graph g = TinkerGraph.open();
-        final Vertex v = g.addVertex();
-        final Map<String, Object> map = new HashMap<>();
-        map.put("x", 500);
-        map.put("y", "some");
-
-        final ArrayList<Object> friends = new ArrayList<>();
-        friends.add("x");
-        friends.add(5);
-        friends.add(map);
-
-        v.property(VertexProperty.Cardinality.single, "friends", friends);
-
-        final List list = IteratorUtils.list(g.vertices());
-
-        final ResponseMessage response = convertBinary(list);
-        assertCommon(response);
-
-        final List<ReferenceVertex> vertexList = (List<ReferenceVertex>) response.getResult().getData();
-        assertEquals(1, vertexList.size());
-
-        final ReferenceVertex deserializedVertex = vertexList.get(0);
-        assertEquals(0L, deserializedVertex.id());
-        assertEquals("", deserializedVertex.label());
-
-        assertEquals(0, IteratorUtils.count(deserializedVertex.properties()));
-    }
-
-    @Test
-    public void shouldSerializeToMapWithElementForKey() throws Exception {
-        final TinkerGraph graph = TinkerFactory.createClassic();
-        final GraphTraversalSource g = graph.traversal();
-        final Map<Vertex, Integer> map = new HashMap<>();
-        map.put(g.V().has("name", "marko").next(), 1000);
-
-        final ResponseMessage response = convertBinary(map);
-        assertCommon(response);
-
-        final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>) response.getResult().getData();
-        assertEquals(1, deserializedMap.size());
-
-        final Vertex deserializedMarko = deserializedMap.keySet().iterator().next();
-        assertEquals(0, IteratorUtils.count(deserializedMarko.properties()));
-        assertEquals(1, deserializedMarko.id());
-        assertEquals("", deserializedMarko.label());
-
-        assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
-    }
-
-    private void assertCommon(final ResponseMessage response) {
-        assertEquals(requestId, response.getRequestId());
-        assertEquals(ResponseStatusCode.SUCCESS, response.getStatus().getCode());
-    }
-
-    private ResponseMessage convertBinary(final Object toSerialize) throws SerializationException
{
-        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(),
allocator);
-        return binarySerializer.deserializeResponse(bb);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/955ade68/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
index 9472033..29ca9ea 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
@@ -37,6 +37,8 @@ import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolverV1d0;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -57,6 +59,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.function.Supplier;
@@ -514,8 +517,6 @@ public class GryoMessageSerializerV1d0Test {
 
     @Test
     public void shouldSerializeEdge() throws Exception {
-        assumeThat(name, not(containsString("V1d0Lite")));
-
         final Graph g = TinkerGraph.open();
         final Vertex v1 = g.addVertex();
         final Vertex v2 = g.addVertex();
@@ -527,25 +528,39 @@ public class GryoMessageSerializerV1d0Test {
         final ResponseMessage response = convertBinary(iterable);
         assertCommon(response);
 
-        final java.util.List<DetachedEdge> edgeList = (java.util.List<DetachedEdge>)
response.getResult().getData();
-        assertEquals(1, edgeList.size());
-
-        final DetachedEdge deserializedEdge = edgeList.get(0);
-        assertEquals(e.id(), deserializedEdge.id());
-        assertEquals("test", deserializedEdge.label());
-
-        assertEquals(123, deserializedEdge.values("abc").next());
-        assertEquals(1, IteratorUtils.count(deserializedEdge.properties()));
-        assertEquals(v1.id(), deserializedEdge.outVertex().id());
-        assertEquals(Vertex.DEFAULT_LABEL, deserializedEdge.outVertex().label());
-        assertEquals(v2.id(), deserializedEdge.inVertex().id());
-        assertEquals(Vertex.DEFAULT_LABEL, deserializedEdge.inVertex().label());
+        if (name.contains("V1d0Lite")) {
+            final List<ReferenceEdge> edgeList = (List<ReferenceEdge>) response.getResult().getData();
+            assertEquals(1, edgeList.size());
+
+            final ReferenceEdge deserializedEdge = edgeList.get(0);
+            assertEquals(e.id(), deserializedEdge.id());
+            assertEquals("test", deserializedEdge.label());
+
+            assertEquals(0, IteratorUtils.count(deserializedEdge.properties()));
+            assertEquals(v1.id(), deserializedEdge.outVertex().id());
+            assertEquals("", deserializedEdge.outVertex().label());
+            assertEquals(v2.id(), deserializedEdge.inVertex().id());
+            assertEquals("", deserializedEdge.inVertex().label());
+
+        } else {
+            final java.util.List<DetachedEdge> edgeList = (java.util.List<DetachedEdge>)
response.getResult().getData();
+            assertEquals(1, edgeList.size());
+
+            final DetachedEdge deserializedEdge = edgeList.get(0);
+            assertEquals(e.id(), deserializedEdge.id());
+            assertEquals("test", deserializedEdge.label());
+
+            assertEquals(123, deserializedEdge.values("abc").next());
+            assertEquals(1, IteratorUtils.count(deserializedEdge.properties()));
+            assertEquals(v1.id(), deserializedEdge.outVertex().id());
+            assertEquals(Vertex.DEFAULT_LABEL, deserializedEdge.outVertex().label());
+            assertEquals(v2.id(), deserializedEdge.inVertex().id());
+            assertEquals(Vertex.DEFAULT_LABEL, deserializedEdge.inVertex().label());
+        }
     }
 
     @Test
     public void shouldSerializeVertexWithEmbeddedMap() throws Exception {
-        assumeThat(name, not(containsString("V1d0Lite")));
-
         final Graph g = TinkerGraph.open();
         final Vertex v = g.addVertex();
         final Map<String, Object> map = new HashMap<>();
@@ -564,30 +579,39 @@ public class GryoMessageSerializerV1d0Test {
         final ResponseMessage response = convertBinary(list);
         assertCommon(response);
 
-        final java.util.List<DetachedVertex> vertexList = (java.util.List<DetachedVertex>)
response.getResult().getData();
-        assertEquals(1, vertexList.size());
+        if (name.contains("V1d0Lite")) {
+            final List<ReferenceVertex> vertexList = (List<ReferenceVertex>)
response.getResult().getData();
+            assertEquals(1, vertexList.size());
+
+            final ReferenceVertex deserializedVertex = vertexList.get(0);
+            assertEquals(0L, deserializedVertex.id());
+            assertEquals("", deserializedVertex.label());
 
-        final DetachedVertex deserializedVertex = vertexList.get(0);
-        assertEquals(0l, deserializedVertex.id());
-        assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label());
+            assertEquals(0, IteratorUtils.count(deserializedVertex.properties()));
+        } else {
+            final java.util.List<DetachedVertex> vertexList = (java.util.List<DetachedVertex>)
response.getResult().getData();
+            assertEquals(1, vertexList.size());
 
-        assertEquals(1, IteratorUtils.count(deserializedVertex.properties()));
+            final DetachedVertex deserializedVertex = vertexList.get(0);
+            assertEquals(0l, deserializedVertex.id());
+            assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label());
 
-        final java.util.List<Object> deserializedInnerList = (java.util.List<Object>)
deserializedVertex.values("friends").next();
-        assertEquals(3, deserializedInnerList.size());
-        assertEquals("x", deserializedInnerList.get(0));
-        assertEquals(5, deserializedInnerList.get(1));
+            assertEquals(1, IteratorUtils.count(deserializedVertex.properties()));
 
-        final Map<String, Object> deserializedInnerInnerMap = (Map<String, Object>)
deserializedInnerList.get(2);
-        assertEquals(2, deserializedInnerInnerMap.size());
-        assertEquals(500, deserializedInnerInnerMap.get("x"));
-        assertEquals("some", deserializedInnerInnerMap.get("y"));
+            final java.util.List<Object> deserializedInnerList = (java.util.List<Object>)
deserializedVertex.values("friends").next();
+            assertEquals(3, deserializedInnerList.size());
+            assertEquals("x", deserializedInnerList.get(0));
+            assertEquals(5, deserializedInnerList.get(1));
+
+            final Map<String, Object> deserializedInnerInnerMap = (Map<String, Object>)
deserializedInnerList.get(2);
+            assertEquals(2, deserializedInnerInnerMap.size());
+            assertEquals(500, deserializedInnerInnerMap.get("x"));
+            assertEquals("some", deserializedInnerInnerMap.get("y"));
+        }
     }
 
     @Test
     public void shouldSerializeToMapWithElementForKey() throws Exception {
-        assumeThat(name, not(containsString("V1d0Lite")));
-
         final TinkerGraph graph = TinkerFactory.createClassic();
         final GraphTraversalSource g = graph.traversal();
         final Map<Vertex, Integer> map = new HashMap<>();
@@ -596,17 +620,29 @@ public class GryoMessageSerializerV1d0Test {
         final ResponseMessage response = convertBinary(map);
         assertCommon(response);
 
-        final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>) response.getResult().getData();
-        assertEquals(1, deserializedMap.size());
+        if (name.contains("V1d0Lite")) {
+            final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>)
response.getResult().getData();
+            assertEquals(1, deserializedMap.size());
 
-        final Vertex deserializedMarko = deserializedMap.keySet().iterator().next();
-        assertEquals("marko", deserializedMarko.values("name").next().toString());
-        assertEquals(1, deserializedMarko.id());
-        assertEquals(Vertex.DEFAULT_LABEL, deserializedMarko.label());
-        assertEquals(29, deserializedMarko.values("age").next());
-        assertEquals(2, IteratorUtils.count(deserializedMarko.properties()));
+            final Vertex deserializedMarko = deserializedMap.keySet().iterator().next();
+            assertEquals(0, IteratorUtils.count(deserializedMarko.properties()));
+            assertEquals(1, deserializedMarko.id());
+            assertEquals("", deserializedMarko.label());
 
-        assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
+            assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
+        } else {
+            final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>)
response.getResult().getData();
+            assertEquals(1, deserializedMap.size());
+
+            final Vertex deserializedMarko = deserializedMap.keySet().iterator().next();
+            assertEquals("marko", deserializedMarko.values("name").next().toString());
+            assertEquals(1, deserializedMarko.id());
+            assertEquals(Vertex.DEFAULT_LABEL, deserializedMarko.label());
+            assertEquals(29, deserializedMarko.values("age").next());
+            assertEquals(2, IteratorUtils.count(deserializedMarko.properties()));
+
+            assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
+        }
     }
 
 


Mime
View raw message