You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/04/03 15:31:00 UTC
[2/3] incubator-tinkerpop git commit: Add tests for kryo
serialization of TraversalMetrics.
Add tests for kryo serialization of TraversalMetrics.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/8fbb14a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/8fbb14a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/8fbb14a5
Branch: refs/heads/master
Commit: 8fbb14a5e7a7fcd37c4a99c0fe10b100021161ab
Parents: fcc252e
Author: rjbriody <bo...@datastax.com>
Authored: Fri Apr 3 09:17:02 2015 -0400
Committer: rjbriody <bo...@datastax.com>
Committed: Fri Apr 3 09:17:02 2015 -0400
----------------------------------------------------------------------
.../gremlin/structure/SerializationTest.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8fbb14a5/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
index a60e2e1..6ad96d1 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
@@ -37,6 +37,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
@@ -188,6 +189,24 @@ public class SerializationTest {
// this is a SimpleTraverser so no properties are present in detachment
assertFalse(detachedVIn.properties().hasNext());
}
+
+ @Test
+ @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+ public void shouldSerializeTraversalMetrics() throws Exception {
+ final GryoWriter gryoWriter = graph.io().gryoWriter().create();
+ final GryoReader gryoReader = graph.io().gryoReader().create();
+
+ final TraversalMetrics before = (TraversalMetrics) g.V().both().profile().cap(TraversalMetrics.METRICS_KEY).next();
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ gryoWriter.writeObject(outputStream, before);
+
+ final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
+ final TraversalMetrics after = gryoReader.readObject(inputStream);
+ assertNotNull(after);
+ assertEquals(before.getMetrics().size(), after.getMetrics().size());
+ assertEquals(before.getDuration(TimeUnit.MILLISECONDS), after.getDuration(TimeUnit.MILLISECONDS));
+ assertEquals(before.getMetrics(0).getCounts(), after.getMetrics(0).getCounts());
+ }
}
public static class GraphSONTest extends AbstractGremlinTest {
@@ -308,7 +327,6 @@ public class SerializationTest {
assertTrue(metrics0.containsKey(GraphSONTokens.NAME));
assertTrue(metrics0.containsKey(GraphSONTokens.COUNTS));
assertTrue(metrics0.containsKey(GraphSONTokens.DURATION));
-
}
}
}