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/05/23 23:41:26 UTC

[1/2] geode git commit: GEODE-2580 : Pre Kotlin conversion

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2580 2ccedd062 -> 6a5e4be30


GEODE-2580 : Pre Kotlin conversion


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

Branch: refs/heads/feature/GEODE-2580
Commit: c1e22f3757f96e8bf100bd4dd39819e142782e9a
Parents: 2ccedd0
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Tue May 23 11:47:46 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Tue May 23 11:47:46 2017 -0700

----------------------------------------------------------------------
 geode-client-protobuf/build.gradle              |  14 +-
 .../geode/protocol/client/EncodingTypeThingy.kt |  33 ++++
 .../client/NewClientProtocolTestClient.java     |   8 +-
 .../client/ProtobufProtocolMessageHandler.java  | 153 ++++++-------------
 .../src/main/proto/basicTypes.proto             |  35 +++--
 .../src/main/proto/region_API.proto             |  10 +-
 .../geode/protocol/client/MessageUtils.java     |  62 +++-----
 .../client/ProtobufProtocolIntegrationTest.java | 112 +++++++-------
 ...rotobufSerializationDeserializationTest.java |  63 ++++----
 .../sockets/ClientProtocolMessageHandler.java   |   4 +-
 .../cache/tier/sockets/ServerConnection.java    |   4 +-
 .../geode/serialization/Deserializer.java       |   2 +-
 .../geode/serialization/SerializationType.java  |  62 +++++++-
 .../apache/geode/serialization/Serializer.java  |   2 +-
 .../serialization/SerializationTypeTest.java    | 113 ++++++++++++++
 15 files changed, 402 insertions(+), 275 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/build.gradle
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/build.gradle b/geode-client-protobuf/build.gradle
index c82f311..79932ae 100644
--- a/geode-client-protobuf/build.gradle
+++ b/geode-client-protobuf/build.gradle
@@ -17,19 +17,24 @@
 
 
 apply plugin: 'java'
+apply plugin: 'kotlin'
 apply plugin: 'com.google.protobuf'
 apply plugin: 'idea'
 
 repositories {
   maven { url "https://plugins.gradle.org/m2/" }
+    mavenCentral()
 }
 
 buildscript {
-  repositories {
+    ext.kotlin_version = '1.1.1'
+    repositories {
     maven { url "https://plugins.gradle.org/m2/" }
-  }
+        mavenCentral()
+    }
   dependencies {
     classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1'
+      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
 }
 
@@ -48,9 +53,12 @@ dependencies {
   testCompile project (':geode-junit')
   testCompile "org.mockito:mockito-core:2.+"
   testCompile files(project(':geode-core').sourceSets.test.output)
-  // Extra proto source files for test besides the ones residing under
+    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
+    // Extra proto source files for test besides the ones residing under
   // "src/test".
   //testProtobuf files("lib/protos-test.tar.gz")
+  testCompile 'com.pholser:junit-quickcheck-core:' + project.'junit-quickcheck.version'
+  testCompile 'com.pholser:junit-quickcheck-generators:' + project.'junit-quickcheck.version'
 }
 
 protobuf {

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
new file mode 100644
index 0000000..8d65827
--- /dev/null
+++ b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
@@ -0,0 +1,33 @@
+package org.apache.geode.protocol.client
+
+import org.apache.geode.pdx.JSONFormatter
+import org.apache.geode.pdx.PdxInstance
+import org.apache.geode.protocol.protobuf.BasicTypes
+import org.apache.geode.serialization.SerializationType
+
+fun getEncodingTypeForObjectKT(o: Any?): BasicTypes.EncodingType {
+    return when (o) {
+        is String -> BasicTypes.EncodingType.STRING
+        is Int -> BasicTypes.EncodingType.INT
+        is PdxInstance -> {
+            if (o.className == JSONFormatter.JSON_CLASSNAME) BasicTypes.EncodingType.JSON else BasicTypes.EncodingType.UNRECOGNIZED
+        }
+        is ByteArray -> BasicTypes.EncodingType.BINARY
+        else -> BasicTypes.EncodingType.UNRECOGNIZED
+    }
+}
+
+fun serializerFromProtoEnum(encodingType: BasicTypes.EncodingType): SerializationType {
+    return when (encodingType) {
+        BasicTypes.EncodingType.INT -> SerializationType.INT
+        BasicTypes.EncodingType.LONG -> SerializationType.LONG
+        BasicTypes.EncodingType.SHORT -> SerializationType.SHORT
+        BasicTypes.EncodingType.BYTE -> SerializationType.BYTE
+        BasicTypes.EncodingType.STRING -> SerializationType.STRING
+        BasicTypes.EncodingType.BINARY -> SerializationType.BYTE_BLOB
+        BasicTypes.EncodingType.JSON -> SerializationType.JSON
+        BasicTypes.EncodingType.FLOAT, BasicTypes.EncodingType.BOOLEAN, BasicTypes.EncodingType.DOUBLE -> TODO()
+        else -> TODO()
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/NewClientProtocolTestClient.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/NewClientProtocolTestClient.java b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/NewClientProtocolTestClient.java
index 834d2f6..0b29aa3 100644
--- a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/NewClientProtocolTestClient.java
+++ b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/NewClientProtocolTestClient.java
@@ -73,11 +73,11 @@ public class NewClientProtocolTestClient implements AutoCloseable {
         ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt());
     // .setSize() //we don't need to set the size because Protobuf will handle the message frame
 
-    BasicTypes.Key.Builder key =
-        BasicTypes.Key.newBuilder().setKey(ByteString.copyFrom(createByteArrayOfSize(64)));
+    BasicTypes.EncodedValue.Builder key = BasicTypes.EncodedValue.newBuilder()
+        .setValue(ByteString.copyFrom(createByteArrayOfSize(64)));
 
-    BasicTypes.Value.Builder value =
-        BasicTypes.Value.newBuilder().setValue(ByteString.copyFrom(createByteArrayOfSize(512)));
+    BasicTypes.EncodedValue.Builder value = BasicTypes.EncodedValue.newBuilder()
+        .setValue(ByteString.copyFrom(createByteArrayOfSize(512)));
 
     RegionAPI.PutRequest.Builder putRequestBuilder =
         RegionAPI.PutRequest.newBuilder().setRegionName("TestRegion")

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
index 85de51d..ed9a7e3 100644
--- a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
+++ b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
@@ -15,7 +15,15 @@
 
 package org.apache.geode.protocol.client;
 
+import static org.apache.geode.protocol.client.EncodingTypeThingyKt.getEncodingTypeForObjectKT;
+import static org.apache.geode.protocol.client.EncodingTypeThingyKt.serializerFromProtoEnum;
+import static org.apache.geode.protocol.protobuf.ClientProtocol.Message;
+import static org.apache.geode.protocol.protobuf.ClientProtocol.Request;
+import static org.apache.geode.protocol.protobuf.ClientProtocol.Response;
+import static org.apache.geode.protocol.protobuf.RegionAPI.PutRequest;
+
 import com.google.protobuf.ByteString;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheWriterException;
 import org.apache.geode.cache.Region;
@@ -26,19 +34,13 @@ import org.apache.geode.protocol.protobuf.BasicTypes;
 import org.apache.geode.protocol.protobuf.RegionAPI;
 import org.apache.geode.protocol.protobuf.RegionAPI.GetRequest;
 import org.apache.geode.protocol.protobuf.RegionAPI.PutResponse;
-import org.apache.geode.serialization.Deserializer;
-import org.apache.geode.serialization.Serializer;
+import org.apache.geode.serialization.SerializationType;
 import org.apache.logging.log4j.Logger;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Message;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Request;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Response;
-import static org.apache.geode.protocol.protobuf.RegionAPI.PutRequest;
-
 public class ProtobufProtocolMessageHandler implements ClientProtocolMessageHandler {
 
   private static final Logger logger = LogService.getLogger();
@@ -48,8 +50,8 @@ public class ProtobufProtocolMessageHandler implements ClientProtocolMessageHand
   }
 
   @Override
-  public void receiveMessage(InputStream inputStream, OutputStream outputStream,
-      Deserializer deserializer, Serializer serializer, Cache cache) throws IOException {
+  public void receiveMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
+      throws IOException {
     final Message message = Message.parseDelimitedFrom(inputStream);
     // can be null at EOF, see Parser.parseDelimitedFrom(java.io.InputStream)
     if (message == null) {
@@ -66,9 +68,9 @@ public class ProtobufProtocolMessageHandler implements ClientProtocolMessageHand
     Request request = message.getRequest();
     Request.RequestAPICase requestAPICase = request.getRequestAPICase();
     if (requestAPICase == Request.RequestAPICase.GETREQUEST) {
-      responseMessage = doGetRequest(request.getGetRequest(), deserializer, serializer, cache);
+      responseMessage = doGetRequest(request.getGetRequest(), cache);
     } else if (requestAPICase == Request.RequestAPICase.PUTREQUEST) {
-      responseMessage = doPutRequest(request.getPutRequest(), deserializer, cache);
+      responseMessage = doPutRequest(request.getPutRequest(), cache);
     } else {
       // TODO
     }
@@ -77,16 +79,15 @@ public class ProtobufProtocolMessageHandler implements ClientProtocolMessageHand
     }
   }
 
-  private Message doPutRequest(PutRequest request, Deserializer dataDeserializer, Cache cache) {
+  private Message doPutRequest(PutRequest request, Cache cache) {
     final String regionName = request.getRegionName();
     final BasicTypes.Entry entry = request.getEntry();
-    final ByteString key = entry.getKey().getKey();
-    final ByteString value = entry.getValue().getValue();
+    assert (entry != null);
 
     final Region<Object, Object> region = cache.getRegion(regionName);
     try {
-      region.put(dataDeserializer.deserialize(key.toByteArray()),
-          dataDeserializer.deserialize(value.toByteArray()));
+      region.put(deserializeEncodedValue(entry.getKey()),
+          deserializeEncodedValue(entry.getValue()));
       return putResponseWithStatus(true);
     } catch (TimeoutException | CacheWriterException ex) {
       logger.warn("Caught normal-ish exception doing region put", ex);
@@ -94,111 +95,53 @@ public class ProtobufProtocolMessageHandler implements ClientProtocolMessageHand
     }
   }
 
+  private Object deserializeEncodedValue(BasicTypes.EncodedValue encodedValue) {
+    assert (encodedValue != null);
+    SerializationType serializer = serializerFromProtoEnum(encodedValue.getEncodingType());
+    return serializer.deserialize(encodedValue.getValue().toByteArray());
+  }
+
+  private byte[] serializeEncodedValue(BasicTypes.EncodingType encodingType,
+      Object objectToSerialize) {
+    if (objectToSerialize == null) {
+      return null; // BLECH!!! :(
+    }
+    SerializationType serializer = serializerFromProtoEnum(encodingType);
+    return serializer.serialize(objectToSerialize);
+  }
+
   private Message putResponseWithStatus(boolean ok) {
     return Message.newBuilder()
         .setResponse(Response.newBuilder().setPutResponse(PutResponse.newBuilder().setSuccess(ok)))
         .build();
   }
 
-  private Message doGetRequest(GetRequest request, Deserializer deserializer, Serializer serializer,
-      Cache cache) {
-    String regionName = request.getRegionName();
-    BasicTypes.Key key = request.getKey();
-    byte[] keyBytes = key.getKey().toByteArray();
-    Region<Object, Object> region = cache.getRegion(regionName);
-
-    Object returnValue = region.get(deserializer.deserialize(keyBytes));
+  private Message doGetRequest(GetRequest request, Cache cache) {
+    Region<Object, Object> region = cache.getRegion(request.getRegionName());
+    Object returnValue = region.get(deserializeEncodedValue(request.getKey()));
 
     if (returnValue == null) {
-      return getResponseWithValue(new byte[0]);
+
+      return makeGetResponseMessageWithValue(new byte[0]);
     } else {
       // TODO types in the region?
-      return getResponseWithValue(serializer.serialize(returnValue));
+      return makeGetResponseMessageWithValue(returnValue);
     }
   }
 
-  private Message getResponseWithValue(byte[] value) {
+  private BasicTypes.EncodingType getEncodingTypeForObject(Object object) {
+    return getEncodingTypeForObjectKT(object);
+  }
+
+  private Message makeGetResponseMessageWithValue(Object objectToReturn) {
+    BasicTypes.EncodingType encodingType = getEncodingTypeForObject(objectToReturn);
+    byte[] serializedObject = serializeEncodedValue(encodingType, objectToReturn);
     return Message.newBuilder()
         .setResponse(Response.newBuilder()
             .setGetResponse(RegionAPI.GetResponse.newBuilder()
-                .setResult(BasicTypes.Value.newBuilder().setValue(ByteString.copyFrom(value)))))
+                .setResult(BasicTypes.EncodedValue.newBuilder()
+                    .setEncodingType(BasicTypes.EncodingType.STRING)
+                    .setValue(ByteString.copyFrom(serializedObject)))))
         .build();
   }
-
-  public ProtobufProtocolMessageHandler() {}
 }
-
-
-// public final class NewClientProtocol {
-// public static void recvMessage(Cache cache, InputStream inputStream, OutputStream outputStream) {
-// try {
-// final DataInputStream dataInputStream = new DataInputStream(inputStream);
-// final DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
-//
-// RequestHeader header = new RequestHeader(dataInputStream);
-//
-// // todo: string -- assume UTF-8 from here.
-// // Java modified UTF-8: unsigned short len. hope we don't run into the "modified" part.
-// switch (header.requestType) {
-// case MessageType.PUT:
-// servePutRequest(header, cache, dataInputStream, dataOutputStream);
-// break;
-// case MessageType.REQUEST: // this is a GET request.
-// serveGetRequest(cache, dataInputStream, dataOutputStream);
-// break;
-// }
-// } catch (IOException e) {
-// e.printStackTrace();
-// // todo error handling.
-// }
-// }
-//
-// private static void serveGetRequest(Cache cache, DataInputStream dataInputStream,
-// DataOutputStream dataOutputStream) throws IOException {
-// // GetRequest: Header RegionName Key CallbackArg
-// final String regionName = readString(dataInputStream);
-// final String key = readString(dataInputStream);
-// // todo no callback arg for now
-// final Region<Object, Object> region = cache.getRegion(regionName);
-// // todo anything more complex?
-//
-// Object val = region.get(key);
-// if (val == null) {
-// byte[] bytes = "Entry not found in region.".getBytes();
-// dataOutputStream.writeInt(bytes.length); // len
-// dataOutputStream.writeByte(19); // ENTRY_NOT_FOUND_EXCEPTION
-// dataOutputStream.write(bytes);
-// } else {
-// byte[] bytes = val.toString().getBytes();
-// dataOutputStream.writeInt(bytes.length); // len
-// dataOutputStream.writeByte(1); // RESPONSE
-// dataOutputStream.write(bytes);
-// }
-// dataOutputStream.flush();
-// }
-//
-// // response: size responseType requestId
-//
-// private static void servePutRequest(RequestHeader header, Cache cache,
-// DataInputStream dataInputStream, DataOutputStream dataOutputStream) throws IOException {
-// String regionName = readString(dataInputStream);
-// // assume every object is a string.
-//
-// String key = readString(dataInputStream);
-// // TODO: value header, callback arg?
-// String value = readString(dataInputStream);
-//
-// Region<Object, Object> region = cache.getRegion(regionName);
-// region.put(key, value);
-//
-// dataOutputStream.writeInt(0); // len
-// dataOutputStream.writeByte(1); // RESPONSE
-// dataOutputStream.writeInt(header.requestId);
-// dataOutputStream.flush();
-// }
-//
-// private static String readString(DataInputStream inputStream) throws IOException {
-// String s = inputStream.readUTF();
-// return s;
-// }
-// }

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/main/proto/basicTypes.proto
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/proto/basicTypes.proto b/geode-client-protobuf/src/main/proto/basicTypes.proto
index 7cb4204..2f9568c 100644
--- a/geode-client-protobuf/src/main/proto/basicTypes.proto
+++ b/geode-client-protobuf/src/main/proto/basicTypes.proto
@@ -17,29 +17,36 @@ syntax = "proto3";
 package org.apache.geode.protocol.protobuf;
 
 import "google/protobuf/any.proto";
+import "google/protobuf/empty.proto";
 
-message Entry{
-    Key key = 1;
-    Value value = 2;
+message Entry {
+    EncodedValue key = 1;
+    EncodedValue value = 2;
 }
 
-message Key {
-    bytes key = 1;
-}
 
-message Value {
-    ValueHeader valueHeader = 1;
+message EncodedValue {
+    EncodingType encodingType = 1;
     bytes value = 2;
 }
 
-message ValueHeader {
-    int32 size = 1;
-    bool isPartial = 2;
+enum EncodingType {
+    INVALID = 0;
+    INT = 1;
+    LONG = 2;
+    SHORT = 3;
+    BYTE = 4;
+    BOOLEAN = 5;
+    BINARY = 6;
+    FLOAT = 7;
+    DOUBLE = 8;
+    STRING = 9;
+    JSON = 10;
 }
 
-message CallbackArguments{
+message CallbackArguments {
     oneof callbackArgs {
-        bool hasCallbackArgument = 1;
-        bytes callbackBytes = 2;
+        google.protobuf.Empty hasCallbackArgument = 1;
+        EncodedValue callbackValue = 2;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/main/proto/region_API.proto
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/proto/region_API.proto b/geode-client-protobuf/src/main/proto/region_API.proto
index d46e0e6..cf9536b 100644
--- a/geode-client-protobuf/src/main/proto/region_API.proto
+++ b/geode-client-protobuf/src/main/proto/region_API.proto
@@ -30,12 +30,12 @@ message PutResponse {
 
 message GetRequest {
     string regionName = 1;
-    Key key = 2;
+    EncodedValue key = 2;
     CallbackArguments callbackArg = 3;
 }
 
 message GetResponse {
-    Value result = 1;
+    EncodedValue result = 1;
 }
 
 message PutAllRequest {
@@ -47,14 +47,14 @@ message PutAllRequest {
 
 message PutAllResponse {
     int32 numberOfKeysFailed = 1;
-    repeated Key key = 2;
+    repeated EncodedValue key = 2;
 }
 
 message GetAllRequest {
     string regionName = 1;
     int32 numberOfKeys = 2;
-    repeated Key key = 3;
-    CallbackArguments callbackArg = 4;
+    repeated EncodedValue key = 3;
+    EncodedValue callbackArg = 4;
 }
 
 message GetAllResponse {

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
index 7cb5ffa..250c2f8 100644
--- a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
+++ b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
@@ -15,8 +15,10 @@
 
 package org.apache.geode.protocol.client;
 
-import com.google.protobuf.Any;
+import static org.apache.geode.protocol.client.EncodingTypeThingyKt.serializerFromProtoEnum;
+
 import com.google.protobuf.ByteString;
+
 import org.apache.geode.protocol.protobuf.BasicTypes;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.protocol.protobuf.RegionAPI;
@@ -24,6 +26,7 @@ import org.apache.geode.protocol.protobuf.RegionAPI;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.Random;
 
 public class MessageUtils {
@@ -35,40 +38,29 @@ public class MessageUtils {
     return new ByteArrayInputStream(messageByteArray);
   }
 
-  public static ClientProtocol.Message makePutMessage() {
+  public static ClientProtocol.Message makeGetMessageFor(String region, String key) {
     Random random = new Random();
     ClientProtocol.MessageHeader.Builder messageHeader =
         ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt());
 
-    BasicTypes.Key.Builder key =
-        BasicTypes.Key.newBuilder().setKey(ByteString.copyFrom(createByteArrayOfSize(64)));
-
-    BasicTypes.Value.Builder value =
-        BasicTypes.Value.newBuilder().setValue(ByteString.copyFrom(createByteArrayOfSize(512)));
-
-    RegionAPI.PutRequest.Builder putRequestBuilder =
-        RegionAPI.PutRequest.newBuilder().setRegionName("TestRegion")
-            .setEntry(BasicTypes.Entry.newBuilder().setKey(key).setValue(value));
+    BasicTypes.EncodedValue.Builder keyBuilder = getEncodedValueBuilder(key);
 
+    RegionAPI.GetRequest.Builder getRequest =
+        RegionAPI.GetRequest.newBuilder().setRegionName(region).setKey(keyBuilder);
     ClientProtocol.Request.Builder request =
-        ClientProtocol.Request.newBuilder().setPutRequest(putRequestBuilder);
-
-    ClientProtocol.Message.Builder message =
-        ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request);
+        ClientProtocol.Request.newBuilder().setGetRequest(getRequest);
 
-    return message.build();
+    return ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request)
+        .build();
   }
 
-  public static ClientProtocol.Message makePutMessageFor(String region, String key, String value) {
+  public static ClientProtocol.Message makePutMessageFor(String region, Object key, Object value) {
     Random random = new Random();
     ClientProtocol.MessageHeader.Builder messageHeader =
         ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt());
 
-    BasicTypes.Key.Builder keyBuilder =
-        BasicTypes.Key.newBuilder().setKey(ByteString.copyFromUtf8(key));
-
-    BasicTypes.Value.Builder valueBuilder =
-        BasicTypes.Value.newBuilder().setValue(ByteString.copyFromUtf8(value));
+    BasicTypes.EncodedValue.Builder keyBuilder = getEncodedValueBuilder(key);
+    BasicTypes.EncodedValue.Builder valueBuilder = getEncodedValueBuilder(value);
 
     RegionAPI.PutRequest.Builder putRequestBuilder =
         RegionAPI.PutRequest.newBuilder().setRegionName(region)
@@ -82,28 +74,10 @@ public class MessageUtils {
     return message.build();
   }
 
-  public static ClientProtocol.Message makeGetMessageFor(String region, String key) {
-    Random random = new Random();
-    ClientProtocol.MessageHeader.Builder messageHeader =
-        ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt());
-
-    BasicTypes.Key.Builder keyBuilder =
-        BasicTypes.Key.newBuilder().setKey(ByteString.copyFromUtf8(key));
-
-    RegionAPI.GetRequest.Builder getRequest =
-        RegionAPI.GetRequest.newBuilder().setRegionName(region).setKey(keyBuilder);
-    ClientProtocol.Request.Builder request =
-        ClientProtocol.Request.newBuilder().setGetRequest(getRequest);
-
-    return ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request)
-        .build();
-  }
+  private static BasicTypes.EncodedValue.Builder getEncodedValueBuilder(Object value) {
+    BasicTypes.EncodingType encodingType = EncodingTypeThingyKt.getEncodingTypeForObjectKT(value);
 
-  private static byte[] createByteArrayOfSize(int msgSize) {
-    byte[] array = new byte[msgSize];
-    for (int i = 0; i < msgSize; i++) {
-      array[i] = 'a';
-    }
-    return array;
+    return BasicTypes.EncodedValue.newBuilder().setEncodingType(encodingType)
+        .setValue(ByteString.copyFrom(serializerFromProtoEnum(encodingType).serialize(value)));
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
index 1a9b62e..a9a7407 100644
--- a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
+++ b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
@@ -15,7 +15,13 @@
 
 package org.apache.geode.protocol.client;
 
-import com.google.protobuf.ByteString;
+import static org.apache.geode.protocol.protobuf.ClientProtocol.Message.MessageTypeCase.RESPONSE;
+import static org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.GETRESPONSE;
+import static org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.PUTRESPONSE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import com.pholser.junit.quickcheck.runner.JUnitQuickcheck;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
@@ -24,100 +30,94 @@ import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.protocol.protobuf.BasicTypes;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
 import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 import java.io.IOException;
 import java.util.Properties;
 
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Message.MessageTypeCase.RESPONSE;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.GETRESPONSE;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.PUTRESPONSE;
-import static org.junit.Assert.*;
-
 @Category(IntegrationTest.class)
+@RunWith(JUnitQuickcheck.class)
 public class ProtobufProtocolIntegrationTest {
+  private final static String testRegion = "testRegion";
+  private final static String testKey = "testKey";
+  private final static String testValue = "testValue";
+  private Cache cache;
+  private NewClientProtocolTestClient testClient;
+  private Region<Object, Object> regionUnderTest;
+
+  @Before
+  public void setup() throws IOException {
+    cache = createCacheOnPort(40404);
+    testClient = new NewClientProtocolTestClient("localhost", 40404);
+    regionUnderTest = cache.createRegionFactory().create(testRegion);
+  }
+
+  @After
+  public void shutdown() throws IOException {
+    if (testClient != null) {
+      testClient.close();
+    }
+    if (cache != null) {
+      cache.close();
+    }
+  }
+
   @Test
   public void testRoundTripPutRequest() throws IOException {
-    try (Cache cache = createCacheOnPort(40404);
-        NewClientProtocolTestClient client = new NewClientProtocolTestClient("localhost", 40404)) {
-      final String testRegion = "testRegion";
-      final String testKey = "testKey";
-      final String testValue = "testValue";
-      Region<Object, Object> region = cache.createRegionFactory().create("testRegion");
-
       ClientProtocol.Message message =
-          MessageUtils.makePutMessageFor(testRegion, testKey, testValue);
-      ClientProtocol.Message response = client.blockingSendMessage(message);
-      client.printResponse(response);
+          MessageUtils.INSTANCE.makePutMessageFor(testRegion, testKey, testValue);
+      ClientProtocol.Message response = testClient.blockingSendMessage(message);
+      testClient.printResponse(response);
 
       assertEquals(RESPONSE, response.getMessageTypeCase());
       assertEquals(PUTRESPONSE, response.getResponse().getResponseAPICase());
       assertTrue(response.getResponse().getPutResponse().getSuccess());
 
-      assertEquals(1, region.size());
-      assertTrue(region.containsKey(testKey));
-      assertEquals(testValue, region.get(testKey));
-    }
+      assertEquals(1, regionUnderTest.size());
+      assertTrue(regionUnderTest.containsKey(testKey));
+      assertEquals(testValue, regionUnderTest.get(testKey));
   }
 
   @Test
   public void testRoundTripEmptyGetRequest() throws IOException {
-    try (Cache cache = createCacheOnPort(40404);
-        NewClientProtocolTestClient client = new NewClientProtocolTestClient("localhost", 40404)) {
-      final String testRegion = "testRegion";
-      final String testKey = "testKey";
-      Region<Object, Object> region = cache.createRegionFactory().create("testRegion");
-
-      ClientProtocol.Message message = MessageUtils.makeGetMessageFor(testRegion, testKey);
-      ClientProtocol.Message response = client.blockingSendMessage(message);
+      ClientProtocol.Message message = MessageUtils.INSTANCE.makeGetMessageFor(testRegion, testKey);
+      ClientProtocol.Message response = testClient.blockingSendMessage(message);
 
       assertEquals(RESPONSE, response.getMessageTypeCase());
       assertEquals(GETRESPONSE, response.getResponse().getResponseAPICase());
-      BasicTypes.Value value = response.getResponse().getGetResponse().getResult();
+      BasicTypes.EncodedValue value = response.getResponse().getGetResponse().getResult();
 
       assertTrue(value.getValue().isEmpty());
-    }
   }
 
   @Test
   public void testRoundTripNonEmptyGetRequest() throws IOException {
-    try (Cache cache = createCacheOnPort(40404);
-        NewClientProtocolTestClient client = new NewClientProtocolTestClient("localhost", 40404)) {
-      final String testRegion = "testRegion";
-      final String testKey = "testKey";
-      final String testValue = "testValue";
-      Region<Object, Object> region = cache.createRegionFactory().create("testRegion");
-
-
       ClientProtocol.Message putMessage =
-          MessageUtils.makePutMessageFor(testRegion, testKey, testValue);
-      ClientProtocol.Message putResponse = client.blockingSendMessage(putMessage);
-      client.printResponse(putResponse);
+          MessageUtils.INSTANCE.makePutMessageFor(testRegion, testKey, testValue);
+      ClientProtocol.Message putResponse = testClient.blockingSendMessage(putMessage);
+      testClient.printResponse(putResponse);
 
-      ClientProtocol.Message getMessage = MessageUtils.makeGetMessageFor(testRegion, testKey);
-      ClientProtocol.Message getResponse = client.blockingSendMessage(getMessage);
+      ClientProtocol.Message getMessage = MessageUtils.INSTANCE
+          .makeGetMessageFor(testRegion, testKey);
+      ClientProtocol.Message getResponse = testClient.blockingSendMessage(getMessage);
 
       assertEquals(RESPONSE, getResponse.getMessageTypeCase());
       assertEquals(GETRESPONSE, getResponse.getResponse().getResponseAPICase());
-      BasicTypes.Value value = getResponse.getResponse().getGetResponse().getResult();
+      BasicTypes.EncodedValue value = getResponse.getResponse().getGetResponse().getResult();
 
       assertEquals(value.getValue().toStringUtf8(), testValue);
     }
-  }
 
-  @Test
-  public void startCache() throws IOException {
-    try (Cache cache = createCacheOnPort(40404)) {
-      while (true) {
-        try {
-          Thread.sleep(100000);
-        } catch (InterruptedException e) {
-          e.printStackTrace();
-        }
-      }
+    @Test
+    public void objectSerializationIntegrationTest() {
+      Object[] inputs = new Object[]{
+        "Foobar", 1000L, 22, (short) 231, (byte) -107, new byte[]{1,2,3,54,99}
+      };
     }
-  }
 
   private Cache createCacheOnPort(int port) throws IOException {
     Properties props = new Properties();

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
index 05d2216..3c8eac0 100644
--- a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
+++ b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
@@ -16,21 +16,20 @@
 package org.apache.geode.protocol.client;
 
 
-import com.google.protobuf.InvalidProtocolBufferException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.Region;
 import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.serialization.Deserializer;
-import org.apache.geode.serialization.SerializationType;
 import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.Mockito;
 
-import static org.apache.geode.protocol.client.MessageUtils.makePutMessage;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -39,12 +38,19 @@ import java.io.OutputStream;
 
 @Category(UnitTest.class)
 public class ProtobufSerializationDeserializationTest {
-  @Test
-  public void protobufSerializationSmokeTest() throws InvalidProtocolBufferException {
-    ClientProtocol.Message message = makePutMessage();
-    byte[] bytes = message.toByteArray();
-    ClientProtocol.Message message1 = ClientProtocol.Message.parseFrom(bytes);
-    assertEquals(message, message1);
+
+  private Cache mockCache;
+  private Region mockRegion;
+  private final String testRegion = "testRegion";
+  private final String testKey = "testKey";
+  private final String testValue = "testValue";
+
+  @Before
+  public void start() {
+    mockCache = Mockito.mock(Cache.class);
+    mockRegion = Mockito.mock(Region.class);
+    when(mockCache.getRegion(testRegion)).thenReturn(mockRegion);
+
   }
 
   /**
@@ -53,40 +59,27 @@ public class ProtobufSerializationDeserializationTest {
    */
   @Test
   public void testNewClientProtocolPutsOnPutMessage() throws IOException {
-    final String testRegion = "testRegion";
-    final String testKey = "testKey";
-    final String testValue = "testValue";
-    ClientProtocol.Message message = MessageUtils.makePutMessageFor(testRegion, testKey, testValue);
-
-    Deserializer deserializer = SerializationType.BYTE_BLOB.deserializer;
-    Cache mockCache = Mockito.mock(Cache.class);
-    Region mockRegion = Mockito.mock(Region.class);
-    when(mockCache.getRegion("testRegion")).thenReturn(mockRegion);
+    ClientProtocol.Message message = MessageUtils.INSTANCE
+        .makePutMessageFor(testRegion, testKey, testValue);
+
     OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
 
     ProtobufProtocolMessageHandler newClientProtocol = new ProtobufProtocolMessageHandler();
-    newClientProtocol.receiveMessage(MessageUtils.loadMessageIntoInputStream(message),
-        mockOutputStream, deserializer, SerializationType.STRING.serializer, mockCache);
+    newClientProtocol.receiveMessage(MessageUtils.INSTANCE.loadMessageIntoInputStream(message),
+        mockOutputStream, mockCache);
 
     verify(mockRegion).put(testKey.getBytes(), testValue.getBytes());
   }
 
   @Test
   public void testServerRespondsToPutMessage() throws IOException {
-    final String testRegion = "testRegion";
-    final String testKey = "testKey";
-    final String testValue = "testValue";
-    ClientProtocol.Message message = MessageUtils.makePutMessageFor(testRegion, testKey, testValue);
-
-    Deserializer deserializer = SerializationType.BYTE_BLOB.deserializer;
-    Cache mockCache = Mockito.mock(Cache.class);
-    Region mockRegion = Mockito.mock(Region.class);
-    when(mockCache.getRegion("testRegion")).thenReturn(mockRegion);
     ByteArrayOutputStream outputStream = new ByteArrayOutputStream(128);
+    ClientProtocol.Message message = MessageUtils.INSTANCE
+        .makePutMessageFor(testRegion, testKey, testValue);
 
     ProtobufProtocolMessageHandler newClientProtocol = new ProtobufProtocolMessageHandler();
-    newClientProtocol.receiveMessage(MessageUtils.loadMessageIntoInputStream(message), outputStream,
-        deserializer, SerializationType.STRING.serializer, mockCache);
+    newClientProtocol.receiveMessage(MessageUtils.INSTANCE.loadMessageIntoInputStream(message), outputStream,
+        mockCache);
 
     ClientProtocol.Message responseMessage = ClientProtocol.Message
         .parseDelimitedFrom(new ByteArrayInputStream(outputStream.toByteArray()));

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
index 3e37c4a..ca5abb2 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolMessageHandler.java
@@ -24,6 +24,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 public interface ClientProtocolMessageHandler {
-  void receiveMessage(InputStream inputStream, OutputStream outputStream, Deserializer deserializer,
-      Serializer serializer, Cache cache) throws IOException;
+  void receiveMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
+      throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
index a61c86c..3be1f97 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ServerConnection.java
@@ -956,9 +956,7 @@ public class ServerConnection implements Runnable {
         InputStream inputStream = socket.getInputStream();
         OutputStream outputStream = socket.getOutputStream();
         // TODO serialization types?
-        newClientProtocol.receiveMessage(inputStream, outputStream,
-            SerializationType.STRING.deserializer, SerializationType.STRING.serializer,
-            this.getCache());
+        newClientProtocol.receiveMessage(inputStream, outputStream, this.getCache());
       } catch (IOException e) {
         // TODO?
       }

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-core/src/main/java/org/apache/geode/serialization/Deserializer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/serialization/Deserializer.java b/geode-core/src/main/java/org/apache/geode/serialization/Deserializer.java
index e4cd20c..7cf3bb7 100644
--- a/geode-core/src/main/java/org/apache/geode/serialization/Deserializer.java
+++ b/geode-core/src/main/java/org/apache/geode/serialization/Deserializer.java
@@ -16,5 +16,5 @@
 package org.apache.geode.serialization;
 
 public interface Deserializer<T> {
-  public abstract T deserialize(byte[] bytes);
+  T deserialize(byte[] bytes);
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-core/src/main/java/org/apache/geode/serialization/SerializationType.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/serialization/SerializationType.java b/geode-core/src/main/java/org/apache/geode/serialization/SerializationType.java
index 2ea4066..2bb622f 100644
--- a/geode-core/src/main/java/org/apache/geode/serialization/SerializationType.java
+++ b/geode-core/src/main/java/org/apache/geode/serialization/SerializationType.java
@@ -18,11 +18,19 @@ package org.apache.geode.serialization;
 import org.apache.geode.pdx.JSONFormatter;
 import org.apache.geode.pdx.PdxInstance;
 
-public enum SerializationType {
-  STRING(String.class, String::getBytes, String::new),
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+public enum SerializationType implements Serializer, Deserializer {
+  STRING(String.class, SerializationType::serializeString, SerializationType::deserializeString),
   BYTE_BLOB(byte[].class, (x) -> x, (x) -> x),
+  INT(int.class, SerializationType::serializeInt, SerializationType::deserializeInt),
+  BYTE(byte.class, SerializationType::serializeByte, SerializationType::deserializeByte),
+  SHORT(short.class, SerializationType::serializeShort, SerializationType::deserializeShort),
+  LONG(long.class, SerializationType::serializeLong, SerializationType::deserializeLong),
   JSON(PdxInstance.class, JSONFormatter::toJSONByteArray, JSONFormatter::fromJSON);
 
+  private static final Charset UTF8 = Charset.forName("UTF-8");
   public final Class klass;
   public final Serializer serializer;
   public final Deserializer deserializer;
@@ -32,5 +40,55 @@ public enum SerializationType {
     this.serializer = serializer;
     this.deserializer = deserializer;
   }
+
+  @Override
+  public byte[] serialize(Object item) {
+    return this.serializer.serialize(item);
+  }
+
+  @Override
+  public Object deserialize(byte[] bytes) {
+    return this.deserializer.deserialize(bytes);
+  }
+
+  private static byte[] serializeString(String value) {
+    return value.getBytes(UTF8);
+  }
+
+  private static String deserializeString(byte[] array) {
+    return new String(array, UTF8);
+  }
+
+  private static byte[] serializeInt(int i) {
+    return ByteBuffer.allocate(Integer.BYTES).putInt(i).array();
+  }
+
+  private static int deserializeInt(byte[] bytes) {
+    return ByteBuffer.wrap(bytes).getInt();
+  }
+
+  private static byte[] serializeShort(short i) {
+    return ByteBuffer.allocate(Short.BYTES).putShort(i).array();
+  }
+
+  private static short deserializeShort(byte[] bytes) {
+    return ByteBuffer.wrap(bytes).getShort();
+  }
+
+  private static byte[] serializeLong(long i) {
+    return ByteBuffer.allocate(Long.BYTES).putLong(i).array();
+  }
+
+  private static long deserializeLong(byte[] bytes) {
+    return ByteBuffer.wrap(bytes).getLong();
+  }
+
+  private static byte[] serializeByte(byte i) {
+    return ByteBuffer.allocate(Byte.BYTES).put(i).array();
+  }
+
+  private static byte deserializeByte(byte[] bytes) {
+    return ByteBuffer.wrap(bytes).get();
+  }
 }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-core/src/main/java/org/apache/geode/serialization/Serializer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/serialization/Serializer.java b/geode-core/src/main/java/org/apache/geode/serialization/Serializer.java
index 6be877f..0cb8d3d 100644
--- a/geode-core/src/main/java/org/apache/geode/serialization/Serializer.java
+++ b/geode-core/src/main/java/org/apache/geode/serialization/Serializer.java
@@ -16,5 +16,5 @@
 package org.apache.geode.serialization;
 
 public interface Serializer<T> {
-  public abstract byte[] serialize(T item);
+  byte[] serialize(T item);
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c1e22f37/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java b/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
new file mode 100644
index 0000000..79b0651
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
@@ -0,0 +1,113 @@
+package org.apache.geode.serialization;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import com.pholser.junit.quickcheck.Property;
+import com.pholser.junit.quickcheck.runner.JUnitQuickcheck;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.nio.charset.Charset;
+
+@RunWith(JUnitQuickcheck.class)
+public class SerializationTypeTest {
+  @Property
+  public void testStringSerialization(String testString) throws Exception {
+    byte[] expectedBytes = testString.getBytes(Charset.forName("UTF-8"));
+    byte[] serializedBytes = SerializationType.STRING.serialize(testString);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testString, SerializationType.STRING.deserialize(expectedBytes));
+  }
+
+
+  @Test
+  public void testLongSerialization() throws Exception {
+    long testValue = 1311768465047740160L; // otherwise known as 0x123456780abadf00 bytes;
+    byte[] expectedBytes =
+        new byte[]{0x12, 0x34, 0x56, 0x78, 0x0a, (byte) 0xba, (byte) 0xdf, 0x00};
+    byte[] serializedBytes = SerializationType.LONG.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.LONG.deserialize(expectedBytes));
+
+    testValue = -1311234265047740160L; // otherwise known as 0xedcd8f6216825100 bytes;
+    expectedBytes = new byte[]{(byte) 0xed, (byte) 0xcd, (byte) 0x8f, 0x62, 0x16, (byte) 0x82,
+        (byte) 0x51, 0x00};
+    serializedBytes = SerializationType.LONG.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.LONG.deserialize(expectedBytes));
+  }
+
+  @Test
+  public void testIntSerialization() throws Exception {
+    int testValue = 313216366; // otherwise known as 0x12ab4d6e bytes;
+    byte[] expectedBytes = new byte[]{0x12, (byte) 0xab, 0x4d, 0x6e};
+    byte[] serializedBytes = SerializationType.INT.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.INT.deserialize(expectedBytes));
+
+    testValue = -313216366; // otherwise known as 0xed54b292 bytes;
+    expectedBytes = new byte[]{(byte) 0xed, 0x54, (byte) 0xb2, (byte) 0x92};
+    serializedBytes = SerializationType.INT.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.INT.deserialize(expectedBytes));
+  }
+
+  @Test
+  public void testShortSerialization() throws Exception {
+    short testValue = 31321; // otherwise known as 0x7a59 bytes;
+    byte[] expectedBytes = new byte[]{0x7a, 0x59};
+    byte[] serializedBytes = SerializationType.SHORT.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.SHORT.deserialize(expectedBytes));
+
+    testValue = -22357; // otherwise known as 0xa8ab bytes;
+    expectedBytes = new byte[]{(byte) 0xa8, (byte) 0xab};
+    serializedBytes = SerializationType.SHORT.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.SHORT.deserialize(expectedBytes));
+  }
+
+  @Test
+  public void testByteSerialization() throws Exception {
+    byte testValue = 116;
+    byte[] expectedBytes = new byte[]{116};
+    byte[] serializedBytes = SerializationType.BYTE.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.BYTE.deserialize(expectedBytes));
+
+    testValue = -87;
+    expectedBytes = new byte[]{-87};
+    serializedBytes = SerializationType.BYTE.serialize(testValue);
+    assertArrayEquals(expectedBytes, serializedBytes);
+    assertEquals(testValue, SerializationType.BYTE.deserialize(expectedBytes));
+
+  }
+
+  @Property
+  public void testBinarySerialization(byte[] bytes) throws Exception {
+    assertArrayEquals(bytes, SerializationType.BYTE_BLOB.serialize(bytes));
+    assertArrayEquals(bytes, (byte[]) SerializationType.BYTE_BLOB.deserialize(bytes));
+  }
+
+  @Ignore("Not currently testable without a Cache, because JSON gets serialized to a PDXInstance, "
+      + "which requires a Cache.")
+  @Test
+  public void testJSONSerialization() {
+    String[] testStrings = {
+        "\"testString\"",
+        "{}",
+        "{\"foo\":\"bar\",\"list :\":[1,2,\"boo\"],hash:{1:2,3:4}}"
+    };
+
+    for (String string : testStrings) {
+      byte[] serialized = SerializationType.JSON.serialize(string);
+      String deserialized =
+          (String) SerializationType.JSON.deserializer.deserialize(serialized);
+      assertEquals(string, deserialized);
+      fail("This test is not yet complete");
+    }
+  }
+}


[2/2] geode git commit: GEODE-2580 : Post Kotlin changes

Posted by ud...@apache.org.
GEODE-2580 : Post Kotlin changes


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

Branch: refs/heads/feature/GEODE-2580
Commit: 6a5e4be30b79c805101017c627719e6949c2dfb7
Parents: c1e22f3
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Tue May 23 16:41:19 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Tue May 23 16:41:19 2017 -0700

----------------------------------------------------------------------
 .../geode/protocol/client/EncodingTypeThingy.kt |  51 +++---
 .../client/ProtobufProtocolMessageHandler.java  | 147 -----------------
 .../client/ProtobufProtocolMessageHandler.kt    | 128 +++++++++++++++
 .../geode/protocol/client/MessageUtils.java     |  83 ----------
 .../geode/protocol/client/MessageUtils.kt       |  69 ++++++++
 .../client/ProtobufProtocolIntegrationTest.java | 134 ----------------
 .../client/ProtobufProtocolIntegrationTest.kt   | 159 +++++++++++++++++++
 ...rotobufSerializationDeserializationTest.java |  94 -----------
 .../ProtobufSerializationDeserializationTest.kt |  94 +++++++++++
 .../serialization/SerializationTypeTest.java    |  26 ++-
 10 files changed, 492 insertions(+), 493 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
index 8d65827..cfb1332 100644
--- a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
+++ b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/EncodingTypeThingy.kt
@@ -5,29 +5,40 @@ import org.apache.geode.pdx.PdxInstance
 import org.apache.geode.protocol.protobuf.BasicTypes
 import org.apache.geode.serialization.SerializationType
 
-fun getEncodingTypeForObjectKT(o: Any?): BasicTypes.EncodingType {
-    return when (o) {
-        is String -> BasicTypes.EncodingType.STRING
-        is Int -> BasicTypes.EncodingType.INT
-        is PdxInstance -> {
-            if (o.className == JSONFormatter.JSON_CLASSNAME) BasicTypes.EncodingType.JSON else BasicTypes.EncodingType.UNRECOGNIZED
+object EncodingTypeThingy {
+    @JvmStatic
+    fun getEncodingTypeForObjectKT(obj: Any?): BasicTypes.EncodingType {
+        return when (obj) {
+            is Byte -> BasicTypes.EncodingType.BYTE
+            is Short -> BasicTypes.EncodingType.SHORT
+            is Long -> BasicTypes.EncodingType.LONG
+            is String -> BasicTypes.EncodingType.STRING
+            is Int -> BasicTypes.EncodingType.INT
+            is PdxInstance -> {
+                if (obj.className == JSONFormatter.JSON_CLASSNAME) {
+                    BasicTypes.EncodingType.JSON
+                } else {
+                    BasicTypes.EncodingType.UNRECOGNIZED
+                }
+            }
+            is ByteArray -> BasicTypes.EncodingType.BINARY
+            else -> BasicTypes.EncodingType.UNRECOGNIZED
         }
-        is ByteArray -> BasicTypes.EncodingType.BINARY
-        else -> BasicTypes.EncodingType.UNRECOGNIZED
     }
-}
 
-fun serializerFromProtoEnum(encodingType: BasicTypes.EncodingType): SerializationType {
-    return when (encodingType) {
-        BasicTypes.EncodingType.INT -> SerializationType.INT
-        BasicTypes.EncodingType.LONG -> SerializationType.LONG
-        BasicTypes.EncodingType.SHORT -> SerializationType.SHORT
-        BasicTypes.EncodingType.BYTE -> SerializationType.BYTE
-        BasicTypes.EncodingType.STRING -> SerializationType.STRING
-        BasicTypes.EncodingType.BINARY -> SerializationType.BYTE_BLOB
-        BasicTypes.EncodingType.JSON -> SerializationType.JSON
-        BasicTypes.EncodingType.FLOAT, BasicTypes.EncodingType.BOOLEAN, BasicTypes.EncodingType.DOUBLE -> TODO()
-        else -> TODO()
+    @JvmStatic
+    fun serializerFromProtoEnum(encodingType: BasicTypes.EncodingType): SerializationType {
+        return when (encodingType) {
+            BasicTypes.EncodingType.INT -> SerializationType.INT
+            BasicTypes.EncodingType.LONG -> SerializationType.LONG
+            BasicTypes.EncodingType.SHORT -> SerializationType.SHORT
+            BasicTypes.EncodingType.BYTE -> SerializationType.BYTE
+            BasicTypes.EncodingType.STRING -> SerializationType.STRING
+            BasicTypes.EncodingType.BINARY -> SerializationType.BYTE_BLOB
+            BasicTypes.EncodingType.JSON -> SerializationType.JSON
+            BasicTypes.EncodingType.FLOAT, BasicTypes.EncodingType.BOOLEAN, BasicTypes.EncodingType.DOUBLE -> TODO()
+            else -> TODO("Unknown EncodingType to SerializationType conversion for $encodingType")
+        }
     }
 }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
deleted file mode 100644
index ed9a7e3..0000000
--- a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.java
+++ /dev/null
@@ -1,147 +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.protocol.client;
-
-import static org.apache.geode.protocol.client.EncodingTypeThingyKt.getEncodingTypeForObjectKT;
-import static org.apache.geode.protocol.client.EncodingTypeThingyKt.serializerFromProtoEnum;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Message;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Request;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Response;
-import static org.apache.geode.protocol.protobuf.RegionAPI.PutRequest;
-
-import com.google.protobuf.ByteString;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheWriterException;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.TimeoutException;
-import org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler;
-import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-import org.apache.geode.protocol.protobuf.RegionAPI.GetRequest;
-import org.apache.geode.protocol.protobuf.RegionAPI.PutResponse;
-import org.apache.geode.serialization.SerializationType;
-import org.apache.logging.log4j.Logger;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class ProtobufProtocolMessageHandler implements ClientProtocolMessageHandler {
-
-  private static final Logger logger = LogService.getLogger();
-
-  private String ErrorMessageFromMessage(Message message) {
-    return "Error parsing message, message string: " + message.toString();
-  }
-
-  @Override
-  public void receiveMessage(InputStream inputStream, OutputStream outputStream, Cache cache)
-      throws IOException {
-    final Message message = Message.parseDelimitedFrom(inputStream);
-    // can be null at EOF, see Parser.parseDelimitedFrom(java.io.InputStream)
-    if (message == null) {
-      return;
-    }
-
-    if (message.getMessageTypeCase() != Message.MessageTypeCase.REQUEST) {
-      // TODO
-      logger.error(() -> "Got message of type response: " + ErrorMessageFromMessage(message));
-    }
-
-    Message responseMessage = null;
-
-    Request request = message.getRequest();
-    Request.RequestAPICase requestAPICase = request.getRequestAPICase();
-    if (requestAPICase == Request.RequestAPICase.GETREQUEST) {
-      responseMessage = doGetRequest(request.getGetRequest(), cache);
-    } else if (requestAPICase == Request.RequestAPICase.PUTREQUEST) {
-      responseMessage = doPutRequest(request.getPutRequest(), cache);
-    } else {
-      // TODO
-    }
-    if (responseMessage != null) {
-      responseMessage.writeDelimitedTo(outputStream);
-    }
-  }
-
-  private Message doPutRequest(PutRequest request, Cache cache) {
-    final String regionName = request.getRegionName();
-    final BasicTypes.Entry entry = request.getEntry();
-    assert (entry != null);
-
-    final Region<Object, Object> region = cache.getRegion(regionName);
-    try {
-      region.put(deserializeEncodedValue(entry.getKey()),
-          deserializeEncodedValue(entry.getValue()));
-      return putResponseWithStatus(true);
-    } catch (TimeoutException | CacheWriterException ex) {
-      logger.warn("Caught normal-ish exception doing region put", ex);
-      return putResponseWithStatus(false);
-    }
-  }
-
-  private Object deserializeEncodedValue(BasicTypes.EncodedValue encodedValue) {
-    assert (encodedValue != null);
-    SerializationType serializer = serializerFromProtoEnum(encodedValue.getEncodingType());
-    return serializer.deserialize(encodedValue.getValue().toByteArray());
-  }
-
-  private byte[] serializeEncodedValue(BasicTypes.EncodingType encodingType,
-      Object objectToSerialize) {
-    if (objectToSerialize == null) {
-      return null; // BLECH!!! :(
-    }
-    SerializationType serializer = serializerFromProtoEnum(encodingType);
-    return serializer.serialize(objectToSerialize);
-  }
-
-  private Message putResponseWithStatus(boolean ok) {
-    return Message.newBuilder()
-        .setResponse(Response.newBuilder().setPutResponse(PutResponse.newBuilder().setSuccess(ok)))
-        .build();
-  }
-
-  private Message doGetRequest(GetRequest request, Cache cache) {
-    Region<Object, Object> region = cache.getRegion(request.getRegionName());
-    Object returnValue = region.get(deserializeEncodedValue(request.getKey()));
-
-    if (returnValue == null) {
-
-      return makeGetResponseMessageWithValue(new byte[0]);
-    } else {
-      // TODO types in the region?
-      return makeGetResponseMessageWithValue(returnValue);
-    }
-  }
-
-  private BasicTypes.EncodingType getEncodingTypeForObject(Object object) {
-    return getEncodingTypeForObjectKT(object);
-  }
-
-  private Message makeGetResponseMessageWithValue(Object objectToReturn) {
-    BasicTypes.EncodingType encodingType = getEncodingTypeForObject(objectToReturn);
-    byte[] serializedObject = serializeEncodedValue(encodingType, objectToReturn);
-    return Message.newBuilder()
-        .setResponse(Response.newBuilder()
-            .setGetResponse(RegionAPI.GetResponse.newBuilder()
-                .setResult(BasicTypes.EncodedValue.newBuilder()
-                    .setEncodingType(BasicTypes.EncodingType.STRING)
-                    .setValue(ByteString.copyFrom(serializedObject)))))
-        .build();
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.kt
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.kt b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.kt
new file mode 100644
index 0000000..ec66d44
--- /dev/null
+++ b/geode-client-protobuf/src/main/java/org/apache/geode/protocol/client/ProtobufProtocolMessageHandler.kt
@@ -0,0 +1,128 @@
+/*
+ * 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.protocol.client
+
+import com.google.protobuf.ByteString
+import org.apache.geode.cache.Cache
+import org.apache.geode.cache.CacheWriterException
+import org.apache.geode.cache.TimeoutException
+import org.apache.geode.internal.cache.tier.sockets.ClientProtocolMessageHandler
+import org.apache.geode.internal.logging.LogService
+import org.apache.geode.protocol.protobuf.BasicTypes
+import org.apache.geode.protocol.protobuf.ClientProtocol.*
+import org.apache.geode.protocol.protobuf.RegionAPI
+import org.apache.geode.protocol.protobuf.RegionAPI.*
+import java.io.IOException
+import java.io.InputStream
+import java.io.OutputStream
+
+class ProtobufProtocolMessageHandler : ClientProtocolMessageHandler {
+
+    private fun ErrorMessageFromMessage(message: Message): String {
+        return "Error parsing message, message string: " + message.toString()
+    }
+
+    @Throws(IOException::class)
+    override fun receiveMessage(inputStream: InputStream, outputStream: OutputStream, cache: Cache) {
+        val message = Message.parseDelimitedFrom(inputStream) ?: return
+        // can be null at EOF, see Parser.parseDelimitedFrom(java.io.InputStream)
+
+        if (message.messageTypeCase != Message.MessageTypeCase.REQUEST) {
+            TODO("Got message of type response: ${ErrorMessageFromMessage(message)}")
+        }
+
+        val request = message.request
+        val requestAPICase = request.requestAPICase
+        when (requestAPICase) {
+            Request.RequestAPICase.GETREQUEST -> doGetRequest(request.getRequest, cache).writeDelimitedTo(outputStream)
+            Request.RequestAPICase.PUTREQUEST -> doPutRequest(request.putRequest, cache).writeDelimitedTo(outputStream)
+            else -> TODO("The message type: $requestAPICase is not supported")
+
+        }
+    }
+
+    private fun doPutRequest(request: PutRequest, cache: Cache): Message {
+        val regionName = request.regionName
+        val entry = request.entry!!
+
+        val region = cache.getRegion<Any, Any>(regionName)
+        try {
+            region.put(deserializeEncodedValue(entry.key), deserializeEncodedValue(entry.value))
+            return putResponseWithStatus(true)
+        } catch (ex: TimeoutException) {
+            logger.warn("Caught normal-ish exception doing region put", ex)
+            return putResponseWithStatus(false)
+        } catch (ex: CacheWriterException) {
+            logger.warn("Caught normal-ish exception doing region put", ex)
+            return putResponseWithStatus(false)
+        }
+
+    }
+
+    private fun deserializeEncodedValue(encodedValue: BasicTypes.EncodedValue): Any {
+        val serializer = EncodingTypeThingy.serializerFromProtoEnum(encodedValue.encodingType)
+        return serializer.deserialize(encodedValue.value.toByteArray())
+    }
+
+    private fun serializeEncodedValue(encodingType: BasicTypes.EncodingType,
+                                      objectToSerialize: Any?): ByteArray? {
+        if (objectToSerialize == null) {
+            return null // BLECH!!! :(
+        }
+        val serializer = EncodingTypeThingy.serializerFromProtoEnum(encodingType)
+        return serializer.serialize(objectToSerialize)
+    }
+
+    private fun putResponseWithStatus(ok: Boolean): Message {
+        return Message.newBuilder()
+                .setResponse(Response.newBuilder().setPutResponse(PutResponse.newBuilder().setSuccess(ok)))
+                .build()
+    }
+
+    private fun doGetRequest(request: GetRequest, cache: Cache): Message {
+        val region = cache.getRegion<Any, Any>(request.regionName)
+        val returnValue = region[deserializeEncodedValue(request.key)]
+
+        if (returnValue == null) {
+
+            return makeGetResponseMessageWithValue(ByteArray(0))
+        } else {
+            // TODO types in the region?
+            return makeGetResponseMessageWithValue(returnValue)
+        }
+    }
+
+    private fun getEncodingTypeForObject(`object`: Any): BasicTypes.EncodingType {
+        return EncodingTypeThingy.getEncodingTypeForObjectKT(`object`)
+    }
+
+    private fun makeGetResponseMessageWithValue(objectToReturn: Any): Message {
+        val encodingType = getEncodingTypeForObject(objectToReturn)
+        val serializedObject = serializeEncodedValue(encodingType, objectToReturn)
+
+        val encodedValueBuilder = BasicTypes.EncodedValue.newBuilder()
+                .setEncodingType(encodingType)
+                .setValue(ByteString.copyFrom(serializedObject))
+        val getResponseBuilder = RegionAPI.GetResponse.newBuilder().setResult(encodedValueBuilder)
+        val responseBuilder = Response.newBuilder().setGetResponse(getResponseBuilder)
+        return Message.newBuilder().setResponse(responseBuilder).build()
+    }
+
+    companion object {
+
+        private val logger = LogService.getLogger()
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
deleted file mode 100644
index 250c2f8..0000000
--- a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.java
+++ /dev/null
@@ -1,83 +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.protocol.client;
-
-import static org.apache.geode.protocol.client.EncodingTypeThingyKt.serializerFromProtoEnum;
-
-import com.google.protobuf.ByteString;
-
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.protocol.protobuf.RegionAPI;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Random;
-
-public class MessageUtils {
-  public static ByteArrayInputStream loadMessageIntoInputStream(ClientProtocol.Message message)
-      throws IOException {
-    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-    message.writeDelimitedTo(byteArrayOutputStream);
-    byte[] messageByteArray = byteArrayOutputStream.toByteArray();
-    return new ByteArrayInputStream(messageByteArray);
-  }
-
-  public static ClientProtocol.Message makeGetMessageFor(String region, String key) {
-    Random random = new Random();
-    ClientProtocol.MessageHeader.Builder messageHeader =
-        ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt());
-
-    BasicTypes.EncodedValue.Builder keyBuilder = getEncodedValueBuilder(key);
-
-    RegionAPI.GetRequest.Builder getRequest =
-        RegionAPI.GetRequest.newBuilder().setRegionName(region).setKey(keyBuilder);
-    ClientProtocol.Request.Builder request =
-        ClientProtocol.Request.newBuilder().setGetRequest(getRequest);
-
-    return ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request)
-        .build();
-  }
-
-  public static ClientProtocol.Message makePutMessageFor(String region, Object key, Object value) {
-    Random random = new Random();
-    ClientProtocol.MessageHeader.Builder messageHeader =
-        ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt());
-
-    BasicTypes.EncodedValue.Builder keyBuilder = getEncodedValueBuilder(key);
-    BasicTypes.EncodedValue.Builder valueBuilder = getEncodedValueBuilder(value);
-
-    RegionAPI.PutRequest.Builder putRequestBuilder =
-        RegionAPI.PutRequest.newBuilder().setRegionName(region)
-            .setEntry(BasicTypes.Entry.newBuilder().setKey(keyBuilder).setValue(valueBuilder));
-
-    ClientProtocol.Request.Builder request =
-        ClientProtocol.Request.newBuilder().setPutRequest(putRequestBuilder);
-    ClientProtocol.Message.Builder message =
-        ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request);
-
-    return message.build();
-  }
-
-  private static BasicTypes.EncodedValue.Builder getEncodedValueBuilder(Object value) {
-    BasicTypes.EncodingType encodingType = EncodingTypeThingyKt.getEncodingTypeForObjectKT(value);
-
-    return BasicTypes.EncodedValue.newBuilder().setEncodingType(encodingType)
-        .setValue(ByteString.copyFrom(serializerFromProtoEnum(encodingType).serialize(value)));
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.kt
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.kt b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.kt
new file mode 100644
index 0000000..285c9b4
--- /dev/null
+++ b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/MessageUtils.kt
@@ -0,0 +1,69 @@
+/*
+ * 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.protocol.client
+
+import com.google.protobuf.ByteString
+import org.apache.geode.protocol.protobuf.BasicTypes
+import org.apache.geode.protocol.protobuf.ClientProtocol
+import org.apache.geode.protocol.protobuf.RegionAPI
+import java.io.ByteArrayInputStream
+import java.io.ByteArrayOutputStream
+import java.io.IOException
+import java.util.*
+
+object MessageUtils {
+    @Throws(IOException::class)
+    fun loadMessageIntoInputStream(message: ClientProtocol.Message): ByteArrayInputStream {
+        val byteArrayOutputStream = ByteArrayOutputStream()
+        message.writeDelimitedTo(byteArrayOutputStream)
+        val messageByteArray = byteArrayOutputStream.toByteArray()
+        return ByteArrayInputStream(messageByteArray)
+    }
+
+    fun makeGetMessageFor(region: String, key: Any, keyEncoding: BasicTypes.EncodingType = EncodingTypeThingy.getEncodingTypeForObjectKT(key)): ClientProtocol.Message {
+        val random = Random()
+        val messageHeader = ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt())
+
+        val keyBuilder = getEncodedValueBuilder(key, keyEncoding)
+
+        val getRequest = RegionAPI.GetRequest.newBuilder().setRegionName(region).setKey(keyBuilder)
+        val request = ClientProtocol.Request.newBuilder().setGetRequest(getRequest)
+
+        return ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request)
+                .build()
+    }
+
+    fun makePutMessageFor(region: String, key: Any, value: Any, keyEncoding: BasicTypes.EncodingType = EncodingTypeThingy.getEncodingTypeForObjectKT(key), valueEncoding: BasicTypes.EncodingType = EncodingTypeThingy.getEncodingTypeForObjectKT(value)): ClientProtocol.Message {
+        val random = Random()
+        val messageHeader = ClientProtocol.MessageHeader.newBuilder().setCorrelationId(random.nextInt())
+
+        val keyBuilder = getEncodedValueBuilder(key, keyEncoding)
+        val valueBuilder = getEncodedValueBuilder(value, valueEncoding)
+
+        val putRequestBuilder = RegionAPI.PutRequest.newBuilder().setRegionName(region)
+                .setEntry(BasicTypes.Entry.newBuilder().setKey(keyBuilder).setValue(valueBuilder))
+
+        val request = ClientProtocol.Request.newBuilder().setPutRequest(putRequestBuilder)
+        val message = ClientProtocol.Message.newBuilder().setMessageHeader(messageHeader).setRequest(request)
+
+        return message.build()
+    }
+
+    private fun getEncodedValueBuilder(value: Any, encodingType: BasicTypes.EncodingType): BasicTypes.EncodedValue.Builder {
+        return BasicTypes.EncodedValue.newBuilder().setEncodingType(encodingType)
+                .setValue(ByteString.copyFrom(EncodingTypeThingy.serializerFromProtoEnum(encodingType).serialize(value)))
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
deleted file mode 100644
index a9a7407..0000000
--- a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.java
+++ /dev/null
@@ -1,134 +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.protocol.client;
-
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Message.MessageTypeCase.RESPONSE;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.GETRESPONSE;
-import static org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.PUTRESPONSE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import com.pholser.junit.quickcheck.runner.JUnitQuickcheck;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.protocol.protobuf.BasicTypes;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import java.io.IOException;
-import java.util.Properties;
-
-@Category(IntegrationTest.class)
-@RunWith(JUnitQuickcheck.class)
-public class ProtobufProtocolIntegrationTest {
-  private final static String testRegion = "testRegion";
-  private final static String testKey = "testKey";
-  private final static String testValue = "testValue";
-  private Cache cache;
-  private NewClientProtocolTestClient testClient;
-  private Region<Object, Object> regionUnderTest;
-
-  @Before
-  public void setup() throws IOException {
-    cache = createCacheOnPort(40404);
-    testClient = new NewClientProtocolTestClient("localhost", 40404);
-    regionUnderTest = cache.createRegionFactory().create(testRegion);
-  }
-
-  @After
-  public void shutdown() throws IOException {
-    if (testClient != null) {
-      testClient.close();
-    }
-    if (cache != null) {
-      cache.close();
-    }
-  }
-
-  @Test
-  public void testRoundTripPutRequest() throws IOException {
-      ClientProtocol.Message message =
-          MessageUtils.INSTANCE.makePutMessageFor(testRegion, testKey, testValue);
-      ClientProtocol.Message response = testClient.blockingSendMessage(message);
-      testClient.printResponse(response);
-
-      assertEquals(RESPONSE, response.getMessageTypeCase());
-      assertEquals(PUTRESPONSE, response.getResponse().getResponseAPICase());
-      assertTrue(response.getResponse().getPutResponse().getSuccess());
-
-      assertEquals(1, regionUnderTest.size());
-      assertTrue(regionUnderTest.containsKey(testKey));
-      assertEquals(testValue, regionUnderTest.get(testKey));
-  }
-
-  @Test
-  public void testRoundTripEmptyGetRequest() throws IOException {
-      ClientProtocol.Message message = MessageUtils.INSTANCE.makeGetMessageFor(testRegion, testKey);
-      ClientProtocol.Message response = testClient.blockingSendMessage(message);
-
-      assertEquals(RESPONSE, response.getMessageTypeCase());
-      assertEquals(GETRESPONSE, response.getResponse().getResponseAPICase());
-      BasicTypes.EncodedValue value = response.getResponse().getGetResponse().getResult();
-
-      assertTrue(value.getValue().isEmpty());
-  }
-
-  @Test
-  public void testRoundTripNonEmptyGetRequest() throws IOException {
-      ClientProtocol.Message putMessage =
-          MessageUtils.INSTANCE.makePutMessageFor(testRegion, testKey, testValue);
-      ClientProtocol.Message putResponse = testClient.blockingSendMessage(putMessage);
-      testClient.printResponse(putResponse);
-
-      ClientProtocol.Message getMessage = MessageUtils.INSTANCE
-          .makeGetMessageFor(testRegion, testKey);
-      ClientProtocol.Message getResponse = testClient.blockingSendMessage(getMessage);
-
-      assertEquals(RESPONSE, getResponse.getMessageTypeCase());
-      assertEquals(GETRESPONSE, getResponse.getResponse().getResponseAPICase());
-      BasicTypes.EncodedValue value = getResponse.getResponse().getGetResponse().getResult();
-
-      assertEquals(value.getValue().toStringUtf8(), testValue);
-    }
-
-    @Test
-    public void objectSerializationIntegrationTest() {
-      Object[] inputs = new Object[]{
-        "Foobar", 1000L, 22, (short) 231, (byte) -107, new byte[]{1,2,3,54,99}
-      };
-    }
-
-  private Cache createCacheOnPort(int port) throws IOException {
-    Properties props = new Properties();
-    props.setProperty(ConfigurationProperties.TCP_PORT, Integer.toString(port));
-    props.setProperty(ConfigurationProperties.BIND_ADDRESS, "localhost");
-    CacheFactory cf = new CacheFactory(props);
-    Cache cache = cf.create();
-    CacheServer cacheServer = cache.addCacheServer();
-    cacheServer.setBindAddress("localhost");
-    cacheServer.start();
-    return cache;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.kt
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.kt b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.kt
new file mode 100644
index 0000000..2130c88
--- /dev/null
+++ b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufProtocolIntegrationTest.kt
@@ -0,0 +1,159 @@
+/*
+ * 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.protocol.client
+
+import com.pholser.junit.quickcheck.runner.JUnitQuickcheck
+import org.apache.geode.cache.Cache
+import org.apache.geode.cache.CacheFactory
+import org.apache.geode.cache.Region
+import org.apache.geode.distributed.ConfigurationProperties
+import org.apache.geode.protocol.protobuf.BasicTypes
+import org.apache.geode.protocol.protobuf.ClientProtocol.Message.MessageTypeCase.RESPONSE
+import org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.GETRESPONSE
+import org.apache.geode.protocol.protobuf.ClientProtocol.Response.ResponseAPICase.PUTRESPONSE
+import org.apache.geode.test.junit.categories.IntegrationTest
+import org.junit.After
+import org.junit.Assert.*
+import org.junit.Before
+import org.junit.Test
+import org.junit.experimental.categories.Category
+import org.junit.runner.RunWith
+import java.io.IOException
+import java.io.Serializable
+import java.util.*
+
+@Category(IntegrationTest::class)
+@RunWith(JUnitQuickcheck::class)
+class ProtobufProtocolIntegrationTest {
+    private lateinit var cache: Cache
+    private lateinit var testClient: NewClientProtocolTestClient
+    private lateinit var regionUnderTest: Region<Any, Any>
+    private val testRegion = "testRegion"
+    private val testKey = "testKey"
+    private val testValue = "testValue"
+
+    @Before
+    @Throws(IOException::class)
+    fun setup() {
+        cache = createCacheOnPort(40404)
+        testClient = NewClientProtocolTestClient("localhost", 40404)
+        regionUnderTest = cache.createRegionFactory<Any, Any>().create(testRegion)
+    }
+
+    @After
+    @Throws(IOException::class)
+    fun shutdown() {
+        testClient.close()
+        cache.close()
+    }
+
+    @Test
+    @Throws(IOException::class)
+    fun testRoundTripPutRequest() {
+        val message = MessageUtils.makePutMessageFor(region = testRegion, key = testKey, value = testValue)
+        val response = testClient.blockingSendMessage(message)
+        testClient.printResponse(response)
+
+        assertEquals(RESPONSE, response.messageTypeCase)
+        assertEquals(PUTRESPONSE, response.response.responseAPICase)
+        assertTrue(response.response.putResponse.success)
+
+        assertEquals(1, regionUnderTest.size.toLong())
+        assertTrue(regionUnderTest.containsKey(testKey))
+        assertEquals(testValue, regionUnderTest[testKey])
+    }
+
+    @Test
+    @Throws(IOException::class)
+    fun testRoundTripEmptyGetRequest() {
+        val message = MessageUtils.makeGetMessageFor(region = testRegion, key = testKey)
+        val response = testClient.blockingSendMessage(message)
+
+        assertEquals(RESPONSE, response.messageTypeCase)
+        assertEquals(GETRESPONSE, response.response.responseAPICase)
+        val value = response.response.getResponse.result
+
+        assertTrue(value.value.isEmpty)
+    }
+
+    @Test
+    @Throws(IOException::class)
+    fun testRoundTripNonEmptyGetRequest() {
+        val putMessage = MessageUtils.makePutMessageFor(testRegion, testKey, testValue)
+        val putResponse = testClient.blockingSendMessage(putMessage)
+        testClient.printResponse(putResponse)
+
+        val getMessage = MessageUtils
+                .makeGetMessageFor(testRegion, testKey)
+        val getResponse = testClient.blockingSendMessage(getMessage)
+
+        assertEquals(RESPONSE, getResponse.messageTypeCase)
+        assertEquals(GETRESPONSE, getResponse.response.responseAPICase)
+        val value = getResponse.response.getResponse.result
+
+        assertEquals(value.value.toStringUtf8(), testValue)
+    }
+
+    @Test
+    fun objectSerializationIntegrationTest() {
+        val inputs = listOf("Foobar", 1000.toLong(), 22, 231.toShort(), (-107).toByte(), byteArrayOf(1, 2, 3, 54, 99))
+        for (key in inputs) {
+            for (value in inputs) {
+                if (key !is ByteArray) {
+                    testMessagePutAndGet(key, value, EncodingTypeThingy.getEncodingTypeForObjectKT(value))
+                }
+            }
+        }
+//        val jsonString = "{ \"_id\": \"5924ba3f3918de8404fc1321\", \"index\": 0, \"guid\": \"bd27d3fa-8870-4f0d-ab4d-73adf7cbe58b\", \"isActive\": false, \"balance\": \"$1,934.31\", \"picture\": \"http://placehold.it/32x32\", \"age\": 39, \"eyeColor\": \"blue\", \"name\": \"Holt Dickson\", \"gender\": \"male\", \"company\": \"INQUALA\", \"email\": \"holtdickson@inquala.com\", \"phone\": \"+1 (886) 450-2949\", \"address\": \"933 Diamond Street, Hinsdale, Palau, 2038\", \"about\": \"Cupidatat excepteur labore cillum ea reprehenderit aliquip magna duis aliquip Lorem labore. Aliquip elit ullamco aliqua fugiat aute id irure enim Lorem eu qui nisi aliquip. Et do sit cupidatat sit ut consectetur ullamco aute do nostrud in. Ea voluptate in reprehenderit sit commodo et aliquip officia id eiusmod. Quis voluptate commodo ad esse do cillum ut occaecat non.\r\n\", \"registered\": \"2017-02-01T12:28:49 +08:00\", \"latitude\": -69.313434, \"longitude\": 134.707471, \"tags\": [ \"officia\", \"qui
 \", \"ullamco\", \"nostrud\", \"ipsum\", \"dolor\", \"officia\" ], \"friends\": [ { \"id\": 0, \"name\": \"Vivian Beach\" }, { \"id\": 1, \"name\": \"Crystal Mills\" }, { \"id\": 2, \"name\": \"Mosley Frank\" } ], \"greeting\": \"Hello, Holt Dickson! You have 2 unread messages.\", \"favoriteFruit\": \"apple\" }"
+//
+//        testMessagePutAndGet(testKey,jsonString,BasicTypes.EncodingType.STRING)
+//        val putMessage = MessageUtils.makePutMessageFor(region = testRegion, key = testKey, value = jsonString, valueEncoding = BasicTypes.EncodingType.STRING)
+    }
+
+    private fun testMessagePutAndGet(key: Serializable, value: Serializable, valueEncoding: BasicTypes.EncodingType) {
+        val putMessage = MessageUtils.makePutMessageFor(region = testRegion, key = key, value = value, valueEncoding = valueEncoding)
+        val responseMessage = testClient.blockingSendMessage(putMessage)
+        assertTrue(responseMessage.response.putResponse.success)
+
+        val getMessage = MessageUtils.makeGetMessageFor(region = testRegion, key = key)
+        val getResponse = testClient.blockingSendMessage(getMessage)
+
+        val messageEncodingType = getResponse.response.getResponse.result.encodingType
+        assertEquals(valueEncoding, messageEncodingType)
+
+        val serializer = EncodingTypeThingy.serializerFromProtoEnum(messageEncodingType)
+        val messageValue = getResponse.response.getResponse.result.value.toByteArray()
+
+        val deserializeValue = serializer.deserializer.deserialize(messageValue)
+        when (messageEncodingType) {
+            BasicTypes.EncodingType.BINARY -> assertArrayEquals(value as ByteArray, deserializeValue as ByteArray)
+            else -> assertEquals(value, serializer.deserializer.deserialize(messageValue))
+        }
+    }
+
+    @Throws(IOException::class)
+    private fun createCacheOnPort(port: Int): Cache {
+        val props = Properties()
+        props.setProperty(ConfigurationProperties.TCP_PORT, Integer.toString(port))
+        props.setProperty(ConfigurationProperties.BIND_ADDRESS, "localhost")
+        val cf = CacheFactory(props)
+        val cache = cf.create()
+        val cacheServer = cache.addCacheServer()
+        cacheServer.bindAddress = "localhost"
+        cacheServer.start()
+        return cache
+    }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
deleted file mode 100644
index 3c8eac0..0000000
--- a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.java
+++ /dev/null
@@ -1,94 +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.protocol.client;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.Region;
-import org.apache.geode.protocol.protobuf.ClientProtocol;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-
-@Category(UnitTest.class)
-public class ProtobufSerializationDeserializationTest {
-
-  private Cache mockCache;
-  private Region mockRegion;
-  private final String testRegion = "testRegion";
-  private final String testKey = "testKey";
-  private final String testValue = "testValue";
-
-  @Before
-  public void start() {
-    mockCache = Mockito.mock(Cache.class);
-    mockRegion = Mockito.mock(Region.class);
-    when(mockCache.getRegion(testRegion)).thenReturn(mockRegion);
-
-  }
-
-  /**
-   * Given a serialized message that we've built, verify that the server part does the right call to
-   * the Cache it gets passed.
-   */
-  @Test
-  public void testNewClientProtocolPutsOnPutMessage() throws IOException {
-    ClientProtocol.Message message = MessageUtils.INSTANCE
-        .makePutMessageFor(testRegion, testKey, testValue);
-
-    OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
-
-    ProtobufProtocolMessageHandler newClientProtocol = new ProtobufProtocolMessageHandler();
-    newClientProtocol.receiveMessage(MessageUtils.INSTANCE.loadMessageIntoInputStream(message),
-        mockOutputStream, mockCache);
-
-    verify(mockRegion).put(testKey.getBytes(), testValue.getBytes());
-  }
-
-  @Test
-  public void testServerRespondsToPutMessage() throws IOException {
-    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(128);
-    ClientProtocol.Message message = MessageUtils.INSTANCE
-        .makePutMessageFor(testRegion, testKey, testValue);
-
-    ProtobufProtocolMessageHandler newClientProtocol = new ProtobufProtocolMessageHandler();
-    newClientProtocol.receiveMessage(MessageUtils.INSTANCE.loadMessageIntoInputStream(message), outputStream,
-        mockCache);
-
-    ClientProtocol.Message responseMessage = ClientProtocol.Message
-        .parseDelimitedFrom(new ByteArrayInputStream(outputStream.toByteArray()));
-
-    assertEquals(responseMessage.getMessageTypeCase(),
-        ClientProtocol.Message.MessageTypeCase.RESPONSE);
-    assertEquals(responseMessage.getResponse().getResponseAPICase(),
-        ClientProtocol.Response.ResponseAPICase.PUTRESPONSE);
-    assertTrue(responseMessage.getResponse().getPutResponse().getSuccess());
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.kt
----------------------------------------------------------------------
diff --git a/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.kt b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.kt
new file mode 100644
index 0000000..4a60993
--- /dev/null
+++ b/geode-client-protobuf/src/test/java/org/apache/geode/protocol/client/ProtobufSerializationDeserializationTest.kt
@@ -0,0 +1,94 @@
+/*
+ * 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.protocol.client
+
+
+import org.apache.geode.cache.Cache
+import org.apache.geode.cache.Region
+import org.apache.geode.protocol.protobuf.ClientProtocol
+import org.apache.geode.test.junit.categories.UnitTest
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Test
+import org.junit.experimental.categories.Category
+import org.mockito.Mockito
+import org.mockito.Mockito.`when`
+import org.mockito.Mockito.verify
+import java.io.ByteArrayInputStream
+import java.io.ByteArrayOutputStream
+import java.io.IOException
+import java.io.OutputStream
+
+
+@Category(UnitTest::class)
+class ProtobufSerializationDeserializationTest {
+
+    private lateinit var mockCache: Cache
+    private lateinit var mockRegion: Region<*, *>
+    private val testRegion = "testRegion"
+    private val testKey = "testKey"
+    private val testValue = "testValue"
+
+    @Before
+    fun start() {
+        mockCache = Mockito.mock(Cache::class.java)
+        mockRegion = Mockito.mock(Region::class.java)
+        `when`(mockCache.getRegion<Any, Any>(testRegion)).thenReturn(mockRegion as Region<Any, Any>)
+
+    }
+
+    /**
+     * Given a serialized message that we've built, verify that the server part does the right call to
+     * the Cache it gets passed.
+     */
+    @Test
+    @Throws(IOException::class)
+    fun testNewClientProtocolPutsOnPutMessage() {
+        val message = MessageUtils
+                .makePutMessageFor(region = testRegion, key = testKey, value = testValue)
+
+        val mockOutputStream = Mockito.mock(OutputStream::class.java)
+
+        val newClientProtocol = ProtobufProtocolMessageHandler()
+        newClientProtocol.receiveMessage(MessageUtils.loadMessageIntoInputStream(message),
+                mockOutputStream, mockCache)
+
+        verify(mockRegion as Region<Any, Any>).put(testKey, testValue)
+    }
+
+    @Test
+    @Throws(IOException::class)
+    fun testServerRespondsToPutMessage() {
+        val outputStream = ByteArrayOutputStream(128)
+        val message = MessageUtils
+                .makePutMessageFor(region = testRegion, key = testKey, value = testValue)
+
+        val newClientProtocol = ProtobufProtocolMessageHandler()
+        newClientProtocol.receiveMessage(MessageUtils.loadMessageIntoInputStream(message), outputStream,
+                mockCache)
+
+        val responseMessage = ClientProtocol.Message
+                .parseDelimitedFrom(ByteArrayInputStream(outputStream.toByteArray()))
+
+        assertEquals(responseMessage.messageTypeCase,
+                ClientProtocol.Message.MessageTypeCase.RESPONSE)
+        assertEquals(responseMessage.response.responseAPICase,
+                ClientProtocol.Response.ResponseAPICase.PUTRESPONSE)
+        assertTrue(responseMessage.response.putResponse.success)
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/geode/blob/6a5e4be3/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java b/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
index 79b0651..d551cef 100644
--- a/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
+++ b/geode-core/src/test/java/org/apache/geode/serialization/SerializationTypeTest.java
@@ -27,13 +27,13 @@ public class SerializationTypeTest {
   public void testLongSerialization() throws Exception {
     long testValue = 1311768465047740160L; // otherwise known as 0x123456780abadf00 bytes;
     byte[] expectedBytes =
-        new byte[]{0x12, 0x34, 0x56, 0x78, 0x0a, (byte) 0xba, (byte) 0xdf, 0x00};
+        new byte[] {0x12, 0x34, 0x56, 0x78, 0x0a, (byte) 0xba, (byte) 0xdf, 0x00};
     byte[] serializedBytes = SerializationType.LONG.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.LONG.deserialize(expectedBytes));
 
     testValue = -1311234265047740160L; // otherwise known as 0xedcd8f6216825100 bytes;
-    expectedBytes = new byte[]{(byte) 0xed, (byte) 0xcd, (byte) 0x8f, 0x62, 0x16, (byte) 0x82,
+    expectedBytes = new byte[] {(byte) 0xed, (byte) 0xcd, (byte) 0x8f, 0x62, 0x16, (byte) 0x82,
         (byte) 0x51, 0x00};
     serializedBytes = SerializationType.LONG.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
@@ -43,13 +43,13 @@ public class SerializationTypeTest {
   @Test
   public void testIntSerialization() throws Exception {
     int testValue = 313216366; // otherwise known as 0x12ab4d6e bytes;
-    byte[] expectedBytes = new byte[]{0x12, (byte) 0xab, 0x4d, 0x6e};
+    byte[] expectedBytes = new byte[] {0x12, (byte) 0xab, 0x4d, 0x6e};
     byte[] serializedBytes = SerializationType.INT.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.INT.deserialize(expectedBytes));
 
     testValue = -313216366; // otherwise known as 0xed54b292 bytes;
-    expectedBytes = new byte[]{(byte) 0xed, 0x54, (byte) 0xb2, (byte) 0x92};
+    expectedBytes = new byte[] {(byte) 0xed, 0x54, (byte) 0xb2, (byte) 0x92};
     serializedBytes = SerializationType.INT.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.INT.deserialize(expectedBytes));
@@ -58,13 +58,13 @@ public class SerializationTypeTest {
   @Test
   public void testShortSerialization() throws Exception {
     short testValue = 31321; // otherwise known as 0x7a59 bytes;
-    byte[] expectedBytes = new byte[]{0x7a, 0x59};
+    byte[] expectedBytes = new byte[] {0x7a, 0x59};
     byte[] serializedBytes = SerializationType.SHORT.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.SHORT.deserialize(expectedBytes));
 
     testValue = -22357; // otherwise known as 0xa8ab bytes;
-    expectedBytes = new byte[]{(byte) 0xa8, (byte) 0xab};
+    expectedBytes = new byte[] {(byte) 0xa8, (byte) 0xab};
     serializedBytes = SerializationType.SHORT.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.SHORT.deserialize(expectedBytes));
@@ -73,13 +73,13 @@ public class SerializationTypeTest {
   @Test
   public void testByteSerialization() throws Exception {
     byte testValue = 116;
-    byte[] expectedBytes = new byte[]{116};
+    byte[] expectedBytes = new byte[] {116};
     byte[] serializedBytes = SerializationType.BYTE.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.BYTE.deserialize(expectedBytes));
 
     testValue = -87;
-    expectedBytes = new byte[]{-87};
+    expectedBytes = new byte[] {-87};
     serializedBytes = SerializationType.BYTE.serialize(testValue);
     assertArrayEquals(expectedBytes, serializedBytes);
     assertEquals(testValue, SerializationType.BYTE.deserialize(expectedBytes));
@@ -96,16 +96,12 @@ public class SerializationTypeTest {
       + "which requires a Cache.")
   @Test
   public void testJSONSerialization() {
-    String[] testStrings = {
-        "\"testString\"",
-        "{}",
-        "{\"foo\":\"bar\",\"list :\":[1,2,\"boo\"],hash:{1:2,3:4}}"
-    };
+    String[] testStrings =
+        {"\"testString\"", "{}", "{\"foo\":\"bar\",\"list :\":[1,2,\"boo\"],hash:{1:2,3:4}}"};
 
     for (String string : testStrings) {
       byte[] serialized = SerializationType.JSON.serialize(string);
-      String deserialized =
-          (String) SerializationType.JSON.deserializer.deserialize(serialized);
+      String deserialized = (String) SerializationType.JSON.deserializer.deserialize(serialized);
       assertEquals(string, deserialized);
       fail("This test is not yet complete");
     }