Repository: geode Updated Branches: refs/heads/develop 49123c475 -> e1c6c3a97
GEODE-2995: incorporating even more review feedback Addressing feedback from Udo and Hitesh Refactored test locations to match new src layout Signed-off-by: Galen O'Sullivan <gosulli...@pivotal.io> Signed-off-by: Brian Rowe <br...@pivotal.io> Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/a3c66e1a Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/a3c66e1a Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/a3c66e1a Branch: refs/heads/develop Commit: a3c66e1afc88700bd7839f56d54a0f6d44f00432 Parents: 0de1d97 Author: Brian Rowe <br...@pivotal.io> Authored: Wed Jun 21 11:53:54 2017 -0700 Committer: Hitesh Khamesra <hkhame...@pivotal.io> Committed: Mon Jun 26 09:26:22 2017 -0700 ---------------------------------------------------------------------- geode-protobuf/build.gradle | 6 +- .../protobuf/EncodingTypeTranslator.java | 47 +++---- .../operations/GetRequestOperationHandler.java | 19 +-- .../geode/client/protocol/IntegrationTest.java | 124 ------------------- .../geode/client/protocol/MessageUtil.java | 41 ------ .../geode/client/protocol/OpsHandler.java | 21 ---- .../geode/protocol/IntegrationJUnitTest.java | 124 +++++++++++++++++++ .../org/apache/geode/protocol/MessageUtil.java | 41 ++++++ .../org/apache/geode/protocol/OpsHandler.java | 21 ++++ .../GetRequestOperationHandlerTest.java | 95 -------------- ...eToSerializationTypeTranslatorJUnitTest.java | 73 +++++++++++ .../protobuf/ProtobufOpsProcessorJUnitTest.java | 62 ++++++++++ .../protobuf/ProtobufOpsProcessorTest.java | 62 ---------- .../GetRequestOperationHandlerJUnitTest.java | 96 ++++++++++++++ .../ProtobufProtocolSerializerJUnitTest.java | 2 +- .../ProtobufSerializationServiceImplTest.java | 58 --------- .../ProtobufSerializationServiceJUnitTest.java | 111 +++++++++++++++++ .../codec/BinaryFormatJUnitTest.java | 64 ++++++++++ .../codec/StringCodecJUnitTest.java | 64 ---------- ...eToSerializationTypeTranslatorJUnitTest.java | 73 ----------- gradle/dependency-versions.properties | 3 + 21 files changed, 637 insertions(+), 570 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/build.gradle ---------------------------------------------------------------------- diff --git a/geode-protobuf/build.gradle b/geode-protobuf/build.gradle index f069267..a63000e 100644 --- a/geode-protobuf/build.gradle +++ b/geode-protobuf/build.gradle @@ -23,7 +23,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1' + classpath 'com.google.protobuf:protobuf-gradle-plugin:' + project.'protobuf-gradle-plugin.version' } } @@ -36,13 +36,13 @@ dependencies { testCompile 'org.powermock:powermock-module-junit4:' + project.'powermock.version' testCompile 'org.powermock:powermock-api-mockito:' + project.'powermock.version' - compile 'com.google.protobuf:protobuf-java:3.3.1' + compile 'com.google.protobuf:protobuf-java:' + project.'protobuf-java.version' } protobuf { protoc { // The artifact spec for the Protobuf Compiler - artifact = 'com.google.protobuf:protoc:3.0.0' + artifact = 'com.google.protobuf:protoc:' + project.'protoc.version' } generatedFilesBaseDir = "$buildDir/generated-src/proto" } http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java index 650ac81..edb7c7e 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/EncodingTypeTranslator.java @@ -20,10 +20,28 @@ import org.apache.geode.protocol.protobuf.BasicTypes; import org.apache.geode.serialization.SerializationType; import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; +import java.util.HashMap; + /** * This class maps protobuf specific encoding types and the corresponding serialization types. */ public abstract class EncodingTypeTranslator { + static final HashMap<Class, BasicTypes.EncodingType> typeToEncodingMap = intializeTypeMap(); + + private static HashMap<Class, BasicTypes.EncodingType> intializeTypeMap() { + HashMap<Class, BasicTypes.EncodingType> result = new HashMap<>(); + result.put(Integer.class, BasicTypes.EncodingType.INT); + result.put(Byte.class, BasicTypes.EncodingType.BYTE); + result.put(Long.class, BasicTypes.EncodingType.LONG); + result.put(Float.class, BasicTypes.EncodingType.FLOAT); + result.put(Short.class, BasicTypes.EncodingType.SHORT); + result.put(byte[].class, BasicTypes.EncodingType.BINARY); + result.put(Double.class, BasicTypes.EncodingType.DOUBLE); + result.put(String.class, BasicTypes.EncodingType.STRING); + result.put(Boolean.class, BasicTypes.EncodingType.BOOLEAN); + return result; + } + public static SerializationType getSerializationTypeForEncodingType( BasicTypes.EncodingType encodingType) throws UnsupportedEncodingTypeException { switch (encodingType) { @@ -55,32 +73,19 @@ public abstract class EncodingTypeTranslator { public static BasicTypes.EncodingType getEncodingTypeForObject(Object resultValue) throws UnsupportedEncodingTypeException { - if (resultValue instanceof Integer) { - return BasicTypes.EncodingType.INT; - } else if (resultValue instanceof Byte) { - return BasicTypes.EncodingType.BYTE; - } else if (resultValue instanceof PdxInstance) { + if (resultValue instanceof PdxInstance) { String pdxClassName = ((PdxInstance) resultValue).getClassName(); if (pdxClassName.equals(JSONFormatter.JSON_CLASSNAME)) { return BasicTypes.EncodingType.JSON; } - } else if (resultValue instanceof Long) { - return BasicTypes.EncodingType.LONG; - } else if (resultValue instanceof Float) { - return BasicTypes.EncodingType.FLOAT; - } else if (resultValue instanceof Short) { - return BasicTypes.EncodingType.SHORT; - } else if (resultValue instanceof byte[]) { - return BasicTypes.EncodingType.BINARY; - } else if (resultValue instanceof Double) { - return BasicTypes.EncodingType.DOUBLE; - } else if (resultValue instanceof String) { - return BasicTypes.EncodingType.STRING; - } else if (resultValue instanceof Boolean) { - return BasicTypes.EncodingType.BOOLEAN; } - throw new UnsupportedEncodingTypeException( - "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding"); + BasicTypes.EncodingType encodingType = typeToEncodingMap.get(resultValue.getClass()); + if (encodingType == null) { + throw new UnsupportedEncodingTypeException( + "We cannot translate: " + resultValue.getClass() + " into a specific Protobuf Encoding"); + } else { + return encodingType; + } } } http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java index 37d1d32..d9c1475 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandler.java @@ -23,6 +23,7 @@ import org.apache.geode.protocol.protobuf.ClientProtocol; import org.apache.geode.protocol.protobuf.RegionAPI; import org.apache.geode.serialization.SerializationService; import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; +import org.apache.geode.serialization.exception.TypeEncodingException; import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; @@ -31,8 +32,7 @@ public class GetRequestOperationHandler @Override public RegionAPI.GetResponse process(SerializationService serializationService, - RegionAPI.GetRequest request, Cache cache) - throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { + RegionAPI.GetRequest request, Cache cache) throws TypeEncodingException { String regionName = request.getRegionName(); BasicTypes.EncodedValue key = request.getKey(); BasicTypes.EncodingType encodingType = key.getEncodingType(); @@ -42,6 +42,16 @@ public class GetRequestOperationHandler Region region = cache.getRegion(regionName); Object resultValue = region.get(decodedValue); + return buildGetResponse(serializationService, resultValue); + } + + @Override + public int getOperationCode() { + return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber(); + } + + private RegionAPI.GetResponse buildGetResponse(SerializationService serializationService, + Object resultValue) throws TypeEncodingException { BasicTypes.EncodingType resultEncodingType = EncodingTypeTranslator.getEncodingTypeForObject(resultValue); byte[] resultEncodedValue = serializationService.encode(resultEncodingType, resultValue); @@ -50,9 +60,4 @@ public class GetRequestOperationHandler .setResult(ProtobufUtilities.getEncodedValue(resultEncodingType, resultEncodedValue)) .build(); } - - @Override - public int getOperationCode() { - return ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber(); - } } http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java deleted file mode 100644 index 63cde31..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/IntegrationTest.java +++ /dev/null @@ -1,124 +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.client.protocol; - -import com.google.protobuf.ByteString; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.protocol.protobuf.ProtobufStreamProcessor; -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.serialization.codec.StringCodec; -import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; -import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; -import org.apache.geode.serialization.registry.SerializationCodecRegistry; -import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException; -import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; -import org.apache.geode.test.dunit.Assert; -import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -@Category(UnitTest.class) -public class IntegrationTest { - - public static final String TEST_KEY = "my key"; - public static final String TEST_VALUE = "my value"; - public static final String TEST_REGION = "test region"; - private StringCodec stringCodec; - private Cache cacheStub; - private Region regionStub; - - @Before - public void setup() throws CodecAlreadyRegisteredForTypeException, - UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { - SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry(); - stringCodec = (StringCodec) serializationCodecRegistry.getCodecForType( - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING)); - regionStub = getRegionStub(); - cacheStub = getCacheStub(regionStub); - } - - @Test - public void testGetRequestProcessed() throws Exception { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor(); - streamProcessor.processOneMessage(getInputStream(getRequest(stringCodec)), outputStream, - cacheStub); - - RegionAPI.GetResponse getResponse = getGetResponse(outputStream); - - Assert.assertNotNull(getResponse); - Assert.assertEquals(BasicTypes.EncodingType.STRING, getResponse.getResult().getEncodingType()); - String actualValue = stringCodec.decode(getResponse.getResult().getValue().toByteArray()); - Assert.assertEquals(TEST_VALUE, actualValue); - verify(regionStub, times(1)).get(TEST_KEY); - verify(regionStub, times(1)).get(anyString()); - } - - private Region getRegionStub() { - regionStub = mock(Region.class); - when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE); - return regionStub; - } - - private Cache getCacheStub(Region region) { - Cache cacheStub = mock(Cache.class); - when(cacheStub.getRegion(TEST_REGION)).thenReturn(region); - return cacheStub; - } - - private RegionAPI.GetResponse getGetResponse(ByteArrayOutputStream outputStream) - throws IOException { - ByteArrayInputStream helperInputStream = new ByteArrayInputStream(outputStream.toByteArray()); - ClientProtocol.Message responseMessage = - ClientProtocol.Message.parseDelimitedFrom(helperInputStream); - ClientProtocol.Response response = responseMessage.getResponse(); - return response.getGetResponse(); - } - - private ByteArrayInputStream getInputStream(ClientProtocol.Message request) throws IOException { - ByteArrayOutputStream helperOutputStream = new ByteArrayOutputStream(); - request.writeDelimitedTo(helperOutputStream); - return new ByteArrayInputStream(helperOutputStream.toByteArray()); - } - - private ClientProtocol.Message getRequest(StringCodec stringCodec) { - RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder(); - getRequestBuilder.setRegionName(TEST_REGION) - .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING) - .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY)))); - ClientProtocol.Request request = - ClientProtocol.Request.newBuilder().setGetRequest(getRequestBuilder).build(); - ClientProtocol.Message requestMessage = ClientProtocol.Message.newBuilder() - .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setRequest(request).build(); - - return requestMessage; - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java deleted file mode 100644 index c830b01..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/MessageUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.client.protocol; - -import org.apache.geode.protocol.protobuf.ClientProtocol; -import org.apache.geode.protocol.protobuf.RegionAPI; - -public class MessageUtil { - public static ClientProtocol.Message createGetRequestMessage() { - ClientProtocol.Message.Builder messageBuilder = ClientProtocol.Message.newBuilder(); - messageBuilder.setMessageHeader(getMessageHeaderBuilder()); - ClientProtocol.Request.Builder requestBuilder = getRequestBuilder(); - requestBuilder.setGetRequest(getGetRequestBuilder()); - messageBuilder.setRequest(requestBuilder); - return messageBuilder.build(); - } - - private static ClientProtocol.Request.Builder getRequestBuilder() { - return ClientProtocol.Request.newBuilder(); - } - - private static RegionAPI.GetRequest.Builder getGetRequestBuilder() { - return RegionAPI.GetRequest.newBuilder(); - } - - private static ClientProtocol.MessageHeader.Builder getMessageHeaderBuilder() { - return ClientProtocol.MessageHeader.newBuilder(); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java b/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java deleted file mode 100644 index 793dace..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/client/protocol/OpsHandler.java +++ /dev/null @@ -1,21 +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.client.protocol; - -import org.apache.geode.serialization.registry.SerializationCodecRegistry; - -public interface OpsHandler<Req, Resp> { - Resp process(SerializationCodecRegistry serializationCodecRegistry, Req request); -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java new file mode 100644 index 0000000..42cc7b3 --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/IntegrationJUnitTest.java @@ -0,0 +1,124 @@ +/* + * 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; + +import com.google.protobuf.ByteString; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.Region; +import org.apache.geode.protocol.protobuf.ProtobufStreamProcessor; +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.serialization.codec.StringCodec; +import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; +import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; +import org.apache.geode.serialization.registry.SerializationCodecRegistry; +import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException; +import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; +import org.apache.geode.test.dunit.Assert; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +@Category(UnitTest.class) +public class IntegrationJUnitTest { + + public static final String TEST_KEY = "my key"; + public static final String TEST_VALUE = "my value"; + public static final String TEST_REGION = "test region"; + private StringCodec stringCodec; + private Cache cacheStub; + private Region regionStub; + + @Before + public void setup() throws CodecAlreadyRegisteredForTypeException, + UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { + SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry(); + stringCodec = (StringCodec) serializationCodecRegistry.getCodecForType( + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING)); + regionStub = getRegionStub(); + cacheStub = getCacheStub(regionStub); + } + + @Test + public void testGetRequestProcessed() throws Exception { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + ProtobufStreamProcessor streamProcessor = new ProtobufStreamProcessor(); + streamProcessor.processOneMessage(getInputStream(getRequest(stringCodec)), outputStream, + cacheStub); + + RegionAPI.GetResponse getResponse = getGetResponse(outputStream); + + Assert.assertNotNull(getResponse); + Assert.assertEquals(BasicTypes.EncodingType.STRING, getResponse.getResult().getEncodingType()); + String actualValue = stringCodec.decode(getResponse.getResult().getValue().toByteArray()); + Assert.assertEquals(TEST_VALUE, actualValue); + verify(regionStub, times(1)).get(TEST_KEY); + verify(regionStub, times(1)).get(anyString()); + } + + private Region getRegionStub() { + regionStub = mock(Region.class); + when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE); + return regionStub; + } + + private Cache getCacheStub(Region region) { + Cache cacheStub = mock(Cache.class); + when(cacheStub.getRegion(TEST_REGION)).thenReturn(region); + return cacheStub; + } + + private RegionAPI.GetResponse getGetResponse(ByteArrayOutputStream outputStream) + throws IOException { + ByteArrayInputStream helperInputStream = new ByteArrayInputStream(outputStream.toByteArray()); + ClientProtocol.Message responseMessage = + ClientProtocol.Message.parseDelimitedFrom(helperInputStream); + ClientProtocol.Response response = responseMessage.getResponse(); + return response.getGetResponse(); + } + + private ByteArrayInputStream getInputStream(ClientProtocol.Message request) throws IOException { + ByteArrayOutputStream helperOutputStream = new ByteArrayOutputStream(); + request.writeDelimitedTo(helperOutputStream); + return new ByteArrayInputStream(helperOutputStream.toByteArray()); + } + + private ClientProtocol.Message getRequest(StringCodec stringCodec) { + RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder(); + getRequestBuilder.setRegionName(TEST_REGION) + .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING) + .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY)))); + ClientProtocol.Request request = + ClientProtocol.Request.newBuilder().setGetRequest(getRequestBuilder).build(); + ClientProtocol.Message requestMessage = ClientProtocol.Message.newBuilder() + .setMessageHeader(ClientProtocol.MessageHeader.newBuilder()).setRequest(request).build(); + + return requestMessage; + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java new file mode 100644 index 0000000..f0b0b41 --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java @@ -0,0 +1,41 @@ +/* + * 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; + +import org.apache.geode.protocol.protobuf.ClientProtocol; +import org.apache.geode.protocol.protobuf.RegionAPI; + +public class MessageUtil { + public static ClientProtocol.Message createGetRequestMessage() { + ClientProtocol.Message.Builder messageBuilder = ClientProtocol.Message.newBuilder(); + messageBuilder.setMessageHeader(getMessageHeaderBuilder()); + ClientProtocol.Request.Builder requestBuilder = getRequestBuilder(); + requestBuilder.setGetRequest(getGetRequestBuilder()); + messageBuilder.setRequest(requestBuilder); + return messageBuilder.build(); + } + + private static ClientProtocol.Request.Builder getRequestBuilder() { + return ClientProtocol.Request.newBuilder(); + } + + private static RegionAPI.GetRequest.Builder getGetRequestBuilder() { + return RegionAPI.GetRequest.newBuilder(); + } + + private static ClientProtocol.MessageHeader.Builder getMessageHeaderBuilder() { + return ClientProtocol.MessageHeader.newBuilder(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java new file mode 100644 index 0000000..2b4aa21 --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/OpsHandler.java @@ -0,0 +1,21 @@ +/* + * 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; + +import org.apache.geode.serialization.registry.SerializationCodecRegistry; + +public interface OpsHandler<Req, Resp> { + Resp process(SerializationCodecRegistry serializationCodecRegistry, Req request); +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java deleted file mode 100644 index cb98eb7..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/operations/protobuf/GetRequestOperationHandlerTest.java +++ /dev/null @@ -1,95 +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.operations.protobuf; - -import com.google.protobuf.ByteString; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.protocol.protobuf.BasicTypes; -import org.apache.geode.protocol.protobuf.RegionAPI; -import org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler; -import org.apache.geode.serialization.SerializationService; -import org.apache.geode.serialization.codec.StringCodec; -import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; -import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; -import org.apache.geode.serialization.registry.SerializationCodecRegistry; -import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException; -import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; -import org.apache.geode.test.dunit.Assert; -import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.nio.charset.Charset; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@Category(UnitTest.class) -public class GetRequestOperationHandlerTest { - public static final String TEST_KEY = "my key"; - public static final String TEST_VALUE = "my value"; - public static final String TEST_REGION = "test region"; - public Cache cacheStub; - public SerializationService serializationServiceStub; - - @Before - public void setUp() throws Exception { - serializationServiceStub = mock(SerializationService.class); - when(serializationServiceStub.decode(BasicTypes.EncodingType.STRING, - TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenReturn(TEST_KEY); - when(serializationServiceStub.encode(BasicTypes.EncodingType.STRING, TEST_VALUE)) - .thenReturn(TEST_VALUE.getBytes(Charset.forName("UTF-8"))); - - Region regionStub = mock(Region.class); - when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE); - - cacheStub = mock(Cache.class); - when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); - } - - @Test - public void processReturnsTheEncodedValueFromTheRegion() throws UnsupportedEncodingTypeException, - CodecNotRegisteredForTypeException, CodecAlreadyRegisteredForTypeException { - GetRequestOperationHandler operationHandler = new GetRequestOperationHandler(); - - RegionAPI.GetResponse response = - operationHandler.process(serializationServiceStub, makeGetRequest(), cacheStub); - - Assert.assertEquals(BasicTypes.EncodingType.STRING, response.getResult().getEncodingType()); - String actualValue = getStringCodec().decode(response.getResult().getValue().toByteArray()); - Assert.assertEquals(TEST_VALUE, actualValue); - } - - private RegionAPI.GetRequest makeGetRequest() throws CodecNotRegisteredForTypeException, - UnsupportedEncodingTypeException, CodecAlreadyRegisteredForTypeException { - StringCodec stringCodec = getStringCodec(); - RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder(); - getRequestBuilder.setRegionName(TEST_REGION) - .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING) - .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY)))); - - return getRequestBuilder.build(); - } - - private StringCodec getStringCodec() throws CodecAlreadyRegisteredForTypeException, - CodecNotRegisteredForTypeException, UnsupportedEncodingTypeException { - SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry(); - return (StringCodec) serializationCodecRegistry.getCodecForType( - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING)); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java new file mode 100644 index 0000000..8e6f66a --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/EncodingTypeToSerializationTypeTranslatorJUnitTest.java @@ -0,0 +1,73 @@ +/* + * 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.protobuf; + +import static org.junit.Assert.assertSame; + +import org.apache.geode.protocol.protobuf.BasicTypes; +import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; +import org.apache.geode.serialization.SerializationType; +import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class EncodingTypeToSerializationTypeTranslatorJUnitTest { + + @Test + public void testTranslateEncodingTypes() throws UnsupportedEncodingTypeException { + assertSame(SerializationType.INT, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INT)); + assertSame(SerializationType.LONG, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.LONG)); + assertSame(SerializationType.SHORT, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.SHORT)); + assertSame(SerializationType.BYTE, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BYTE)); + assertSame(SerializationType.BOOLEAN, EncodingTypeTranslator + .getSerializationTypeForEncodingType(BasicTypes.EncodingType.BOOLEAN)); + assertSame(SerializationType.BINARY, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BINARY)); + assertSame(SerializationType.FLOAT, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.FLOAT)); + assertSame(SerializationType.DOUBLE, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.DOUBLE)); + assertSame(SerializationType.STRING, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING)); + assertSame(SerializationType.JSON, + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.JSON)); + } + + @Test(expected = UnsupportedEncodingTypeException.class) + public void testTranslateInvalidEncoding_throwsException() + throws UnsupportedEncodingTypeException { + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INVALID); + } + + @Test + public void testAllEncodingTypeTranslations() { + for (BasicTypes.EncodingType encodingType : BasicTypes.EncodingType.values()) { + if (!(encodingType.equals(BasicTypes.EncodingType.UNRECOGNIZED) + || encodingType.equals(BasicTypes.EncodingType.INVALID))) { + try { + EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingType); + } catch (UnsupportedEncodingTypeException e) { + e.printStackTrace(); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java new file mode 100644 index 0000000..fc980ae --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorJUnitTest.java @@ -0,0 +1,62 @@ +/* + * 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.protobuf; + + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.cache.Cache; +import org.apache.geode.protocol.exception.InvalidProtocolMessageException; +import org.apache.geode.protocol.operations.OperationHandler; +import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry; +import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException; +import org.apache.geode.serialization.SerializationService; +import org.apache.geode.serialization.exception.TypeEncodingException; +import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; +import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class ProtobufOpsProcessorJUnitTest { + @Test + public void testOpsProcessor() throws TypeEncodingException, + OperationHandlerNotRegisteredException, InvalidProtocolMessageException { + OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class); + OperationHandler operationHandlerStub = mock(OperationHandler.class); + SerializationService serializationServiceStub = mock(SerializationService.class); + Cache dummyCache = mock(Cache.class); + int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber(); + + ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder() + .setGetRequest(RegionAPI.GetRequest.newBuilder()).build(); + + RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build(); + + when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID)) + .thenReturn(operationHandlerStub); + when(operationHandlerStub.process(serializationServiceStub, + ProtobufOpsProcessor.getRequestForOperationTypeID(messageRequest), dummyCache)) + .thenReturn(expectedResponse); + + ProtobufOpsProcessor processor = + new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub); + ClientProtocol.Response response = processor.process(messageRequest, dummyCache); + Assert.assertEquals(expectedResponse, response.getGetResponse()); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java deleted file mode 100644 index ac3d68f..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/ProtobufOpsProcessorTest.java +++ /dev/null @@ -1,62 +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.protobuf; - - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.geode.cache.Cache; -import org.apache.geode.protocol.exception.InvalidProtocolMessageException; -import org.apache.geode.protocol.operations.OperationHandler; -import org.apache.geode.protocol.operations.registry.OperationsHandlerRegistry; -import org.apache.geode.protocol.operations.registry.exception.OperationHandlerNotRegisteredException; -import org.apache.geode.serialization.SerializationService; -import org.apache.geode.serialization.exception.TypeEncodingException; -import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; -import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; -import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) -public class ProtobufOpsProcessorTest { - @Test - public void testOpsProcessor() throws TypeEncodingException, - OperationHandlerNotRegisteredException, InvalidProtocolMessageException { - OperationsHandlerRegistry opsHandlerRegistryStub = mock(OperationsHandlerRegistry.class); - OperationHandler operationHandlerStub = mock(OperationHandler.class); - SerializationService serializationServiceStub = mock(SerializationService.class); - Cache dummyCache = mock(Cache.class); - int operationID = ClientProtocol.Request.RequestAPICase.GETREQUEST.getNumber(); - - ClientProtocol.Request messageRequest = ClientProtocol.Request.newBuilder() - .setGetRequest(RegionAPI.GetRequest.newBuilder()).build(); - - RegionAPI.GetResponse expectedResponse = RegionAPI.GetResponse.newBuilder().build(); - - when(opsHandlerRegistryStub.getOperationHandlerForOperationId(operationID)) - .thenReturn(operationHandlerStub); - when(operationHandlerStub.process(serializationServiceStub, - ProtobufOpsProcessor.getRequestForOperationTypeID(messageRequest), dummyCache)) - .thenReturn(expectedResponse); - - ProtobufOpsProcessor processor = - new ProtobufOpsProcessor(opsHandlerRegistryStub, serializationServiceStub); - ClientProtocol.Response response = processor.process(messageRequest, dummyCache); - Assert.assertEquals(expectedResponse, response.getGetResponse()); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java new file mode 100644 index 0000000..daa5870 --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java @@ -0,0 +1,96 @@ +/* + * 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.protobuf.operations; + +import com.google.protobuf.ByteString; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.Region; +import org.apache.geode.protocol.protobuf.BasicTypes; +import org.apache.geode.protocol.protobuf.RegionAPI; +import org.apache.geode.protocol.protobuf.operations.GetRequestOperationHandler; +import org.apache.geode.serialization.SerializationService; +import org.apache.geode.serialization.codec.StringCodec; +import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; +import org.apache.geode.serialization.exception.TypeEncodingException; +import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; +import org.apache.geode.serialization.registry.SerializationCodecRegistry; +import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException; +import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; +import org.apache.geode.test.dunit.Assert; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.nio.charset.Charset; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@Category(UnitTest.class) +public class GetRequestOperationHandlerJUnitTest { + public static final String TEST_KEY = "my key"; + public static final String TEST_VALUE = "my value"; + public static final String TEST_REGION = "test region"; + public Cache cacheStub; + public SerializationService serializationServiceStub; + + @Before + public void setUp() throws Exception { + serializationServiceStub = mock(SerializationService.class); + when(serializationServiceStub.decode(BasicTypes.EncodingType.STRING, + TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenReturn(TEST_KEY); + when(serializationServiceStub.encode(BasicTypes.EncodingType.STRING, TEST_VALUE)) + .thenReturn(TEST_VALUE.getBytes(Charset.forName("UTF-8"))); + + Region regionStub = mock(Region.class); + when(regionStub.get(TEST_KEY)).thenReturn(TEST_VALUE); + + cacheStub = mock(Cache.class); + when(cacheStub.getRegion(TEST_REGION)).thenReturn(regionStub); + } + + @Test + public void processReturnsTheEncodedValueFromTheRegion() + throws TypeEncodingException, CodecAlreadyRegisteredForTypeException { + GetRequestOperationHandler operationHandler = new GetRequestOperationHandler(); + + RegionAPI.GetResponse response = + operationHandler.process(serializationServiceStub, makeGetRequest(), cacheStub); + + Assert.assertEquals(BasicTypes.EncodingType.STRING, response.getResult().getEncodingType()); + String actualValue = getStringCodec().decode(response.getResult().getValue().toByteArray()); + Assert.assertEquals(TEST_VALUE, actualValue); + } + + private RegionAPI.GetRequest makeGetRequest() throws CodecNotRegisteredForTypeException, + UnsupportedEncodingTypeException, CodecAlreadyRegisteredForTypeException { + StringCodec stringCodec = getStringCodec(); + RegionAPI.GetRequest.Builder getRequestBuilder = RegionAPI.GetRequest.newBuilder(); + getRequestBuilder.setRegionName(TEST_REGION) + .setKey(BasicTypes.EncodedValue.newBuilder().setEncodingType(BasicTypes.EncodingType.STRING) + .setValue(ByteString.copyFrom(stringCodec.encode(TEST_KEY)))); + + return getRequestBuilder.build(); + } + + private StringCodec getStringCodec() throws CodecAlreadyRegisteredForTypeException, + CodecNotRegisteredForTypeException, UnsupportedEncodingTypeException { + SerializationCodecRegistry serializationCodecRegistry = new SerializationCodecRegistry(); + return (StringCodec) serializationCodecRegistry.getCodecForType( + EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING)); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java index e1f7b5b..5a94dae 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/serializer/ProtobufProtocolSerializerJUnitTest.java @@ -14,7 +14,7 @@ */ package org.apache.geode.protocol.serializer; -import org.apache.geode.client.protocol.MessageUtil; +import org.apache.geode.protocol.MessageUtil; import org.apache.geode.protocol.exception.InvalidProtocolMessageException; import org.apache.geode.protocol.protobuf.serializer.ProtobufProtocolSerializer; import org.apache.geode.protocol.protobuf.ClientProtocol; http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java deleted file mode 100644 index ef841c3..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceImplTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.serialization; - -import org.apache.geode.protocol.protobuf.BasicTypes; -import org.apache.geode.protocol.protobuf.ProtobufSerializationService; -import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; -import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException; -import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; -import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) -public class ProtobufSerializationServiceImplTest { - - public static final String PAYLOAD = "my value"; - - @Test - public void valuesPreservedByEncodingThenDecoding() throws CodecAlreadyRegisteredForTypeException, - UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { - ProtobufSerializationService protobufSerializationService = new ProtobufSerializationService(); - - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.STRING, "testString"); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.FLOAT, (float) 34.23); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.DOUBLE, 34.23); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.INT, 45); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.SHORT, (short) 45); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BYTE, (byte) 45); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.LONG, (long) 45); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, false); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, true); - testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BINARY, - "testString".getBytes()); - // TODO: Test JSON conversion - } - - private void testEncodeDecode(ProtobufSerializationService service, - BasicTypes.EncodingType encodingType, Object data) - throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { - byte[] encodedValue = service.encode(encodingType, data); - Object decodedValue = service.decode(encodingType, encodedValue); - Assert.assertEquals(data, decodedValue); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java new file mode 100644 index 0000000..122c8bc --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/ProtobufSerializationServiceJUnitTest.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.serialization; + +import org.apache.geode.protocol.protobuf.BasicTypes; +import org.apache.geode.protocol.protobuf.ProtobufSerializationService; +import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; +import org.apache.geode.serialization.registry.exception.CodecAlreadyRegisteredForTypeException; +import org.apache.geode.serialization.registry.exception.CodecNotRegisteredForTypeException; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class ProtobufSerializationServiceJUnitTest { + + public static final String PAYLOAD = "my value"; + private ProtobufSerializationService protobufSerializationService; + + @Before + public void setup() throws CodecAlreadyRegisteredForTypeException { + protobufSerializationService = new ProtobufSerializationService(); + } + + @Test + public void stringValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.STRING, "testString"); + } + + @Test + public void floatValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.FLOAT, (float) 34.23); + } + + @Test + public void doubleValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.DOUBLE, 34.23); + } + + @Test + public void intValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.INT, 45); + } + + @Test + public void shortValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.SHORT, (short) 45); + } + + @Test + public void byteValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BYTE, (byte) 45); + } + + @Test + public void longValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.LONG, (long) 45); + } + + @Test + public void booleanValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, false); + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BOOLEAN, true); + } + + @Test + public void binaryValuesPreservedByEncodingThenDecoding() + throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, + CodecNotRegisteredForTypeException { + testEncodeDecode(protobufSerializationService, BasicTypes.EncodingType.BINARY, + "testString".getBytes()); + } + + private void testEncodeDecode(ProtobufSerializationService service, + BasicTypes.EncodingType encodingType, Object data) + throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { + byte[] encodedValue = service.encode(encodingType, data); + Object decodedValue = service.decode(encodingType, encodedValue); + Assert.assertEquals(data, decodedValue); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java new file mode 100644 index 0000000..dd72a19 --- /dev/null +++ b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/BinaryFormatJUnitTest.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.serialization.codec; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.nio.charset.Charset; + +@Category(UnitTest.class) +public class BinaryFormatJUnitTest { + private static final Charset UTF8 = Charset.forName("UTF-8"); + private static final Charset UTF16 = Charset.forName("UTF-16"); + private String testString = "Test String"; + + private StringCodec stringCodec; + + @Before + public void startup() { + stringCodec = new StringCodec(); + } + + @Test + public void testStringsUseUTF8Encoding() { + assertArrayEquals(testString.getBytes(UTF8), stringCodec.encode(testString)); + } + + @Test + public void testStringDontUseUTF16Encoding() { + byte[] expectedEncodedString = stringCodec.encode(testString); + byte[] incorrectEncodedString = testString.getBytes(UTF16); + assertNotEquals(expectedEncodedString.length, incorrectEncodedString.length); + } + + @Test + public void testImproperlyEncodedStringDecodingFails() { + byte[] encodedString = testString.getBytes(UTF16); + assertNotEquals(testString, stringCodec.decode(encodedString)); + } + + @Test + public void testProperlyEncodedStringDecoding() { + byte[] encodedString = testString.getBytes(UTF8); + assertEquals(testString, stringCodec.decode(encodedString)); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java deleted file mode 100644 index 8cd6029..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/serialization/codec/StringCodecJUnitTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.serialization.codec; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.nio.charset.Charset; - -@Category(UnitTest.class) -public class StringCodecJUnitTest { - private static final Charset UTF8 = Charset.forName("UTF-8"); - private static final Charset UTF16 = Charset.forName("UTF-16"); - private String testString = "Test String"; - - private StringCodec stringCodec; - - @Before - public void startup() { - stringCodec = new StringCodec(); - } - - @Test - public void testStringEncoding() { - assertArrayEquals(testString.getBytes(UTF8), stringCodec.encode(testString)); - } - - @Test - public void testStringIncompatibleEncoding() { - byte[] expectedEncodedString = stringCodec.encode(testString); - byte[] incorrectEncodedString = testString.getBytes(UTF16); - assertNotEquals(expectedEncodedString.length, incorrectEncodedString.length); - } - - @Test - public void testStringDecodingWithIncorrectEncodedString() { - byte[] encodedString = testString.getBytes(UTF16); - assertNotEquals(testString, stringCodec.decode(encodedString)); - } - - @Test - public void testStringDecoding() { - byte[] encodedString = testString.getBytes(UTF8); - assertEquals(testString, stringCodec.decode(encodedString)); - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java deleted file mode 100644 index 963cb85..0000000 --- a/geode-protobuf/src/test/java/org/apache/geode/serialization/protobuf/translation/EncodingTypeToSerializationTypeTranslatorJUnitTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.serialization.protobuf.translation; - -import static org.junit.Assert.assertSame; - -import org.apache.geode.protocol.protobuf.BasicTypes; -import org.apache.geode.protocol.protobuf.EncodingTypeTranslator; -import org.apache.geode.serialization.SerializationType; -import org.apache.geode.serialization.exception.UnsupportedEncodingTypeException; -import org.apache.geode.test.junit.categories.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) -public class EncodingTypeToSerializationTypeTranslatorJUnitTest { - - @Test - public void testTranslateEncodingTypes() throws UnsupportedEncodingTypeException { - assertSame(SerializationType.INT, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INT)); - assertSame(SerializationType.LONG, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.LONG)); - assertSame(SerializationType.SHORT, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.SHORT)); - assertSame(SerializationType.BYTE, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BYTE)); - assertSame(SerializationType.BOOLEAN, EncodingTypeTranslator - .getSerializationTypeForEncodingType(BasicTypes.EncodingType.BOOLEAN)); - assertSame(SerializationType.BINARY, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.BINARY)); - assertSame(SerializationType.FLOAT, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.FLOAT)); - assertSame(SerializationType.DOUBLE, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.DOUBLE)); - assertSame(SerializationType.STRING, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.STRING)); - assertSame(SerializationType.JSON, - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.JSON)); - } - - @Test(expected = UnsupportedEncodingTypeException.class) - public void testTranslateInvalidEncoding_throwsException() - throws UnsupportedEncodingTypeException { - EncodingTypeTranslator.getSerializationTypeForEncodingType(BasicTypes.EncodingType.INVALID); - } - - @Test - public void testAllEncodingTypeTranslations() { - for (BasicTypes.EncodingType encodingType : BasicTypes.EncodingType.values()) { - if (!(encodingType.equals(BasicTypes.EncodingType.UNRECOGNIZED) - || encodingType.equals(BasicTypes.EncodingType.INVALID))) { - try { - EncodingTypeTranslator.getSerializationTypeForEncodingType(encodingType); - } catch (UnsupportedEncodingTypeException e) { - e.printStackTrace(); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/geode/blob/a3c66e1a/gradle/dependency-versions.properties ---------------------------------------------------------------------- diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties index 183dafc..6a730a4 100644 --- a/gradle/dependency-versions.properties +++ b/gradle/dependency-versions.properties @@ -77,6 +77,9 @@ netty-all.version = 4.1.8.Final open-json.version = 1.8 phantomjsdriver.version=1.3.0 powermock.version = 1.7.0RC4 +protobuf-gradle-plugin.version = 0.8.1 +protobuf-java.version = 3.3.1 +protoc.version = 3.0.0 selenium.version=3.0.1 shiro.version=1.3.2 slf4j-api.version = 1.7.23