You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2017/08/25 17:08:04 UTC

[1/3] geode git commit: GEODE-3503: Removal of Codec classes left behind. Added tests to test the remaining JSONCodec.

Repository: geode
Updated Branches:
  refs/heads/develop 343491bbe -> d775dfb3b


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/51338e47
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/51338e47
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/51338e47

Branch: refs/heads/develop
Commit: 51338e4764e3708e184c30cd90ac1ad359279aa7
Parents: 343491b
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Aug 23 13:48:11 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Aug 25 10:00:14 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/51338e47/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/51338e47/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/51338e47/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/51338e47/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/51338e47/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/51338e47/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/51338e47/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/51338e47/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/51338e47/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/51338e47/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 77a164b..d44d3dd 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/51338e47/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/51338e47/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/51338e47/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/51338e47/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 582dcb2..9b25fdb 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/51338e47/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 d5272e8..0b834ed 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/51338e47/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 41b806e..c952c41 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/51338e47/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 af5b54e..776f89d 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.internal.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/51338e47/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/51338e47/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());
+  }
+
+}


[2/3] geode git commit: GEODE-3503: fixed tests and reverted change to region_API.proto

Posted by ud...@apache.org.
GEODE-3503: fixed tests and reverted change to region_API.proto


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

Branch: refs/heads/develop
Commit: cbe51bd1a0ed32a7ea33f18d181e73bbb8a157fa
Parents: 51338e4
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Wed Aug 23 17:02:12 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Aug 25 10:00:57 2017 -0700

----------------------------------------------------------------------
 geode-protobuf/src/main/proto/region_API.proto  |  1 -
 .../protocol/AuthenticationIntegrationTest.java | 27 +++++++---------
 .../RoundTripCacheConnectionJUnitTest.java      |  9 +++++-
 .../RoundTripLocatorConnectionJUnitTest.java    | 34 ++++++--------------
 .../serialization/codec/JSONCodecJUnitTest.java | 25 ++++++++++++--
 .../registry/CodecRegistryJUnitTest.java        |  4 +--
 6 files changed, 53 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/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 d44d3dd..77a164b 100644
--- a/geode-protobuf/src/main/proto/region_API.proto
+++ b/geode-protobuf/src/main/proto/region_API.proto
@@ -58,7 +58,6 @@ message GetAllRequest {
 
 message GetAllResponse {
     repeated Entry entries = 1;
-    repeated KeyedErrorResponse failedKeys = 2;
 }
 
 message RemoveRequest {

http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
index afd5de1..122b8e3 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/AuthenticationIntegrationTest.java
@@ -17,11 +17,11 @@ package org.apache.geode.protocol;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.internal.security.ResourceConstants;
 import org.apache.geode.internal.protocol.protobuf.AuthenticationAPI;
 import org.apache.geode.internal.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.ProtobufSerializationService;
 import org.apache.geode.internal.protocol.protobuf.RegionAPI;
 import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.security.SecurityManager;
@@ -56,16 +56,9 @@ public class AuthenticationIntegrationTest {
   @Rule
   public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
 
-  private Cache cache;
-  private int cacheServerPort;
-  private CacheServer cacheServer;
-  private Socket socket;
   private OutputStream outputStream;
-  private ProtobufSerializationService serializationService;
   private InputStream inputStream;
   private ProtobufProtocolSerializer protobufProtocolSerializer;
-  private Object securityPrincipal;
-  private SecurityManager mockSecurityManager;
 
   public void setUp(String authenticationMode)
       throws IOException, CodecAlreadyRegisteredForTypeException {
@@ -73,34 +66,36 @@ public class AuthenticationIntegrationTest {
     expectedAuthProperties.setProperty(ResourceConstants.USER_NAME, TEST_USERNAME);
     expectedAuthProperties.setProperty(ResourceConstants.PASSWORD, TEST_PASSWORD);
 
-    securityPrincipal = new Object();
-    mockSecurityManager = mock(SecurityManager.class);
+    Object securityPrincipal = new Object();
+    SecurityManager mockSecurityManager = mock(SecurityManager.class);
     when(mockSecurityManager.authenticate(expectedAuthProperties)).thenReturn(securityPrincipal);
     when(mockSecurityManager.authorize(same(securityPrincipal), any())).thenReturn(true);
 
     Properties properties = new Properties();
     CacheFactory cacheFactory = new CacheFactory(properties);
-    cacheFactory.set("mcast-port", "0"); // sometimes it isn't due to other tests.
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0"); // sometimes it isn't due to other
+                                                               // tests.
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false");
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
 
     cacheFactory.setSecurityManager(mockSecurityManager);
-    cache = cacheFactory.create();
+    Cache cache = cacheFactory.create();
 
-    cacheServer = cache.addCacheServer();
-    cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    CacheServer cacheServer = cache.addCacheServer();
+    int cacheServerPort = AvailablePortHelper.getRandomAvailableTCPPort();
     cacheServer.setPort(cacheServerPort);
     cacheServer.start();
 
 
     System.setProperty("geode.feature-protobuf-protocol", "true");
     System.setProperty("geode.protocol-authentication-mode", authenticationMode);
-    socket = new Socket("localhost", cacheServerPort);
+    Socket socket = new Socket("localhost", cacheServerPort);
 
     Awaitility.await().atMost(5, TimeUnit.SECONDS).until(socket::isConnected);
     outputStream = socket.getOutputStream();
     inputStream = socket.getInputStream();
     outputStream.write(110);
 
-    serializationService = new ProtobufSerializationService();
     protobufProtocolSerializer = new ProtobufProtocolSerializer();
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
index a7d633e..91e839c 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
@@ -122,7 +122,14 @@ public class RoundTripCacheConnectionJUnitTest {
     }
 
     CacheFactory cacheFactory = new CacheFactory(properties);
-    cacheFactory.set("mcast-port", "0"); // sometimes it isn't due to other tests.
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0"); // sometimes it isn't due to other
+                                                               // tests.
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false"); // sometimes it
+                                                                                     // isn't due to
+                                                                                     // other tests.
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false"); // sometimes it
+                                                                                  // isn't due to
+                                                                                  // other tests.
     cache = cacheFactory.create();
 
     CacheServer cacheServer = cache.addCacheServer();

http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
index 019210b..7ee307b 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripLocatorConnectionJUnitTest.java
@@ -15,31 +15,9 @@
 
 package org.apache.geode.protocol;
 
-import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
-import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION;
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
-import static org.apache.geode.distributed.ConfigurationProperties.MAX_WAIT_TIME_RECONNECT;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.MEMBER_TIMEOUT;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.Socket;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.distributed.Locator;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
 import org.apache.geode.protocol.exception.InvalidProtocolMessageException;
@@ -53,12 +31,20 @@ import org.apache.geode.test.dunit.DistributedTestUtils;
 import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.Socket;
 
 @Category(DistributedTest.class)
 public class RoundTripLocatorConnectionJUnitTest extends JUnit4CacheTestCase {
 
   private Socket socket;
-  private DataOutputStream dataOutputStream;
 
   @Rule
   public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
@@ -72,7 +58,7 @@ public class RoundTripLocatorConnectionJUnitTest extends JUnit4CacheTestCase {
     Host.getLocator().invoke(() -> System.setProperty("geode.feature-protobuf-protocol", "true"));
 
     socket = new Socket(host.getHostName(), locatorPort);
-    dataOutputStream = new DataOutputStream(socket.getOutputStream());
+    DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
     dataOutputStream.writeInt(0);
     // Using the constant from AcceptorImpl to ensure that magic byte is the same
     dataOutputStream.writeByte(AcceptorImpl.PROTOBUF_CLIENT_SERVER_PROTOCOL);

http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/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
index ebd8ef6..ffdd744 100644
--- 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
@@ -1,3 +1,17 @@
+/*
+ * 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 java.util.Arrays.asList;
@@ -7,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.pdx.JSONFormatter;
 import org.apache.geode.pdx.PdxInstance;
@@ -50,7 +66,11 @@ public class JSONCodecJUnitTest {
 
   @Before
   public void setUp() throws Exception {
-    cache = new CacheFactory().create();
+    CacheFactory cacheFactory = new CacheFactory();
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0");
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false");
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
+    cache = cacheFactory.create();
   }
 
   @After
@@ -62,9 +82,8 @@ public class JSONCodecJUnitTest {
 
   @Test
   public void testSimpleJSONEncode() throws Exception {
-    InternalCache cache = (InternalCache) new CacheFactory().create();
     PdxInstanceFactory pdxInstanceFactory =
-        cache.createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME, false);
+        ((GemFireCacheImpl) cache).createPdxInstanceFactory(JSONFormatter.JSON_CLASSNAME, false);
 
     pdxInstanceFactory.writeString("string", "someString");
     pdxInstanceFactory.writeBoolean("boolean", true);

http://git-wip-us.apache.org/repos/asf/geode/blob/cbe51bd1/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
index 578d263..935c886 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/registry/CodecRegistryJUnitTest.java
@@ -50,10 +50,10 @@ public class CodecRegistryJUnitTest {
 
   @Test
   public void testRegisterCodec() throws CodecAlreadyRegisteredForTypeException {
-    Assert.assertEquals(10, codecRegistry.getRegisteredCodecCount());
+    Assert.assertEquals(1, codecRegistry.getRegisteredCodecCount());
     SerializationType mockSerializationType = PowerMockito.mock(SerializationType.class);
     codecRegistry.register(mockSerializationType, new DummyTypeCodec());
-    Assert.assertEquals(11, codecRegistry.getRegisteredCodecCount());
+    Assert.assertEquals(2, codecRegistry.getRegisteredCodecCount());
   }
 
   @Test


[3/3] geode git commit: GEODE-3503: Removal of Codec classes left behind. This closes #737 Added tests to test the remaining JSONCodec.

Posted by ud...@apache.org.
GEODE-3503: Removal of Codec classes left behind. This closes #737
    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/d775dfb3
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d775dfb3
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d775dfb3

Branch: refs/heads/develop
Commit: d775dfb3b68e1f800bcfe7f92af048b26a1fb1a5
Parents: cbe51bd
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Aug 25 09:58:46 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Aug 25 10:07:34 2017 -0700

----------------------------------------------------------------------
 .../geode/serialization/SerializationType.java  | 11 +------
 .../RoundTripCacheConnectionJUnitTest.java      | 11 ++-----
 .../serialization/codec/JSONCodecJUnitTest.java | 31 +++++++++++---------
 3 files changed, 21 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d775dfb3/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
index 10a3e51..01ef048 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/serialization/SerializationType.java
@@ -22,16 +22,7 @@ import org.apache.geode.pdx.PdxInstance;
  */
 @Experimental
 public enum SerializationType {
-  STRING(String.class),
-  BINARY(byte[].class),
-  INT(int.class),
-  BYTE(byte.class),
-  SHORT(short.class),
-  LONG(long.class),
-  JSON(PdxInstance.class),
-  BOOLEAN(boolean.class),
-  FLOAT(float.class),
-  DOUBLE(double.class);
+  JSON(PdxInstance.class);
 
   public final Class klass;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/d775dfb3/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
index 91e839c..b80e90e 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java
@@ -122,14 +122,9 @@ public class RoundTripCacheConnectionJUnitTest {
     }
 
     CacheFactory cacheFactory = new CacheFactory(properties);
-    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0"); // sometimes it isn't due to other
-                                                               // tests.
-    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false"); // sometimes it
-                                                                                     // isn't due to
-                                                                                     // other tests.
-    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false"); // sometimes it
-                                                                                  // isn't due to
-                                                                                  // other tests.
+    cacheFactory.set(ConfigurationProperties.MCAST_PORT, "0");
+    cacheFactory.set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
+    cacheFactory.set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false");
     cache = cacheFactory.create();
 
     CacheServer cacheServer = cache.addCacheServer();

http://git-wip-us.apache.org/repos/asf/geode/blob/d775dfb3/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
index ffdd744..bb7169e 100644
--- 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
@@ -101,26 +101,29 @@ public class JSONCodecJUnitTest {
     PdxInstance pdxInstanceForComplexJSONString = createPDXInstanceForComplexJSONString();
     PdxInstance decodedJSONPdxInstance = new JSONCodec().decode(complexJSONString.getBytes());
 
-    assertEquals(pdxInstanceForComplexJSONString.getFieldNames(),
-        decodedJSONPdxInstance.getFieldNames());
+    pdxInstanceEquals(pdxInstanceForComplexJSONString, decodedJSONPdxInstance);
+  }
 
-    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()));
+  private void pdxInstanceEquals(PdxInstance expectedPdxInstance,
+                                 PdxInstance decodedJSONPdxInstance) {
+    List<String> expectedFieldNames = expectedPdxInstance.getFieldNames();
+
+    assertEquals(expectedFieldNames, decodedJSONPdxInstance.getFieldNames());
 
-    fieldNames.forEach(
-        fieldName -> assertEquals(pdxFieldValues(pdxInstanceForComplexJSONString, fieldName),
-            pdxFieldValues(decodedJSONPdxInstance, fieldName)));
+    expectedFieldNames.forEach(
+        fieldName -> {
+          assertEquals(expectedPdxInstance.getField(fieldName).getClass(),
+              decodedJSONPdxInstance.getField(fieldName).getClass());
+          assertEquals(pdxFieldValues(expectedPdxInstance, fieldName),
+              pdxFieldValues(decodedJSONPdxInstance, fieldName));
+        });
   }
 
   /**
-   * This method is very specific to this test. It will take an pdxInstance object and return you
+   * This method is very specific to this test. It will take a 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>.
+   * of collections LinkedList&lt;String&gt; it will return an ArrayList&lt;String&gt; or in the case of a
+   * LinkedList&lt;PdxInstance&gt; it will return an ArrayList&lt;ArrayList&lt;String&gt;&gt;.
    */
   private Object pdxFieldValues(PdxInstance pdxInstance, String fieldName) {
     Object fieldValue = pdxInstance.getField(fieldName);