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 2015/05/18 19:40:20 UTC
incubator-tinkerpop git commit: Fixed inconsistency in naming that
was causing Gremlin Server integration tests to fail.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master d7db876ca -> e65449307
Fixed inconsistency in naming that was causing Gremlin Server integration tests to fail.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/e6544930
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/e6544930
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/e6544930
Branch: refs/heads/master
Commit: e65449307e63b3db987c00d6d5b842abd6d5b36a
Parents: d7db876
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon May 18 13:40:00 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 18 13:40:00 2015 -0400
----------------------------------------------------------------------
.../gremlin/driver/MessageSerializer.java | 4 +-
.../tinkerpop/gremlin/driver/Settings.java | 4 +-
.../GraphSONMessageSerializerGremlinV1D0.java | 66 ----
.../GraphSONMessageSerializerGremlinV1d0.java | 66 ++++
.../ser/GraphSONMessageSerializerV1D0.java | 122 -------
.../ser/GraphSONMessageSerializerV1d0.java | 122 +++++++
.../gremlin/driver/ser/Serializers.java | 8 +-
.../ser/GryoMessageSerializerV1D0Test.java | 317 -------------------
.../ser/GryoMessageSerializerV1d0Test.java | 316 ++++++++++++++++++
.../JsonMessageSerializerGremlinV1d0Test.java | 2 +-
.../ser/JsonMessageSerializerV1d0Test.java | 2 +-
.../server/GremlinServerIntegrateTest.java | 4 +-
12 files changed, 516 insertions(+), 517 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/MessageSerializer.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/MessageSerializer.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/MessageSerializer.java
index cf4e12c..f2bd8fd 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/MessageSerializer.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/MessageSerializer.java
@@ -20,7 +20,7 @@ package org.apache.tinkerpop.gremlin.driver;
import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
-import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1D0;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0;
import org.apache.tinkerpop.gremlin.driver.ser.SerializationException;
import org.apache.tinkerpop.gremlin.structure.Graph;
import io.netty.buffer.ByteBuf;
@@ -37,7 +37,7 @@ import java.util.ServiceLoader;
* {@link MessageSerializer} instances are instantiated to a cache via {@link ServiceLoader} and indexed based on
* the mime types they support. If a mime type is supported more than once, the last {@link MessageSerializer}
* instance loaded for that mime type is assigned. If a mime type is not found the default
- * {@link GraphSONMessageSerializerV1D0} is used to return the results.
+ * {@link GraphSONMessageSerializerV1d0} is used to return the results.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
index 6ca887f..d2fbad1 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java
@@ -18,7 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.driver;
-import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1D0;
+import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0;
import org.yaml.snakeyaml.TypeDescription;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
@@ -86,7 +86,7 @@ class Settings {
}
public static class SerializerSettings {
- public String className = GraphSONMessageSerializerV1D0.class.getCanonicalName();
+ public String className = GraphSONMessageSerializerV1d0.class.getCanonicalName();
public Map<String, Object> config = null;
public MessageSerializer create() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1D0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1D0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1D0.java
deleted file mode 100644
index b895246..0000000
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1D0.java
+++ /dev/null
@@ -1,66 +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 org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
-
-import java.nio.ByteBuffer;
-
-/**
- * Serialize results to JSON with version 1.0.x schema.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class GraphSONMessageSerializerGremlinV1D0 extends AbstractGraphSONMessageSerializerV1d0 {
-
- private static final String MIME_TYPE = SerTokens.MIME_GRAPHSON_V1D0;
-
- private static byte[] header;
-
- static {
- final ByteBuffer buffer = ByteBuffer.allocate(MIME_TYPE.length() + 1);
- buffer.put((byte) MIME_TYPE.length());
- buffer.put(MIME_TYPE.getBytes());
- header = buffer.array();
- }
-
- public GraphSONMessageSerializerGremlinV1D0() {
- super();
- }
-
- public GraphSONMessageSerializerGremlinV1D0(final GraphSONMapper mapper) {
- super(mapper);
- }
-
- @Override
- public String[] mimeTypesSupported() {
- return new String[]{MIME_TYPE};
- }
-
- @Override
- byte[] obtainHeader() {
- return header;
- }
-
- @Override
- GraphSONMapper.Builder configureBuilder(final GraphSONMapper.Builder builder) {
- return builder.addCustomModule(new GraphSONMessageSerializerV1D0.GremlinServerModule())
- .embedTypes(true);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1d0.java
new file mode 100644
index 0000000..834439d
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV1d0.java
@@ -0,0 +1,66 @@
+/*
+ * 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 org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Serialize results to JSON with version 1.0.x schema.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GraphSONMessageSerializerGremlinV1d0 extends AbstractGraphSONMessageSerializerV1d0 {
+
+ private static final String MIME_TYPE = SerTokens.MIME_GRAPHSON_V1D0;
+
+ private static byte[] header;
+
+ static {
+ final ByteBuffer buffer = ByteBuffer.allocate(MIME_TYPE.length() + 1);
+ buffer.put((byte) MIME_TYPE.length());
+ buffer.put(MIME_TYPE.getBytes());
+ header = buffer.array();
+ }
+
+ public GraphSONMessageSerializerGremlinV1d0() {
+ super();
+ }
+
+ public GraphSONMessageSerializerGremlinV1d0(final GraphSONMapper mapper) {
+ super(mapper);
+ }
+
+ @Override
+ public String[] mimeTypesSupported() {
+ return new String[]{MIME_TYPE};
+ }
+
+ @Override
+ byte[] obtainHeader() {
+ return header;
+ }
+
+ @Override
+ GraphSONMapper.Builder configureBuilder(final GraphSONMapper.Builder builder) {
+ return builder.addCustomModule(new GraphSONMessageSerializerV1d0.GremlinServerModule())
+ .embedTypes(true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1D0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1D0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1D0.java
deleted file mode 100644
index 3255419..0000000
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1D0.java
+++ /dev/null
@@ -1,122 +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 org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.nio.ByteBuffer;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Serialize results to JSON with version 1.0.x schema.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class GraphSONMessageSerializerV1D0 extends AbstractGraphSONMessageSerializerV1d0 implements MessageTextSerializer {
- private static final Logger logger = LoggerFactory.getLogger(GraphSONMessageSerializerV1D0.class);
- private static final String MIME_TYPE = SerTokens.MIME_JSON;
-
- private static byte[] header;
-
- static {
- final ByteBuffer buffer = ByteBuffer.allocate(MIME_TYPE.length() + 1);
- buffer.put((byte) MIME_TYPE.length());
- buffer.put(MIME_TYPE.getBytes());
- header = buffer.array();
- }
-
- public GraphSONMessageSerializerV1D0() {
- super();
- }
-
- public GraphSONMessageSerializerV1D0(final GraphSONMapper mapper) {
- super(mapper);
- }
-
- @Override
- public String[] mimeTypesSupported() {
- return new String[]{MIME_TYPE};
- }
-
- @Override
- GraphSONMapper.Builder configureBuilder(GraphSONMapper.Builder builder) {
- return builder.addCustomModule(new GremlinServerModule())
- .embedTypes(false);
- }
-
- @Override
- byte[] obtainHeader() {
- return header;
- }
-
- @Override
- public ResponseMessage deserializeResponse(final String msg) throws SerializationException {
- try {
- final Map<String, Object> responseData = mapper.readValue(msg, mapTypeReference);
- final Map<String, Object> status = (Map<String, Object>) responseData.get(SerTokens.TOKEN_STATUS);
- final Map<String, Object> result = (Map<String, Object>) responseData.get(SerTokens.TOKEN_RESULT);
- return ResponseMessage.build(UUID.fromString(responseData.get(SerTokens.TOKEN_REQUEST).toString()))
- .code(ResponseStatusCode.getFromValue((Integer) status.get(SerTokens.TOKEN_CODE)))
- .statusMessage(status.get(SerTokens.TOKEN_MESSAGE).toString())
- .statusAttributes((Map<String, Object>) status.get(SerTokens.TOKEN_ATTRIBUTES))
- .result(result.get(SerTokens.TOKEN_DATA))
- .responseMetaData((Map<String, Object>) result.get(SerTokens.TOKEN_META))
- .create();
- } catch (Exception ex) {
- logger.warn("Response [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV1d0.class.getName());
- throw new SerializationException(ex);
- }
- }
-
- @Override
- public String serializeResponseAsString(final ResponseMessage responseMessage) throws SerializationException {
- try {
- return mapper.writeValueAsString(responseMessage);
- } catch (Exception ex) {
- logger.warn("Response [{}] could not be serialized by {}.", responseMessage.toString(), AbstractGraphSONMessageSerializerV1d0.class.getName());
- throw new SerializationException(ex);
- }
- }
-
- @Override
- public RequestMessage deserializeRequest(final String msg) throws SerializationException {
- try {
- return mapper.readValue(msg, RequestMessage.class);
- } catch (Exception ex) {
- logger.warn("Request [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV1d0.class.getName());
- throw new SerializationException(ex);
- }
- }
-
- @Override
- public String serializeRequestAsString(final RequestMessage requestMessage) throws SerializationException {
- try {
- return mapper.writeValueAsString(requestMessage);
- } catch (Exception ex) {
- logger.warn("Request [{}] could not be serialized by {}.", requestMessage.toString(), AbstractGraphSONMessageSerializerV1d0.class.getName());
- throw new SerializationException(ex);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1d0.java
new file mode 100644
index 0000000..f4293a8
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV1d0.java
@@ -0,0 +1,122 @@
+/*
+ * 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 org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Serialize results to JSON with version 1.0.x schema.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GraphSONMessageSerializerV1d0 extends AbstractGraphSONMessageSerializerV1d0 implements MessageTextSerializer {
+ private static final Logger logger = LoggerFactory.getLogger(GraphSONMessageSerializerV1d0.class);
+ private static final String MIME_TYPE = SerTokens.MIME_JSON;
+
+ private static byte[] header;
+
+ static {
+ final ByteBuffer buffer = ByteBuffer.allocate(MIME_TYPE.length() + 1);
+ buffer.put((byte) MIME_TYPE.length());
+ buffer.put(MIME_TYPE.getBytes());
+ header = buffer.array();
+ }
+
+ public GraphSONMessageSerializerV1d0() {
+ super();
+ }
+
+ public GraphSONMessageSerializerV1d0(final GraphSONMapper mapper) {
+ super(mapper);
+ }
+
+ @Override
+ public String[] mimeTypesSupported() {
+ return new String[]{MIME_TYPE};
+ }
+
+ @Override
+ GraphSONMapper.Builder configureBuilder(GraphSONMapper.Builder builder) {
+ return builder.addCustomModule(new GremlinServerModule())
+ .embedTypes(false);
+ }
+
+ @Override
+ byte[] obtainHeader() {
+ return header;
+ }
+
+ @Override
+ public ResponseMessage deserializeResponse(final String msg) throws SerializationException {
+ try {
+ final Map<String, Object> responseData = mapper.readValue(msg, mapTypeReference);
+ final Map<String, Object> status = (Map<String, Object>) responseData.get(SerTokens.TOKEN_STATUS);
+ final Map<String, Object> result = (Map<String, Object>) responseData.get(SerTokens.TOKEN_RESULT);
+ return ResponseMessage.build(UUID.fromString(responseData.get(SerTokens.TOKEN_REQUEST).toString()))
+ .code(ResponseStatusCode.getFromValue((Integer) status.get(SerTokens.TOKEN_CODE)))
+ .statusMessage(status.get(SerTokens.TOKEN_MESSAGE).toString())
+ .statusAttributes((Map<String, Object>) status.get(SerTokens.TOKEN_ATTRIBUTES))
+ .result(result.get(SerTokens.TOKEN_DATA))
+ .responseMetaData((Map<String, Object>) result.get(SerTokens.TOKEN_META))
+ .create();
+ } catch (Exception ex) {
+ logger.warn("Response [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV1d0.class.getName());
+ throw new SerializationException(ex);
+ }
+ }
+
+ @Override
+ public String serializeResponseAsString(final ResponseMessage responseMessage) throws SerializationException {
+ try {
+ return mapper.writeValueAsString(responseMessage);
+ } catch (Exception ex) {
+ logger.warn("Response [{}] could not be serialized by {}.", responseMessage.toString(), AbstractGraphSONMessageSerializerV1d0.class.getName());
+ throw new SerializationException(ex);
+ }
+ }
+
+ @Override
+ public RequestMessage deserializeRequest(final String msg) throws SerializationException {
+ try {
+ return mapper.readValue(msg, RequestMessage.class);
+ } catch (Exception ex) {
+ logger.warn("Request [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV1d0.class.getName());
+ throw new SerializationException(ex);
+ }
+ }
+
+ @Override
+ public String serializeRequestAsString(final RequestMessage requestMessage) throws SerializationException {
+ try {
+ return mapper.writeValueAsString(requestMessage);
+ } catch (Exception ex) {
+ logger.warn("Request [{}] could not be serialized by {}.", requestMessage.toString(), AbstractGraphSONMessageSerializerV1d0.class.getName());
+ throw new SerializationException(ex);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
index 8c5e7ba..5ae472b 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
@@ -37,14 +37,14 @@ public enum Serializers {
* {@link org.apache.tinkerpop.gremlin.driver.ser.MessageTextSerializer} so that it can be compatible with text-based
* websocket messages.
*/
- public static final MessageSerializer DEFAULT_RESULT_SERIALIZER = new GraphSONMessageSerializerV1D0();
+ public static final MessageSerializer DEFAULT_RESULT_SERIALIZER = new GraphSONMessageSerializerV1d0();
/**
* Default serializer for requests received by Gremlin Server. This implementation must be of type
* {@link org.apache.tinkerpop.gremlin.driver.ser.MessageTextSerializer} so that it can be compatible with text-based
* websocket messages.
*/
- public static final MessageSerializer DEFAULT_REQUEST_SERIALIZER = new GraphSONMessageSerializerV1D0();
+ public static final MessageSerializer DEFAULT_REQUEST_SERIALIZER = new GraphSONMessageSerializerV1d0();
private Serializers(final String mimeType) {
this.value = mimeType;
@@ -57,9 +57,9 @@ public enum Serializers {
public MessageSerializer simpleInstance() {
switch (value) {
case SerTokens.MIME_JSON:
- return new GraphSONMessageSerializerV1D0();
+ return new GraphSONMessageSerializerV1d0();
case SerTokens.MIME_GRAPHSON_V1D0:
- return new GraphSONMessageSerializerGremlinV1D0();
+ return new GraphSONMessageSerializerGremlinV1d0();
case SerTokens.MIME_GRYO_V1D0:
return new GryoMessageSerializerV1d0();
default:
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/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
deleted file mode 100644
index 6093648..0000000
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1D0Test.java
+++ /dev/null
@@ -1,317 +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 org.apache.tinkerpop.gremlin.driver.MessageSerializer;
-import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
-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.Compare;
-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.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.UnpooledByteBufAllocator;
-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;
-import static org.junit.Assert.assertNull;
-
-/**
- * Serializer tests that cover non-lossy serialization/deserialization methods.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class GryoMessageSerializerV1D0Test {
- private static final Map<String, Object> config = new HashMap<String, Object>() {{
- put("serializeResultToString", 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 GryoMessageSerializerV1d0();
-
- public MessageSerializer textSerializer = new GryoMessageSerializerV1d0();
-
- public GryoMessageSerializerV1D0Test() {
- textSerializer.configure(config, null);
- }
-
- @Test
- public void serializeIterable() throws Exception {
- final ArrayList<Integer> list = new ArrayList<>();
- list.add(1);
- list.add(100);
-
- final ResponseMessage response = convertBinary(list);
- assertCommon(response);
-
- final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
- assertEquals(2, deserializedFunList.size());
- assertEquals(new Integer(1), deserializedFunList.get(0));
- assertEquals(new Integer(100), deserializedFunList.get(1));
- }
-
- @Test
- public void serializeIterableToString() throws Exception {
- final ArrayList<Integer> list = new ArrayList<>();
- list.add(1);
- list.add(100);
-
- final ResponseMessage response = convertText(list);
- assertCommon(response);
-
- final List deserializedFunList = (List) response.getResult().getData();
- assertEquals(2, deserializedFunList.size());
- assertEquals("1", deserializedFunList.get(0));
- assertEquals("100", deserializedFunList.get(1));
- }
-
- @Test
- public void serializeIterableToStringWithNull() throws Exception {
- final ArrayList<Integer> list = new ArrayList<>();
- list.add(1);
- list.add(null);
- list.add(100);
-
- final ResponseMessage response = convertText(list);
- assertCommon(response);
-
- final List deserializedFunList = (List) response.getResult().getData();
- assertEquals(3, deserializedFunList.size());
- assertEquals("1", deserializedFunList.get(0).toString());
- assertEquals("null", deserializedFunList.get(1).toString());
- assertEquals("100", deserializedFunList.get(2).toString());
- }
-
- @Test
- public void serializeIterableWithNull() throws Exception {
- final ArrayList<Integer> list = new ArrayList<>();
- list.add(1);
- list.add(null);
- list.add(100);
-
- final ResponseMessage response = convertBinary(list);
- assertCommon(response);
-
- final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
- assertEquals(3, deserializedFunList.size());
- assertEquals(new Integer(1), deserializedFunList.get(0));
- assertNull(deserializedFunList.get(1));
- assertEquals(new Integer(100), deserializedFunList.get(2));
- }
-
- @Test
- public void serializeMap() throws Exception {
- final Map<String, Object> map = new HashMap<>();
- final Map<String, String> innerMap = new HashMap<>();
- innerMap.put("a", "b");
-
- map.put("x", 1);
- map.put("y", "some");
- map.put("z", innerMap);
-
- final ResponseMessage response = convertBinary(map);
- assertCommon(response);
-
- final Map<String, Object> deserializedMap = (Map<String, Object>) response.getResult().getData();
- assertEquals(3, deserializedMap.size());
- assertEquals(1, deserializedMap.get("x"));
- assertEquals("some", deserializedMap.get("y"));
-
- final Map<String, String> deserializedInnerMap = (Map<String, String>) deserializedMap.get("z");
- assertEquals(1, deserializedInnerMap.size());
- assertEquals("b", deserializedInnerMap.get("a"));
- }
-
- @Test
- public void serializeEdge() 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<DetachedEdge> edgeList = (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 serializeVertexWithEmbeddedMap() 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<DetachedVertex> vertexList = (List<DetachedVertex>) response.getResult().getData();
- assertEquals(1, vertexList.size());
-
- final DetachedVertex deserializedVertex = vertexList.get(0);
- assertEquals(0l, deserializedVertex.id());
- assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label());
-
- assertEquals(1, IteratorUtils.count(deserializedVertex.properties()));
-
- final List<Object> deserializedInnerList = (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 serializeToMapWithElementForKey() 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("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());
- }
-
- @Test
- public void serializeFullResponseMessage() throws Exception {
- final UUID id = UUID.randomUUID();
-
- final Map<String, Object> metaData = new HashMap<>();
- metaData.put("test", "this");
- metaData.put("one", 1);
-
- final Map<String, Object> attributes = new HashMap<>();
- attributes.put("test", "that");
- attributes.put("two", 2);
-
- final ResponseMessage response = ResponseMessage.build(id)
- .responseMetaData(metaData)
- .code(ResponseStatusCode.SUCCESS)
- .result("some-result")
- .statusAttributes(attributes)
- .statusMessage("worked")
- .create();
-
- final ByteBuf bb = binarySerializer.serializeResponseAsBinary(response, allocator);
- final ResponseMessage deserialized = binarySerializer.deserializeResponse(bb);
-
- assertEquals(id, deserialized.getRequestId());
- assertEquals("this", deserialized.getResult().getMeta().get("test"));
- assertEquals(1, deserialized.getResult().getMeta().get("one"));
- assertEquals("some-result", deserialized.getResult().getData());
- assertEquals("that", deserialized.getStatus().getAttributes().get("test"));
- assertEquals(2, deserialized.getStatus().getAttributes().get("two"));
- assertEquals(ResponseStatusCode.SUCCESS.getValue(), deserialized.getStatus().getCode().getValue());
- assertEquals("worked", deserialized.getStatus().getMessage());
- }
-
- @Test
- public void serializeFullRequestMessage() throws Exception {
- final UUID id = UUID.randomUUID();
-
- final RequestMessage request = RequestMessage.build("try")
- .overrideRequestId(id)
- .processor("pro")
- .addArg("test", "this")
- .create();
- final ByteBuf bb = binarySerializer.serializeRequestAsBinary(request, allocator);
- final int mimeLen = bb.readByte();
- bb.readBytes(new byte[mimeLen]);
- final RequestMessage deserialized = binarySerializer.deserializeRequest(bb);
-
- assertEquals(id, deserialized.getRequestId());
- assertEquals("pro", deserialized.getProcessor());
- assertEquals("try", deserialized.getOp());
- assertEquals("this", deserialized.getArgs().get("test"));
- }
-
- 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);
- }
-
- private ResponseMessage convertText(final Object toSerialize) throws SerializationException {
- final ByteBuf bb = textSerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
- return textSerializer.deserializeResponse(bb);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/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
new file mode 100644
index 0000000..ecb074b
--- /dev/null
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
@@ -0,0 +1,316 @@
+/*
+ * 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 org.apache.tinkerpop.gremlin.driver.MessageSerializer;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+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.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.UnpooledByteBufAllocator;
+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;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Serializer tests that cover non-lossy serialization/deserialization methods.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GryoMessageSerializerV1d0Test {
+ private static final Map<String, Object> config = new HashMap<String, Object>() {{
+ put("serializeResultToString", 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 GryoMessageSerializerV1d0();
+
+ public MessageSerializer textSerializer = new GryoMessageSerializerV1d0();
+
+ public GryoMessageSerializerV1d0Test() {
+ textSerializer.configure(config, null);
+ }
+
+ @Test
+ public void serializeIterable() throws Exception {
+ final ArrayList<Integer> list = new ArrayList<>();
+ list.add(1);
+ list.add(100);
+
+ final ResponseMessage response = convertBinary(list);
+ assertCommon(response);
+
+ final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
+ assertEquals(2, deserializedFunList.size());
+ assertEquals(new Integer(1), deserializedFunList.get(0));
+ assertEquals(new Integer(100), deserializedFunList.get(1));
+ }
+
+ @Test
+ public void serializeIterableToString() throws Exception {
+ final ArrayList<Integer> list = new ArrayList<>();
+ list.add(1);
+ list.add(100);
+
+ final ResponseMessage response = convertText(list);
+ assertCommon(response);
+
+ final List deserializedFunList = (List) response.getResult().getData();
+ assertEquals(2, deserializedFunList.size());
+ assertEquals("1", deserializedFunList.get(0));
+ assertEquals("100", deserializedFunList.get(1));
+ }
+
+ @Test
+ public void serializeIterableToStringWithNull() throws Exception {
+ final ArrayList<Integer> list = new ArrayList<>();
+ list.add(1);
+ list.add(null);
+ list.add(100);
+
+ final ResponseMessage response = convertText(list);
+ assertCommon(response);
+
+ final List deserializedFunList = (List) response.getResult().getData();
+ assertEquals(3, deserializedFunList.size());
+ assertEquals("1", deserializedFunList.get(0).toString());
+ assertEquals("null", deserializedFunList.get(1).toString());
+ assertEquals("100", deserializedFunList.get(2).toString());
+ }
+
+ @Test
+ public void serializeIterableWithNull() throws Exception {
+ final ArrayList<Integer> list = new ArrayList<>();
+ list.add(1);
+ list.add(null);
+ list.add(100);
+
+ final ResponseMessage response = convertBinary(list);
+ assertCommon(response);
+
+ final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
+ assertEquals(3, deserializedFunList.size());
+ assertEquals(new Integer(1), deserializedFunList.get(0));
+ assertNull(deserializedFunList.get(1));
+ assertEquals(new Integer(100), deserializedFunList.get(2));
+ }
+
+ @Test
+ public void serializeMap() throws Exception {
+ final Map<String, Object> map = new HashMap<>();
+ final Map<String, String> innerMap = new HashMap<>();
+ innerMap.put("a", "b");
+
+ map.put("x", 1);
+ map.put("y", "some");
+ map.put("z", innerMap);
+
+ final ResponseMessage response = convertBinary(map);
+ assertCommon(response);
+
+ final Map<String, Object> deserializedMap = (Map<String, Object>) response.getResult().getData();
+ assertEquals(3, deserializedMap.size());
+ assertEquals(1, deserializedMap.get("x"));
+ assertEquals("some", deserializedMap.get("y"));
+
+ final Map<String, String> deserializedInnerMap = (Map<String, String>) deserializedMap.get("z");
+ assertEquals(1, deserializedInnerMap.size());
+ assertEquals("b", deserializedInnerMap.get("a"));
+ }
+
+ @Test
+ public void serializeEdge() 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<DetachedEdge> edgeList = (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 serializeVertexWithEmbeddedMap() 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<DetachedVertex> vertexList = (List<DetachedVertex>) response.getResult().getData();
+ assertEquals(1, vertexList.size());
+
+ final DetachedVertex deserializedVertex = vertexList.get(0);
+ assertEquals(0l, deserializedVertex.id());
+ assertEquals(Vertex.DEFAULT_LABEL, deserializedVertex.label());
+
+ assertEquals(1, IteratorUtils.count(deserializedVertex.properties()));
+
+ final List<Object> deserializedInnerList = (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 serializeToMapWithElementForKey() 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("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());
+ }
+
+ @Test
+ public void serializeFullResponseMessage() throws Exception {
+ final UUID id = UUID.randomUUID();
+
+ final Map<String, Object> metaData = new HashMap<>();
+ metaData.put("test", "this");
+ metaData.put("one", 1);
+
+ final Map<String, Object> attributes = new HashMap<>();
+ attributes.put("test", "that");
+ attributes.put("two", 2);
+
+ final ResponseMessage response = ResponseMessage.build(id)
+ .responseMetaData(metaData)
+ .code(ResponseStatusCode.SUCCESS)
+ .result("some-result")
+ .statusAttributes(attributes)
+ .statusMessage("worked")
+ .create();
+
+ final ByteBuf bb = binarySerializer.serializeResponseAsBinary(response, allocator);
+ final ResponseMessage deserialized = binarySerializer.deserializeResponse(bb);
+
+ assertEquals(id, deserialized.getRequestId());
+ assertEquals("this", deserialized.getResult().getMeta().get("test"));
+ assertEquals(1, deserialized.getResult().getMeta().get("one"));
+ assertEquals("some-result", deserialized.getResult().getData());
+ assertEquals("that", deserialized.getStatus().getAttributes().get("test"));
+ assertEquals(2, deserialized.getStatus().getAttributes().get("two"));
+ assertEquals(ResponseStatusCode.SUCCESS.getValue(), deserialized.getStatus().getCode().getValue());
+ assertEquals("worked", deserialized.getStatus().getMessage());
+ }
+
+ @Test
+ public void serializeFullRequestMessage() throws Exception {
+ final UUID id = UUID.randomUUID();
+
+ final RequestMessage request = RequestMessage.build("try")
+ .overrideRequestId(id)
+ .processor("pro")
+ .addArg("test", "this")
+ .create();
+ final ByteBuf bb = binarySerializer.serializeRequestAsBinary(request, allocator);
+ final int mimeLen = bb.readByte();
+ bb.readBytes(new byte[mimeLen]);
+ final RequestMessage deserialized = binarySerializer.deserializeRequest(bb);
+
+ assertEquals(id, deserialized.getRequestId());
+ assertEquals("pro", deserialized.getProcessor());
+ assertEquals("try", deserialized.getOp());
+ assertEquals("this", deserialized.getArgs().get("test"));
+ }
+
+ 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);
+ }
+
+ private ResponseMessage convertText(final Object toSerialize) throws SerializationException {
+ final ByteBuf bb = textSerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
+ return textSerializer.deserializeResponse(bb);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerGremlinV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerGremlinV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerGremlinV1d0Test.java
index eac6a67..a7f214b 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerGremlinV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerGremlinV1d0Test.java
@@ -54,7 +54,7 @@ public class JsonMessageSerializerGremlinV1d0Test {
private ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(requestId);
private static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
- public MessageSerializer serializer = new GraphSONMessageSerializerGremlinV1D0();
+ public MessageSerializer serializer = new GraphSONMessageSerializerGremlinV1d0();
@Test
public void serializeIterable() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
index 453af95..ef7dcc2 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/JsonMessageSerializerV1d0Test.java
@@ -51,7 +51,7 @@ import static org.junit.Assert.assertNotNull;
*/
public class JsonMessageSerializerV1d0Test {
- public static final GraphSONMessageSerializerV1D0 SERIALIZER = new GraphSONMessageSerializerV1D0();
+ public static final GraphSONMessageSerializerV1d0 SERIALIZER = new GraphSONMessageSerializerV1d0();
private static final RequestMessage msg = RequestMessage.build("op")
.overrideRequestId(UUID.fromString("2D62161B-9544-4F39-AF44-62EC49F9A595")).create();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6544930/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index f44a17a..bb8f0ca 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -193,7 +193,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
}
});
- if (!latch.await(300, TimeUnit.MILLISECONDS))
+ if (!latch.await(3000, TimeUnit.MILLISECONDS))
fail("Request should have returned error, but instead timed out");
assertTrue(pass.get());
}
@@ -359,7 +359,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
@Test
public void shouldFailOnDeadHost() throws Exception {
- final Cluster cluster = Cluster.build("localhost").serializer(Serializers.JSON_V1D0).create();
+ final Cluster cluster = Cluster.build("localhost").create();
final Client client = cluster.connect();
// ensure that connection to server is good