geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject geode git commit: GEODE-3503: Removal of Codec classes left behind. Added tests to test the remaining JSONCodec. [Forced Update!]
Date Wed, 23 Aug 2017 21:28:17 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3503 a182a5a95 -> 42eb4b926 (forced update)


GEODE-3503: Removal of Codec classes left behind.
Added tests to test the remaining JSONCodec.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/42eb4b92
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/42eb4b92
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/42eb4b92

Branch: refs/heads/feature/GEODE-3503
Commit: 42eb4b926331c1fc4ded1165f7ccab6c6ed26b8d
Parents: 039edfc
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Wed Aug 23 13:48:11 2017 -0700
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Wed Aug 23 14:27:57 2017 -0700

----------------------------------------------------------------------
 .../geode/serialization/codec/BinaryCodec.java  |  37 ----
 .../geode/serialization/codec/BooleanCodec.java |  39 ----
 .../geode/serialization/codec/ByteCodec.java    |  39 ----
 .../geode/serialization/codec/DoubleCodec.java  |  39 ----
 .../geode/serialization/codec/FloatCodec.java   |  39 ----
 .../geode/serialization/codec/IntCodec.java     |  39 ----
 .../geode/serialization/codec/LongCodec.java    |  39 ----
 .../geode/serialization/codec/ShortCodec.java   |  39 ----
 .../geode/serialization/codec/StringCodec.java  |  41 ----
 geode-protobuf/src/main/proto/region_API.proto  |   1 +
 ...e.geode.protocol.operations.OperationHandler |   1 -
 ...geode.protocol.serializer.ProtocolSerializer |   1 -
 .../org.apache.geode.serialization.TypeCodec    |   9 -
 .../GetAllRequestOperationHandlerJUnitTest.java |   3 -
 .../GetRequestOperationHandlerJUnitTest.java    |   3 -
 .../RemoveRequestOperationHandlerJUnitTest.java |   3 -
 .../ProtobufProtocolSerializerJUnitTest.java    |  27 +--
 .../codec/BinaryFormatJUnitTest.java            |  65 ------
 .../serialization/codec/JSONCodecJUnitTest.java | 207 +++++++++++++++++++
 19 files changed, 218 insertions(+), 453 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
deleted file mode 100644
index cca88dd..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BinaryCodec.java
+++ /dev/null
@@ -1,37 +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.geode.serialization.codec;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class BinaryCodec implements TypeCodec<byte[]> {
-  @Override
-  public byte[] decode(byte[] incoming) {
-    return incoming;
-  }
-
-  @Override
-  public byte[] encode(byte[] incoming) {
-    return incoming;
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.BINARY;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
deleted file mode 100644
index ca0443c..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/BooleanCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class BooleanCodec implements TypeCodec<Boolean> {
-  @Override
-  public Boolean decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).get() == 1;
-  }
-
-  @Override
-  public byte[] encode(Boolean incoming) {
-    return ByteBuffer.allocate(Byte.BYTES).put(incoming ? (byte) 1 : (byte) 0).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.BOOLEAN;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
deleted file mode 100644
index 847d210..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ByteCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class ByteCodec implements TypeCodec<Byte> {
-  @Override
-  public Byte decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).get();
-  }
-
-  @Override
-  public byte[] encode(Byte incoming) {
-    return ByteBuffer.allocate(Byte.BYTES).put(incoming).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.BYTE;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
deleted file mode 100644
index 8f01639..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/DoubleCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class DoubleCodec implements TypeCodec<Double> {
-  @Override
-  public Double decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).getDouble();
-  }
-
-  @Override
-  public byte[] encode(Double incoming) {
-    return ByteBuffer.allocate(Double.BYTES).putDouble(incoming).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.DOUBLE;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
deleted file mode 100644
index 75c1e0d..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/FloatCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class FloatCodec implements TypeCodec<Float> {
-  @Override
-  public Float decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).getFloat();
-  }
-
-  @Override
-  public byte[] encode(Float incoming) {
-    return ByteBuffer.allocate(Float.BYTES).putFloat(incoming).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.FLOAT;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
deleted file mode 100644
index 4366c84..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/IntCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class IntCodec implements TypeCodec<Integer> {
-  @Override
-  public Integer decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).getInt();
-  }
-
-  @Override
-  public byte[] encode(Integer incoming) {
-    return ByteBuffer.allocate(Integer.BYTES).putInt(incoming).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.INT;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
deleted file mode 100644
index b6b8053..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/LongCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class LongCodec implements TypeCodec<Long> {
-  @Override
-  public Long decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).getLong();
-  }
-
-  @Override
-  public byte[] encode(Long incoming) {
-    return ByteBuffer.allocate(Long.BYTES).putLong(incoming).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.LONG;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
deleted file mode 100644
index df79fb0..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/ShortCodec.java
+++ /dev/null
@@ -1,39 +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.geode.serialization.codec;
-
-import java.nio.ByteBuffer;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class ShortCodec implements TypeCodec<Short> {
-  @Override
-  public Short decode(byte[] incoming) {
-    return ByteBuffer.wrap(incoming).getShort();
-  }
-
-  @Override
-  public byte[] encode(Short incoming) {
-    return ByteBuffer.allocate(Short.BYTES).putShort(incoming).array();
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.SHORT;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
b/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
deleted file mode 100644
index 027f4ca..0000000
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/codec/StringCodec.java
+++ /dev/null
@@ -1,41 +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.geode.serialization.codec;
-
-import java.nio.charset.Charset;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.geode.serialization.TypeCodec;
-
-@Experimental
-public class StringCodec implements TypeCodec<String> {
-  private static final Charset UTF8 = Charset.forName("UTF-8");
-
-  @Override
-  public String decode(byte[] incoming) {
-    return new String(incoming, UTF8);
-  }
-
-  @Override
-  public byte[] encode(String incoming) {
-    return incoming.getBytes(UTF8);
-  }
-
-  @Override
-  public SerializationType getSerializationType() {
-    return SerializationType.STRING;
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/proto/region_API.proto
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/proto/region_API.proto b/geode-protobuf/src/main/proto/region_API.proto
index 40bf882..7900f5e 100644
--- a/geode-protobuf/src/main/proto/region_API.proto
+++ b/geode-protobuf/src/main/proto/region_API.proto
@@ -58,6 +58,7 @@ message GetAllRequest {
 
 message GetAllResponse {
     repeated Entry entries = 1;
+    repeated KeyedErrorResponse failedKeys = 2;
 }
 
 message RemoveRequest {

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
deleted file mode 100644
index b6ec564..0000000
--- a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.operations.OperationHandler
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
deleted file mode 100644
index 2a9af4e..0000000
--- a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.protocol.serializer.ProtocolSerializer
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
index 1b7b333..fed6cd0 100644
--- a/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
+++ b/geode-protobuf/src/main/resources/META-INF/services/org.apache.geode.serialization.TypeCodec
@@ -1,10 +1 @@
-org.apache.geode.serialization.codec.BinaryCodec
-org.apache.geode.serialization.codec.BooleanCodec
-org.apache.geode.serialization.codec.ByteCodec
-org.apache.geode.serialization.codec.DoubleCodec
-org.apache.geode.serialization.codec.FloatCodec
-org.apache.geode.serialization.codec.IntCodec
 org.apache.geode.serialization.codec.JSONCodec
-org.apache.geode.serialization.codec.LongCodec
-org.apache.geode.serialization.codec.ShortCodec
-org.apache.geode.serialization.codec.StringCodec

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java
index 64ee50b..cb6592a 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java
@@ -35,7 +35,6 @@ import org.apache.geode.protocol.protobuf.Result;
 import org.apache.geode.protocol.protobuf.Success;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufRequestUtilities;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufUtilities;
-import org.apache.geode.serialization.codec.StringCodec;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
@@ -51,7 +50,6 @@ public class GetAllRequestOperationHandlerJUnitTest extends OperationHandlerJUni
   private static final String TEST_KEY3 = "my key3";
   private static final String TEST_VALUE3 = "my value3";
   private static final String TEST_REGION = "test region";
-  private StringCodec stringDecoder;
 
   @Before
   public void setUp() throws Exception {
@@ -74,7 +72,6 @@ public class GetAllRequestOperationHandlerJUnitTest extends OperationHandlerJUni
 
     when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
     operationHandler = new GetAllRequestOperationHandler();
-    stringDecoder = new StringCodec();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
index 6885666..e2eb8dd 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java
@@ -26,7 +26,6 @@ import org.apache.geode.protocol.protobuf.Result;
 import org.apache.geode.protocol.protobuf.Success;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufRequestUtilities;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufUtilities;
-import org.apache.geode.serialization.codec.StringCodec;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
@@ -50,7 +49,6 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe
   private final String MISSING_REGION = "missing region";
   private final String MISSING_KEY = "missing key";
   private final String NULLED_KEY = "nulled key";
-  private StringCodec stringDecoder;
 
   @Before
   public void setUp() throws Exception {
@@ -66,7 +64,6 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe
     when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
     when(cacheStub.getRegion(MISSING_REGION)).thenReturn(null);
     operationHandler = new GetRequestOperationHandler();
-    stringDecoder = new StringCodec();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java
index 4350ece..e0ee9ec 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java
@@ -27,7 +27,6 @@ import org.apache.geode.protocol.protobuf.Result;
 import org.apache.geode.protocol.protobuf.Success;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufRequestUtilities;
 import org.apache.geode.protocol.protobuf.utilities.ProtobufUtilities;
-import org.apache.geode.serialization.codec.StringCodec;
 import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException;
 import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException;
 import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException;
@@ -52,7 +51,6 @@ public class RemoveRequestOperationHandlerJUnitTest extends OperationHandlerJUni
   private final String TEST_REGION = "test region";
   private final String MISSING_REGION = "missing region";
   private final String MISSING_KEY = "missing key";
-  private StringCodec stringDecoder;
   private Region regionStub;
 
   @Before
@@ -67,7 +65,6 @@ public class RemoveRequestOperationHandlerJUnitTest extends OperationHandlerJUni
     when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub);
     when(cacheStub.getRegion(MISSING_REGION)).thenReturn(null);
     operationHandler = new RemoveRequestOperationHandler();
-    stringDecoder = new StringCodec();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
index 0f6435a..c1b6a04 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java
@@ -14,22 +14,20 @@
  */
 package org.apache.geode.protocol.serializer;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ServiceLoader;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 import org.apache.geode.protocol.MessageUtil;
 import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 
 @Category(UnitTest.class)
 public class ProtobufProtocolSerializerJUnitTest {
@@ -37,12 +35,7 @@ public class ProtobufProtocolSerializerJUnitTest {
 
   @Before
   public void startup() {
-    ServiceLoader<ProtocolSerializer> serviceLoader = ServiceLoader.load(ProtocolSerializer.class);
-    for (ProtocolSerializer protocolSerializer : serviceLoader) {
-      if (protocolSerializer instanceof ProtobufProtocolSerializer) {
-        this.protocolSerializer = protocolSerializer;
-      }
-    }
+    this.protocolSerializer = new ProtobufProtocolSerializer();
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
deleted file mode 100644
index 4d749ab..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java
+++ /dev/null
@@ -1,65 +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.geode.serialization.codec;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-import java.nio.charset.Charset;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class BinaryFormatJUnitTest {
-  private static final Charset UTF8 = Charset.forName("UTF-8");
-  private static final Charset UTF16 = Charset.forName("UTF-16");
-  private String testString = "Test String";
-
-  private StringCodec stringCodec;
-
-  @Before
-  public void startup() {
-    stringCodec = new StringCodec();
-  }
-
-  @Test
-  public void testStringsUseUTF8Encoding() {
-    assertArrayEquals(testString.getBytes(UTF8), stringCodec.encode(testString));
-  }
-
-  @Test
-  public void testStringDontUseUTF16Encoding() {
-    byte[] expectedEncodedString = stringCodec.encode(testString);
-    byte[] incorrectEncodedString = testString.getBytes(UTF16);
-    assertNotEquals(expectedEncodedString.length, incorrectEncodedString.length);
-  }
-
-  @Test
-  public void testImproperlyEncodedStringDecodingFails() {
-    byte[] encodedString = testString.getBytes(UTF16);
-    assertNotEquals(testString, stringCodec.decode(encodedString));
-  }
-
-  @Test
-  public void testProperlyEncodedStringDecoding() {
-    byte[] encodedString = testString.getBytes(UTF8);
-    assertEquals(testString, stringCodec.decode(encodedString));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/42eb4b92/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
new file mode 100644
index 0000000..ebd8ef6
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/JSONCodecJUnitTest.java
@@ -0,0 +1,207 @@
+package org.apache.geode.serialization.codec;
+
+import static java.util.Arrays.asList;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.pdx.JSONFormatter;
+import org.apache.geode.pdx.PdxInstance;
+import org.apache.geode.pdx.PdxInstanceFactory;
+import org.apache.geode.pdx.WritablePdxInstance;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+
+@Category(UnitTest.class)
+public class JSONCodecJUnitTest {
+
+  private String complexJSONString = "{\n" + "    \"_id\": \"599c7d885df276ac3e0bf10a\",\n"
+      + "    \"index\": 0,\n" + "    \"guid\": \"395902d8-36ed-4178-ad70-2f720c557c55\",\n"
+      + "    \"isActive\": true,\n" + "    \"balance\": \"$3,152.82\",\n"
+      + "    \"picture\": \"http://placehold.it/32x32\",\n" + "    \"age\": 27,\n"
+      + "    \"eyeColor\": \"blue\",\n" + "    \"name\": \"Kristina Norman\",\n"
+      + "    \"gender\": \"female\",\n" + "    \"company\": \"ORBALIX\",\n"
+      + "    \"email\": \"kristinanorman@orbalix.com\",\n"
+      + "    \"phone\": \"+1 (983) 526-3433\",\n"
+      + "    \"address\": \"400 Vermont Court, Denio, Wyoming, 7142\",\n"
+      + "    \"about\": \"Mollit nostrud irure excepteur veniam aliqua. Non id tempor magna
nisi ipsum minim. Culpa velit tempor culpa mollit cillum deserunt nisi culpa irure ut nostrud
enim consectetur voluptate. Elit veniam velit enim minim. Sunt nostrud ea duis enim sit cillum.\",\n"
+      + "    \"registered\": \"2015-03-11T02:22:45 +07:00\",\n" + "    \"latitude\": -0.853065,\n"
+      + "    \"longitude\": -29.749358,\n" + "    \"tags\": [\n" + "      \"laboris\",\n"
+      + "      \"velit\",\n" + "      \"non\",\n" + "      \"est\",\n" + "      \"anim\",\n"
+      + "      \"amet\",\n" + "      \"cupidatat\"\n" + "    ],\n" + "    \"friends\": [\n"
+      + "      {\n" + "        \"id\": 0,\n" + "        \"name\": \"Roseann Roy\"\n" + "
     },\n"
+      + "      {\n" + "        \"id\": 1,\n" + "        \"name\": \"Adriana Perry\"\n"
+      + "      },\n" + "      {\n" + "        \"id\": 2,\n"
+      + "        \"name\": \"Tyler Mccarthy\"\n" + "      }\n" + "    ],\n"
+      + "    \"greeting\": \"Hello, Kristina Norman! You have 8 unread messages.\",\n"
+      + "    \"favoriteFruit\": \"apple\"\n" + "  }";
+  private Cache cache;
+
+  @Before
+  public void setUp() throws Exception {
+    cache = new CacheFactory().create();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (cache != null) {
+      cache.close();
+    }
+  }
+
+  @Test
+  public void testSimpleJSONEncode() throws Exception {
+    InternalCache cache = (InternalCache) new CacheFactory().create();
+    PdxInstanceFactory pdxInstanceFactory =
+        cache.createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME, false);
+
+    pdxInstanceFactory.writeString("string", "someString");
+    pdxInstanceFactory.writeBoolean("boolean", true);
+    PdxInstance pdxInstance = pdxInstanceFactory.create();
+
+    byte[] encodedJSONByte = new JSONCodec().encode(pdxInstance);
+
+    String expectedJsonString =
+        "{\n" + "  \"string\" : \"someString\",\n" + "  \"boolean\" : true\n" + "}";
+    assertArrayEquals(expectedJsonString.getBytes(), encodedJSONByte);
+  }
+
+  @Test
+  public void testComplexJSONEncode() {
+    PdxInstance pdxInstanceForComplexJSONString = createPDXInstanceForComplexJSONString();
+    PdxInstance decodedJSONPdxInstance = new JSONCodec().decode(complexJSONString.getBytes());
+
+    assertEquals(pdxInstanceForComplexJSONString.getFieldNames(),
+        decodedJSONPdxInstance.getFieldNames());
+
+    List<String> fieldNames = asList("_id", "index", "guid", "isActive", "balance",
"picture",
+        "age", "eyeColor", "name", "gender", "company", "email", "phone", "address", "about",
+        "registered", "latitude", "longitude", "tags", "friends", "greeting", "favoriteFruit");
+    fieldNames.forEach(
+        fieldName -> assertEquals(pdxInstanceForComplexJSONString.getField(fieldName).getClass(),
+            decodedJSONPdxInstance.getField(fieldName).getClass()));
+
+    fieldNames.forEach(
+        fieldName -> assertEquals(pdxFieldValues(pdxInstanceForComplexJSONString, fieldName),
+            pdxFieldValues(decodedJSONPdxInstance, fieldName)));
+  }
+
+  /**
+   * This method is very specific to this test. It will take an pdxInstance object and return
you
+   * the value for the fieldName. In most cases it will return the value directly, but in
the case
+   * of collections LinkedList<String> it will return an ArrayList<String> or
in the case of a
+   * LinkedList<PdxInstance> it will return an ArrayList<ArrayList>.
+   */
+  private Object pdxFieldValues(PdxInstance pdxInstance, String fieldName) {
+    Object fieldValue = pdxInstance.getField(fieldName);
+    // Check if the value is of type PDXInstance. If so, then iterate over its fields and
return an
+    // ArrayList of all the values
+    if (fieldValue instanceof PdxInstance) {
+      ArrayList<Object> objects = new ArrayList<>();
+      ((PdxInstance) fieldValue).getFieldNames().forEach(
+          innerFieldName -> objects.add(pdxFieldValues((PdxInstance) fieldValue, innerFieldName)));
+      return objects;
+    }
+    // Else check if the value is of type LinkedList. Then it is a collection of either type
String
+    // or type PDXInstance. If of type String, then return an ArrayList<String> otherwise
the
+    // collection
+    // contains a collection of PdxInstance.
+    else if (fieldValue instanceof LinkedList) {
+      LinkedList value = (LinkedList) fieldValue;
+      // if the first value of the LinkedList is not a PDXInstance return the LinkedList
+      if (!value.isEmpty() && !(value.getFirst() instanceof PdxInstance)) {
+        return value;
+      } else {
+        // Here the LinkedList contains PDXInstances. Here we will iterate the linkedList
and
+        // process
+        // each pdxInstance into and ArrayList of the pdx's values.
+        ArrayList<Object> objects = new ArrayList<>();
+        value.forEach(internalPdxInstance -> {
+          ArrayList innerObject = new ArrayList();
+          ((PdxInstance) internalPdxInstance).getFieldNames()
+              .forEach(internalFieldName -> innerObject
+                  .add(pdxFieldValues((PdxInstance) internalPdxInstance, internalFieldName)));
+          objects.add(innerObject);
+          objects.sort((Comparator) (o1, o2) -> (byte) ((ArrayList) o1).get(0));
+        });
+        return objects;
+      }
+    }
+    // Otherwise if the field is not a PdxInstance or LinkedList, then return the value.
+    else {
+      return fieldValue;
+    }
+  }
+
+  /**
+   * Create a PDXInstance object that is equivalent to @link{complexJSONString}
+   */
+  private PdxInstance createPDXInstanceForComplexJSONString() {
+    PdxInstanceFactory friendPdxFactory =
+        ((InternalCache) cache).createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME, false);
+
+    friendPdxFactory.writeByte("id", (byte) 0);
+    PdxInstance friendPdx1 = friendPdxFactory.writeString("name", "Roseann Roy").create();
+
+    WritablePdxInstance friendPdx2 = friendPdx1.createWriter();
+    friendPdx2.setField("id", (byte) 1);
+    friendPdx2.setField("name", "Adriana Perry");
+
+    WritablePdxInstance friendPdx3 = friendPdx1.createWriter();
+    friendPdx3.setField("id", (byte) 2);
+    friendPdx3.setField("name", "Tyler Mccarthy");
+
+    PdxInstanceFactory pdxInstanceFactory =
+        cache.createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME);
+    pdxInstanceFactory.writeString("_id", "599c7d885df276ac3e0bf10a");
+    pdxInstanceFactory.writeByte("index", (byte) 0);
+    pdxInstanceFactory.writeString("guid", "395902d8-36ed-4178-ad70-2f720c557c55");
+    pdxInstanceFactory.writeBoolean("isActive", true);
+    pdxInstanceFactory.writeString("balance", "$3,152.82");
+    pdxInstanceFactory.writeString("picture", "http://placehold.it/32x32");
+    pdxInstanceFactory.writeByte("age", (byte) 27);
+    pdxInstanceFactory.writeString("eyeColor", "blue");
+    pdxInstanceFactory.writeString("name", "Kristina Norman");
+    pdxInstanceFactory.writeString("gender", "female");
+    pdxInstanceFactory.writeString("company", "ORBALIX");
+    pdxInstanceFactory.writeString("email", "kristinanorman@orbalix.com");
+    pdxInstanceFactory.writeString("phone", "+1 (983) 526-3433");
+    pdxInstanceFactory.writeString("address", "400 Vermont Court, Denio, Wyoming, 7142");
+    pdxInstanceFactory.writeString("about",
+        "Mollit nostrud irure excepteur veniam aliqua. Non id tempor magna nisi ipsum minim.
Culpa velit tempor culpa mollit cillum deserunt nisi culpa irure ut nostrud enim consectetur
voluptate. Elit veniam velit enim minim. Sunt nostrud ea duis enim sit cillum.");
+    pdxInstanceFactory.writeString("registered", "2015-03-11T02:22:45 +07:00");
+    pdxInstanceFactory.writeDouble("latitude", -0.853065);
+    pdxInstanceFactory.writeDouble("longitude", -29.749358);
+    pdxInstanceFactory.writeObject("tags",
+        new LinkedList<>(asList("laboris", "velit", "non", "est", "anim", "amet", "cupidatat")));
+    pdxInstanceFactory.writeObject("friends",
+        new LinkedList<>(asList(friendPdx1, friendPdx2, friendPdx3)));
+    pdxInstanceFactory.writeString("greeting",
+        "Hello, Kristina Norman! You have 8 unread messages.");
+    pdxInstanceFactory.writeString("favoriteFruit", "apple");
+    return pdxInstanceFactory.create();
+  }
+
+  @Test
+  public void testJSONDecode() throws Exception {
+    PdxInstance pdxInstance = new JSONCodec().decode(complexJSONString.getBytes());
+
+    assertNotNull(pdxInstance);
+    List<String> fieldNames = asList("_id", "index", "guid", "isActive", "balance",
"picture",
+        "age", "eyeColor", "name", "gender", "company", "email", "phone", "address", "about",
+        "registered", "latitude", "longitude", "tags", "friends", "greeting", "favoriteFruit");
+    assertEquals(fieldNames, pdxInstance.getFieldNames());
+  }
+
+}


Mime
View raw message