GEODE-3141: Amended due to review feedback. BasicTypes.Region.type renamed to dataPolicy Ran spotless Added assertions to RoundTripCacheConnectionJUnitTest.java Amended ProtobufUtilities.java to not populate key/value constraint fields if not set on Geode Region
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/66468b12 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/66468b12 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/66468b12 Branch: refs/heads/feature/GEM-1483 Commit: 66468b1296e1bca64b88a7286d6fef225de24c74 Parents: 527fc76 Author: Udo Kohlmeyer <ukohlme...@pivotal.io> Authored: Thu Jul 13 11:29:20 2017 -0700 Committer: Udo Kohlmeyer <ukohlme...@pivotal.io> Committed: Tue Jul 18 10:20:31 2017 -0700 ---------------------------------------------------------------------- .../GetRegionNamesRequestOperationHandler.java | 2 +- .../GetRegionRequestOperationHandler.java | 5 +- .../operations/GetRequestOperationHandler.java | 2 +- .../operations/PutRequestOperationHandler.java | 2 +- .../RemoveRequestOperationHandler.java | 2 +- .../utilities/ProtobufResponseUtilities.java | 4 +- .../protobuf/utilities/ProtobufUtilities.java | 27 ++++++---- geode-protobuf/src/main/proto/basicTypes.proto | 2 +- .../org/apache/geode/protocol/MessageUtil.java | 6 +-- .../RoundTripCacheConnectionJUnitTest.java | 53 ++++++++++++-------- .../GetAllRequestOperationHandlerJUnitTest.java | 10 ++-- ...onNamesRequestOperationHandlerJUnitTest.java | 16 +++--- ...tRegionRequestOperationHandlerJUnitTest.java | 14 +++--- .../GetRequestOperationHandlerJUnitTest.java | 24 ++++----- .../operations/OperationHandlerJUnitTest.java | 22 ++++---- .../PutAllRequestOperationHandlerJUnitTest.java | 2 +- .../RemoveRequestOperationHandlerJUnitTest.java | 19 +++---- 17 files changed, 113 insertions(+), 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandler.java index b48cb80..8befdd7 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandler.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandler.java @@ -27,7 +27,7 @@ public class GetRegionNamesRequestOperationHandler implements OperationHandler<ClientProtocol.Request, ClientProtocol.Response> { @Override public ClientProtocol.Response process(SerializationService serializationService, - ClientProtocol.Request request, Cache cache) { + ClientProtocol.Request request, Cache cache) { Set<Region<?, ?>> regions = cache.rootRegions(); return ProtobufResponseUtilities.createGetRegionNamesResponse(regions); } http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandler.java index 23645bb..6ac951c 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandler.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandler.java @@ -29,14 +29,15 @@ public class GetRegionRequestOperationHandler @Override public ClientProtocol.Response process(SerializationService serializationService, - ClientProtocol.Request request, Cache cache) { + ClientProtocol.Request request, Cache cache) { RegionAPI.GetRegionRequest regionRequest = request.getGetRegionRequest(); String regionName = regionRequest.getRegionName(); Region region = cache.getRegion(regionName); if (region == null) { - return ProtobufResponseUtilities.createErrorResponse("No region exists for name: "+regionName); + return ProtobufResponseUtilities + .createErrorResponse("No region exists for name: " + regionName); } BasicTypes.Region protoRegion = ProtobufUtilities.createRegionMessageFromRegion(region); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/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 950baa5..d5bcfb9 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 @@ -32,7 +32,7 @@ public class GetRequestOperationHandler @Override public ClientProtocol.Response process(SerializationService serializationService, - ClientProtocol.Request request, Cache cache) { + ClientProtocol.Request request, Cache cache) { if (request.getRequestAPICase() != ClientProtocol.Request.RequestAPICase.GETREQUEST) { return ProtobufResponseUtilities .createAndLogErrorResponse("Improperly formatted get request message.", logger, null); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/PutRequestOperationHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/PutRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/PutRequestOperationHandler.java index da8f74c..195aa7a 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/PutRequestOperationHandler.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/PutRequestOperationHandler.java @@ -32,7 +32,7 @@ public class PutRequestOperationHandler @Override public ClientProtocol.Response process(SerializationService serializationService, - ClientProtocol.Request request, Cache cache) { + ClientProtocol.Request request, Cache cache) { if (request.getRequestAPICase() != ClientProtocol.Request.RequestAPICase.PUTREQUEST) { return ProtobufResponseUtilities .createAndLogErrorResponse("Improperly formatted put request message.", logger, null); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandler.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandler.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandler.java index 16d8374..725a338 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandler.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandler.java @@ -33,7 +33,7 @@ public class RemoveRequestOperationHandler @Override public ClientProtocol.Response process(SerializationService serializationService, - ClientProtocol.Request request, Cache cache) { + ClientProtocol.Request request, Cache cache) { if (request.getRequestAPICase() != ClientProtocol.Request.RequestAPICase.REMOVEREQUEST) { return ProtobufResponseUtilities .createAndLogErrorResponse("Improperly formatted get request message.", logger, null); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufResponseUtilities.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufResponseUtilities.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufResponseUtilities.java index 4347977..5e262d0 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufResponseUtilities.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufResponseUtilities.java @@ -147,6 +147,8 @@ public abstract class ProtobufResponseUtilities { * @return A ClientProtocol.Response object indicating a successful getRegionRequest */ public static ClientProtocol.Response createGetRegionResponse(BasicTypes.Region protoRegion) { - return ClientProtocol.Response.newBuilder().setGetRegionResponse(RegionAPI.GetRegionResponse.newBuilder().setRegion(protoRegion)).build(); + return ClientProtocol.Response.newBuilder() + .setGetRegionResponse(RegionAPI.GetRegionResponse.newBuilder().setRegion(protoRegion)) + .build(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufUtilities.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufUtilities.java b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufUtilities.java index d5b4908..02afc88 100644 --- a/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufUtilities.java +++ b/geode-protobuf/src/main/java/org/apache/geode/protocol/protobuf/utilities/ProtobufUtilities.java @@ -59,7 +59,6 @@ public abstract class ProtobufUtilities { /** * Creates a protobuf key,value pair from an encoded key and value - * * @param key - an EncodedValue containing the key of the entry * @param value - an EncodedValue containing the value of the entry * @return a protobuf Entry object containing the passed key and value @@ -71,19 +70,18 @@ public abstract class ProtobufUtilities { /** * Creates a protobuf key,value pair from unencoded data - * * @param serializationService - object which knows how to encode objects for the protobuf - * protocol {@link ProtobufSerializationService} + * protocol {@link ProtobufSerializationService} * @param unencodedKey - the unencoded key for the entry * @param unencodedValue - the unencoded value for the entry * @return a protobuf Entry containing the encoded key and value * @throws UnsupportedEncodingTypeException - The key or value passed doesn't have a corresponding - * SerializationType + * SerializationType * @throws CodecNotRegisteredForTypeException - There isn't a protobuf codec for the - * SerializationType of the passed key or value + * SerializationType of the passed key or value */ public static BasicTypes.Entry createEntry(SerializationService serializationService, - Object unencodedKey, Object unencodedValue) + Object unencodedKey, Object unencodedValue) throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { return createEntry(createEncodedValue(serializationService, unencodedKey), createEncodedValue(serializationService, unencodedValue)); @@ -151,6 +149,11 @@ public abstract class ProtobufUtilities { return serializationService.decode(encoding, bytes); } + /** + * + * @param region + * @return a Protobuf BasicTypes.Region message that represents the {@link Region} + */ public static BasicTypes.Region createRegionMessageFromRegion(Region region) { RegionAttributes regionAttributes = region.getAttributes(); BasicTypes.Region.Builder protoRegionBuilder = BasicTypes.Region.newBuilder(); @@ -159,13 +162,15 @@ public abstract class ProtobufUtilities { protoRegionBuilder.setSize(region.size()); protoRegionBuilder.setPersisted(regionAttributes.getDataPolicy().withPersistence()); - protoRegionBuilder.setKeyConstraint(regionAttributes.getKeyConstraint() == null ? "" - : regionAttributes.getKeyConstraint().toString()); - protoRegionBuilder.setValueConstraint(regionAttributes.getValueConstraint() == null ? "" - : regionAttributes.getValueConstraint().toString()); + if (regionAttributes.getKeyConstraint() != null) { + protoRegionBuilder.setKeyConstraint(regionAttributes.getKeyConstraint().toString()); + } + if (regionAttributes.getValueConstraint() != null) { + protoRegionBuilder.setValueConstraint(regionAttributes.getValueConstraint().toString()); + } protoRegionBuilder.setScope(regionAttributes.getScope().toString()); - protoRegionBuilder.setType(regionAttributes.getDataPolicy().toString()); + protoRegionBuilder.setDataPolicy(regionAttributes.getDataPolicy().toString()); return protoRegionBuilder.build(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/main/proto/basicTypes.proto ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/main/proto/basicTypes.proto b/geode-protobuf/src/main/proto/basicTypes.proto index 987c2ed..d45d61b 100644 --- a/geode-protobuf/src/main/proto/basicTypes.proto +++ b/geode-protobuf/src/main/proto/basicTypes.proto @@ -52,7 +52,7 @@ message CallbackArguments { message Region { string name = 1; - string type = 2; + string dataPolicy = 2; string scope = 3; string keyConstraint = 4; string valueConstraint = 5; http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/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 index 20216ad..b650f3b 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/MessageUtil.java @@ -29,9 +29,9 @@ public class MessageUtil { } public static ClientProtocol.Message makeGetRegionRequestMessage(String requestRegion, - ClientProtocol.MessageHeader header) { - ClientProtocol.Request request = - ClientProtocol.Request.newBuilder().setGetRegionRequest(makeGetRegionRequest(requestRegion)).build(); + ClientProtocol.MessageHeader header) { + ClientProtocol.Request request = ClientProtocol.Request.newBuilder() + .setGetRegionRequest(makeGetRegionRequest(requestRegion)).build(); return ClientProtocol.Message.newBuilder().setMessageHeader(header).setRequest(request).build(); } http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java index b240552..07cde79 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/RoundTripCacheConnectionJUnitTest.java @@ -17,7 +17,9 @@ package org.apache.geode.protocol; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.RegionFactory; +import org.apache.geode.cache.Scope; import org.apache.geode.cache.server.CacheServer; import org.apache.geode.distributed.ConfigurationProperties; import org.apache.geode.internal.AvailablePortHelper; @@ -73,23 +75,23 @@ import static org.junit.Assert.assertFalse; */ @Category(IntegrationTest.class) public class RoundTripCacheConnectionJUnitTest { - public static final String TEST_KEY = "testKey"; - public static final String TEST_VALUE = "testValue"; - public static final String TEST_REGION = "testRegion"; - public static final int TEST_PUT_CORRELATION_ID = 574; - public static final int TEST_GET_CORRELATION_ID = 68451; - public static final int TEST_REMOVE_CORRELATION_ID = 51; - - private static final String DEFAULT_STORE = "default.keystore"; - private static final String SSL_PROTOCOLS = "any"; - private static final String SSL_CIPHERS = "any"; - - public static final String TEST_MULTIOP_KEY1 = "multiopKey1"; - public static final String TEST_MULTIOP_KEY2 = "multiopKey2"; - public static final String TEST_MULTIOP_KEY3 = "multiopKey3"; - public static final String TEST_MULTIOP_VALUE1 = "multiopValue1"; - public static final String TEST_MULTIOP_VALUE2 = "multiopValue2"; - public static final String TEST_MULTIOP_VALUE3 = "multiopValue3"; + private final String TEST_KEY = "testKey"; + private final String TEST_VALUE = "testValue"; + private final String TEST_REGION = "testRegion"; + private final int TEST_PUT_CORRELATION_ID = 574; + private final int TEST_GET_CORRELATION_ID = 68451; + private final int TEST_REMOVE_CORRELATION_ID = 51; + + private final String DEFAULT_STORE = "default.keystore"; + private final String SSL_PROTOCOLS = "any"; + private final String SSL_CIPHERS = "any"; + + private final String TEST_MULTIOP_KEY1 = "multiopKey1"; + private final String TEST_MULTIOP_KEY2 = "multiopKey2"; + private final String TEST_MULTIOP_KEY3 = "multiopKey3"; + private final String TEST_MULTIOP_VALUE1 = "multiopValue1"; + private final String TEST_MULTIOP_VALUE2 = "multiopValue2"; + private final String TEST_MULTIOP_VALUE3 = "multiopValue3"; private Cache cache; private int cacheServerPort; @@ -289,8 +291,8 @@ public class RoundTripCacheConnectionJUnitTest { ProtobufProtocolSerializer protobufProtocolSerializer = new ProtobufProtocolSerializer(); - ClientProtocol.Message getRegionMessage = - MessageUtil.makeGetRegionRequestMessage(TEST_REGION, ClientProtocol.MessageHeader.newBuilder().build()); + ClientProtocol.Message getRegionMessage = MessageUtil.makeGetRegionRequestMessage(TEST_REGION, + ClientProtocol.MessageHeader.newBuilder().build()); protobufProtocolSerializer.serialize(getRegionMessage, outputStream); ClientProtocol.Message message = @@ -299,8 +301,17 @@ public class RoundTripCacheConnectionJUnitTest { ClientProtocol.Response response = message.getResponse(); assertEquals(ClientProtocol.Response.ResponseAPICase.GETREGIONRESPONSE, response.getResponseAPICase()); - response.getGetRegionResponse(); - //TODO add some assertions for Region data + RegionAPI.GetRegionResponse getRegionResponse = response.getGetRegionResponse(); + BasicTypes.Region region = getRegionResponse.getRegion(); + + assertEquals(TEST_REGION, region.getName()); + assertEquals(0, region.getSize()); + assertEquals(false, region.getPersisted()); + assertEquals(DataPolicy.NORMAL.toString(), region.getDataPolicy()); + assertEquals("", region.getKeyConstraint()); + assertEquals("", region.getValueConstraint()); + assertEquals(Scope.DISTRIBUTED_NO_ACK, Scope.fromString(region.getScope())); + } private void validatePutResponse(Socket socket, http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java index c745ffc..e1c5972 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetAllRequestOperationHandlerJUnitTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @Category(UnitTest.class) -public class GetAllRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTest{ +public class GetAllRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTest { private static final String TEST_KEY1 = "my key1"; private static final String TEST_VALUE1 = "my value1"; private static final String TEST_KEY2 = "my key2"; @@ -96,8 +96,8 @@ public class GetAllRequestOperationHandlerJUnitTest extends OperationHandlerJUni throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request getRequest = generateTestRequest(true); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler.process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETALLRESPONSE, response.getResponseAPICase()); @@ -116,8 +116,8 @@ public class GetAllRequestOperationHandlerJUnitTest extends OperationHandlerJUni public void processReturnsNoEntriesForNoKeysRequested() throws UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request getRequest = generateTestRequest(false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler.process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETALLRESPONSE, response.getResponseAPICase()); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandlerJUnitTest.java index 9798522..2d9cc72 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionNamesRequestOperationHandlerJUnitTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @Category(UnitTest.class) -public class GetRegionNamesRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTest{ +public class GetRegionNamesRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTest { private final String TEST_REGION1 = "test region 1"; private final String TEST_REGION2 = "test region 2"; private final String TEST_REGION3 = "test region 3"; @@ -62,16 +62,17 @@ public class GetRegionNamesRequestOperationHandlerJUnitTest extends OperationHan Region<String, String> region3Stub = mock(Region.class); when(region3Stub.getName()).thenReturn(TEST_REGION3); - when(cacheStub.rootRegions()).thenReturn(Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(region1Stub, region2Stub, region3Stub)))); + when(cacheStub.rootRegions()).thenReturn(Collections + .unmodifiableSet(new HashSet<>(Arrays.asList(region1Stub, region2Stub, region3Stub)))); operationHandler = new GetRegionNamesRequestOperationHandler(); } @Test public void processReturnsCacheRegions() throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { - ClientProtocol.Response response = (ClientProtocol.Response) operationHandler.process(serializationServiceStub, - ProtobufRequestUtilities.createGetRegionNamesRequest(), cacheStub); + ClientProtocol.Response response = + (ClientProtocol.Response) operationHandler.process(serializationServiceStub, + ProtobufRequestUtilities.createGetRegionNamesRequest(), cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETREGIONNAMESRESPONSE, response.getResponseAPICase()); @@ -95,8 +96,9 @@ public class GetRegionNamesRequestOperationHandlerJUnitTest extends OperationHan Cache emptyCache = mock(Cache.class);; when(emptyCache.rootRegions()) .thenReturn(Collections.unmodifiableSet(new HashSet<Region<String, String>>())); - ClientProtocol.Response response = (ClientProtocol.Response) operationHandler.process(serializationServiceStub, - ProtobufRequestUtilities.createGetRegionNamesRequest(), emptyCache); + ClientProtocol.Response response = + (ClientProtocol.Response) operationHandler.process(serializationServiceStub, + ProtobufRequestUtilities.createGetRegionNamesRequest(), emptyCache); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETREGIONNAMESRESPONSE, response.getResponseAPICase()); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandlerJUnitTest.java index ec9d50b..24e1215 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRegionRequestOperationHandlerJUnitTest.java @@ -73,13 +73,13 @@ public class GetRegionRequestOperationHandlerJUnitTest extends OperationHandlerJ when(regionAttributesStub.getScope()).thenReturn(Scope.DISTRIBUTED_ACK); ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler.process(serializationServiceStub, createRequestMessage( - MessageUtil.makeGetRegionRequest(TEST_REGION1)), cacheStub); + (ClientProtocol.Response) operationHandler.process(serializationServiceStub, + createRequestMessage(MessageUtil.makeGetRegionRequest(TEST_REGION1)), cacheStub); BasicTypes.Region region = response.getGetRegionResponse().getRegion(); Assert.assertEquals(TEST_REGION1, region.getName()); Assert.assertEquals(String.class.toString(), region.getKeyConstraint()); Assert.assertEquals(Scope.DISTRIBUTED_ACK.toString(), region.getScope()); - Assert.assertEquals(DataPolicy.PERSISTENT_REPLICATE.toString(), region.getType()); + Assert.assertEquals(DataPolicy.PERSISTENT_REPLICATE.toString(), region.getDataPolicy()); Assert.assertEquals(Integer.class.toString(), region.getValueConstraint()); Assert.assertEquals(true, region.getPersisted()); Assert.assertEquals(10, region.getSize()); @@ -96,11 +96,13 @@ public class GetRegionRequestOperationHandlerJUnitTest extends OperationHandlerJ when(emptyCache.rootRegions()) .thenReturn(Collections.unmodifiableSet(new HashSet<Region<String, String>>())); String unknownRegionName = "UNKNOWN_REGION"; - ClientProtocol.Response response = (ClientProtocol.Response) operationHandler.process(serializationServiceStub, - createRequestMessage(MessageUtil.makeGetRegionRequest(unknownRegionName)), emptyCache); + ClientProtocol.Response response = + (ClientProtocol.Response) operationHandler.process(serializationServiceStub, + createRequestMessage(MessageUtil.makeGetRegionRequest(unknownRegionName)), emptyCache); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.ERRORRESPONSE.getNumber(), response.getResponseAPICase().getNumber()); - Assert.assertEquals("No region exists for name: " + unknownRegionName,response.getErrorResponse().getMessage()); + Assert.assertEquals("No region exists for name: " + unknownRegionName, + response.getErrorResponse().getMessage()); } } http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java index a3d9d91..2d3fbb6 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/GetRequestOperationHandlerJUnitTest.java @@ -84,9 +84,8 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request getRequest = generateTestRequest(false, false, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETRESPONSE, response.getResponseAPICase()); @@ -101,9 +100,8 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request getRequest = generateTestRequest(true, false, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.ERRORRESPONSE, response.getResponseAPICase()); @@ -114,8 +112,8 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request getRequest = generateTestRequest(false, true, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler.process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETRESPONSE, response.getResponseAPICase()); @@ -128,9 +126,8 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request getRequest = generateTestRequest(false, false, true); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.GETRESPONSE, response.getResponseAPICase()); @@ -148,9 +145,8 @@ public class GetRequestOperationHandlerJUnitTest extends OperationHandlerJUnitTe TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenThrow(exception); ClientProtocol.Request getRequest = generateTestRequest(false, false, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, getRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, getRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.ERRORRESPONSE, response.getResponseAPICase()); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/OperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/OperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/OperationHandlerJUnitTest.java index 2ff2d13..c739db9 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/OperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/OperationHandlerJUnitTest.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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; http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/PutAllRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/PutAllRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/PutAllRequestOperationHandlerJUnitTest.java index bd56af6..ac13bdc 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/PutAllRequestOperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/PutAllRequestOperationHandlerJUnitTest.java @@ -83,7 +83,7 @@ public class PutAllRequestOperationHandlerJUnitTest extends OperationHandlerJUni .thenReturn(ByteBuffer.allocate(Integer.BYTES).putInt(TEST_INVALID_VALUE).array()); when(serializationServiceStub.decode(BasicTypes.EncodingType.INT, ByteBuffer.allocate(Integer.BYTES).putInt(TEST_INVALID_VALUE).array())) - .thenReturn(TEST_INVALID_VALUE); + .thenReturn(TEST_INVALID_VALUE); regionMock = mock(Region.class); http://git-wip-us.apache.org/repos/asf/geode/blob/66468b12/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java index 5c5c6dd..47f9bad 100644 --- a/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java +++ b/geode-protobuf/src/test/java/org/apache/geode/protocol/protobuf/operations/RemoveRequestOperationHandlerJUnitTest.java @@ -76,9 +76,8 @@ public class RemoveRequestOperationHandlerJUnitTest extends OperationHandlerJUni throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request removeRequest = generateTestRequest(false, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, removeRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, removeRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.REMOVERESPONSE, response.getResponseAPICase()); @@ -91,9 +90,8 @@ public class RemoveRequestOperationHandlerJUnitTest extends OperationHandlerJUni throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request removeRequest = generateTestRequest(true, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, removeRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, removeRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.ERRORRESPONSE, response.getResponseAPICase()); @@ -104,9 +102,8 @@ public class RemoveRequestOperationHandlerJUnitTest extends OperationHandlerJUni throws CodecAlreadyRegisteredForTypeException, UnsupportedEncodingTypeException, CodecNotRegisteredForTypeException { ClientProtocol.Request removeRequest = generateTestRequest(false, true); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler - .process(serializationServiceStub, removeRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, removeRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.REMOVERESPONSE, response.getResponseAPICase()); @@ -123,8 +120,8 @@ public class RemoveRequestOperationHandlerJUnitTest extends OperationHandlerJUni TEST_KEY.getBytes(Charset.forName("UTF-8")))).thenThrow(exception); ClientProtocol.Request removeRequest = generateTestRequest(false, false); - ClientProtocol.Response response = - (ClientProtocol.Response) operationHandler.process(serializationServiceStub, removeRequest, cacheStub); + ClientProtocol.Response response = (ClientProtocol.Response) operationHandler + .process(serializationServiceStub, removeRequest, cacheStub); Assert.assertEquals(ClientProtocol.Response.ResponseAPICase.ERRORRESPONSE, response.getResponseAPICase());