This is an automated email from the ASF dual-hosted git repository.

pivotalsarge pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 3453736  GEODE-4662: Add method for retrieving size to the region 
interface. (#1557)
3453736 is described below

commit 3453736e37f8134f9987b5fdda6a7496c0144d2f
Author: Michael "Sarge" Dodge <mdo...@pivotal.io>
AuthorDate: Tue Mar 6 10:21:50 2018 -0800

    GEODE-4662: Add method for retrieving size to the region interface. (#1557)
    
    - Previously, the size (e.g., entry count) of a region
      could be retrieved as part of the region attributes.
      However, only the name of the region (which is
      already known) and the size of the region are data
      that can be affected during runtime; the remaineder
      of the fields of the region attributes were
      administrative. So region attributes has been
      elided in favor of just the size.
---
 .../geode/experimental/driver/ProtobufRegion.java  | 15 ++--
 .../apache/geode/experimental/driver/Region.java   |  6 +-
 .../experimental/driver/RegionAttributes.java      | 79 ----------------------
 .../experimental/driver/IntegrationTestBase.java   |  1 -
 .../experimental/driver/RegionIntegrationTest.java | 19 ++----
 .../src/main/proto/v1/basicTypes.proto             | 10 ---
 .../src/main/proto/v1/clientProtocol.proto         |  4 +-
 .../src/main/proto/v1/region_API.proto             |  6 +-
 ...er.java => GetSizeRequestOperationHandler.java} | 13 ++--
 .../registry/ProtobufOperationContextRegistry.java | 10 +--
 .../protobuf/v1/utilities/ProtobufUtilities.java   | 27 --------
 .../internal/protocol/protobuf/v1/MessageUtil.java | 11 ++-
 .../v1/acceptance/CacheOperationsJUnitTest.java    | 29 ++++----
 ...> GetSizeRequestOperationHandlerJUnitTest.java} | 25 +++----
 14 files changed, 54 insertions(+), 201 deletions(-)

diff --git 
a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufRegion.java
 
b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufRegion.java
index a8d53b3..a5d730a 100644
--- 
a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufRegion.java
+++ 
b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufRegion.java
@@ -15,7 +15,6 @@
 package org.apache.geode.experimental.driver;
 
 import java.io.IOException;
-import java.net.Socket;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -27,7 +26,6 @@ import 
org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
 import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol.Message;
 import 
org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol.Message.MessageTypeCase;
 import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI;
-import 
org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetRegionRequest;
 import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetRequest;
 import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.PutRequest;
 import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.RemoveRequest;
@@ -62,18 +60,14 @@ public class ProtobufRegion<K, V> implements Region<K, V> {
     this.protobufChannel = channel;
   }
 
-
   @Override
-  public RegionAttributes getRegionAttributes() throws IOException {
+  public int size() throws IOException {
     final Message request = Message.newBuilder()
-        
.setGetRegionRequest(GetRegionRequest.newBuilder().setRegionName(name)).build();
-
-    return new RegionAttributes(
-        protobufChannel.sendRequest(request, MessageTypeCase.GETREGIONRESPONSE)
-            .getGetRegionResponse().getRegion());
+        
.setGetSizeRequest(RegionAPI.GetSizeRequest.newBuilder().setRegionName(name)).build();
+    return protobufChannel.sendRequest(request, 
MessageTypeCase.GETSIZERESPONSE)
+        .getGetSizeResponse().getSize();
   }
 
-
   @Override
   public V get(K key) throws IOException {
     Message request = Message.newBuilder()
@@ -145,7 +139,6 @@ public class ProtobufRegion<K, V> implements Region<K, V> {
     }
   }
 
-
   @Override
   public void remove(K key) throws IOException {
     final Message request = Message.newBuilder()
diff --git 
a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Region.java
 
b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Region.java
index 54c7138..4c53b76 100644
--- 
a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Region.java
+++ 
b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Region.java
@@ -35,12 +35,12 @@ import org.apache.geode.annotations.Experimental;
 @Experimental
 public interface Region<K, V> {
   /**
-   * Captures a snapshot of the attributes (e.g., size) of this region.
+   * Gets the number of entries in this region.
    *
-   * @return Attributes associated with this region.
+   * @return Non-negative integer count.
    * @throws IOException
    */
-  RegionAttributes getRegionAttributes() throws IOException;
+  int size() throws IOException;
 
   /**
    * Gets the value, if any, contained in this region for the <code>key</code>.
diff --git 
a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/RegionAttributes.java
 
b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/RegionAttributes.java
deleted file mode 100644
index fea1021..0000000
--- 
a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/RegionAttributes.java
+++ /dev/null
@@ -1,79 +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.experimental.driver;
-
-import org.apache.geode.annotations.Experimental;
-import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
-
-/**
- * Encapsulates the attributes of a region in a GemFire server.
- *
- * <strong>This code is an experimental prototype and is presented "as is" 
with no warranty,
- * suitability, or fitness of purpose implied.</strong>
- */
-@Experimental
-public class RegionAttributes {
-  /**
-   * String that uniquely identifies the region within a GemFire server.
-   */
-  public String name;
-
-  /**
-   * Specifies how a local cache will handle the data for the region.
-   */
-  public String dataPolicy;
-
-  /**
-   * Whether modifications to the region are acknowledged throughout the 
GemFire distributed system.
-   */
-  public String scope;
-
-  /**
-   * String that is the fully-qualified class name of the type of which all 
keys must be instances.
-   * May be <code>null</code>.
-   */
-  public String keyConstraint;
-
-  /**
-   * String that is the fully-qualified class name of the type of which all 
values must be
-   * instances. May be <code>null</code>.
-   */
-  public String valueConstraint;
-
-  /**
-   * Whether the region is persisted to disk.
-   */
-  public boolean persisted;
-
-  /**
-   * Number of key/value pairs in the region.
-   */
-  public long size;
-
-  /**
-   * Creates an encapsulation of region attributes.
-   *
-   * @param region Protobuf encoded region attributes.
-   */
-  public RegionAttributes(BasicTypes.Region region) {
-    this.name = region.getName();
-    this.dataPolicy = region.getDataPolicy();
-    this.scope = region.getScope();
-    this.keyConstraint = region.getKeyConstraint();
-    this.valueConstraint = region.getValueConstraint();
-    this.persisted = region.getPersisted();
-    this.size = region.getSize();
-  }
-}
diff --git 
a/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/IntegrationTestBase.java
 
b/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/IntegrationTestBase.java
index 8464e8f..7b8fd01 100644
--- 
a/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/IntegrationTestBase.java
+++ 
b/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/IntegrationTestBase.java
@@ -63,7 +63,6 @@ public class IntegrationTestBase {
 
     // Create a driver connected to the server
     driver = new DriverFactory().addLocator("localhost", locatorPort).create();
-
   }
 
   @After
diff --git 
a/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/RegionIntegrationTest.java
 
b/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/RegionIntegrationTest.java
index 1b6c085..bd168ea 100644
--- 
a/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/RegionIntegrationTest.java
+++ 
b/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/RegionIntegrationTest.java
@@ -25,35 +25,30 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.Locator;
 import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class RegionIntegrationTest extends IntegrationTestBase {
-
   /** a JSON document */
   private static final String jsonDocument =
       "{" + System.lineSeparator() + "  \"name\" : \"Charlemagne\"," + 
System.lineSeparator()
           + "  \"age\" : 1276," + System.lineSeparator() + "  \"nationality\" 
: \"french\","
           + System.lineSeparator() + "  \"emailAddress\" : \"none\"" + 
System.lineSeparator() + "}";
 
+  @Test
+  public void putNewValueShouldIncrementSize() throws Exception {
+    Region<String, String> region = driver.getRegion("region");
+
+    region.put("key", "value");
+    assertEquals(1, region.size());
+  }
 
   @Test
   public void getShouldReturnPutValue() throws Exception {
diff --git a/geode-protobuf-messages/src/main/proto/v1/basicTypes.proto 
b/geode-protobuf-messages/src/main/proto/v1/basicTypes.proto
index 2b306dd..a12718b 100644
--- a/geode-protobuf-messages/src/main/proto/v1/basicTypes.proto
+++ b/geode-protobuf-messages/src/main/proto/v1/basicTypes.proto
@@ -59,16 +59,6 @@ message EncodedValue {
     }
 }
 
-message Region {
-    string name = 1;
-    string dataPolicy = 2;
-    string scope = 3;
-    string keyConstraint = 4;
-    string valueConstraint = 5;
-    bool persisted = 6;
-    int64 size = 7;
-}
-
 message Server {
     string hostname = 1;
     int32 port = 2;
diff --git a/geode-protobuf-messages/src/main/proto/v1/clientProtocol.proto 
b/geode-protobuf-messages/src/main/proto/v1/clientProtocol.proto
index 22ab5c4..ea6d99c 100644
--- a/geode-protobuf-messages/src/main/proto/v1/clientProtocol.proto
+++ b/geode-protobuf-messages/src/main/proto/v1/clientProtocol.proto
@@ -52,8 +52,8 @@ message Message {
         GetRegionNamesRequest getRegionNamesRequest = 14;
         GetRegionNamesResponse getRegionNamesResponse = 15;
 
-        GetRegionRequest getRegionRequest = 16;
-        GetRegionResponse getRegionResponse = 17;
+        GetSizeRequest getSizeRequest = 16;
+        GetSizeResponse getSizeResponse = 17;
 
         ExecuteFunctionOnRegionRequest executeFunctionOnRegionRequest = 18;
         ExecuteFunctionOnRegionResponse executeFunctionOnRegionResponse= 19;
diff --git a/geode-protobuf-messages/src/main/proto/v1/region_API.proto 
b/geode-protobuf-messages/src/main/proto/v1/region_API.proto
index 31039bf..bc385b6 100644
--- a/geode-protobuf-messages/src/main/proto/v1/region_API.proto
+++ b/geode-protobuf-messages/src/main/proto/v1/region_API.proto
@@ -77,12 +77,12 @@ message GetRegionNamesResponse {
     repeated string regions = 1;
 }
 
-message GetRegionRequest {
+message GetSizeRequest {
     string regionName = 1;
 }
 
-message GetRegionResponse {
-    Region region = 1;
+message GetSizeResponse {
+    int32 size = 1;
 }
 
 message OQLQueryRequest {
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetSizeRequestOperationHandler.java
similarity index 82%
rename from 
geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
rename to 
geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetSizeRequestOperationHandler.java
index f87500a..eed38c1 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandler.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetSizeRequestOperationHandler.java
@@ -28,16 +28,15 @@ import 
org.apache.geode.internal.protocol.protobuf.v1.ProtobufSerializationServi
 import org.apache.geode.internal.protocol.protobuf.v1.RegionAPI;
 import org.apache.geode.internal.protocol.protobuf.v1.Result;
 import org.apache.geode.internal.protocol.protobuf.v1.Success;
-import 
org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufUtilities;
 
 @Experimental
-public class GetRegionRequestOperationHandler
-    implements ProtobufOperationHandler<RegionAPI.GetRegionRequest, 
RegionAPI.GetRegionResponse> {
+public class GetSizeRequestOperationHandler
+    implements ProtobufOperationHandler<RegionAPI.GetSizeRequest, 
RegionAPI.GetSizeResponse> {
   private static final Logger logger = LogService.getLogger();
 
   @Override
-  public Result<RegionAPI.GetRegionResponse> process(
-      ProtobufSerializationService serializationService, 
RegionAPI.GetRegionRequest request,
+  public Result<RegionAPI.GetSizeResponse> process(
+      ProtobufSerializationService serializationService, 
RegionAPI.GetSizeRequest request,
       MessageExecutionContext messageExecutionContext) throws 
InvalidExecutionContextException {
     String regionName = request.getRegionName();
 
@@ -48,8 +47,6 @@ public class GetRegionRequestOperationHandler
           "No region exists for name: " + regionName);
     }
 
-    BasicTypes.Region protoRegion = 
ProtobufUtilities.createRegionMessageFromRegion(region);
-
-    return 
Success.of(RegionAPI.GetRegionResponse.newBuilder().setRegion(protoRegion).build());
+    return 
Success.of(RegionAPI.GetSizeResponse.newBuilder().setSize(region.size()).build());
   }
 }
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/registry/ProtobufOperationContextRegistry.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/registry/ProtobufOperationContextRegistry.java
index 13861d1..40c3cf8 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/registry/ProtobufOperationContextRegistry.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/registry/ProtobufOperationContextRegistry.java
@@ -29,9 +29,9 @@ import 
org.apache.geode.internal.protocol.protobuf.v1.operations.ExecuteFunction
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.ExecuteFunctionOnRegionRequestOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.GetAllRequestOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.GetRegionNamesRequestOperationHandler;
-import 
org.apache.geode.internal.protocol.protobuf.v1.operations.GetRegionRequestOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.GetRequestOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.GetServerOperationHandler;
+import 
org.apache.geode.internal.protocol.protobuf.v1.operations.GetSizeRequestOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.KeySetOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.OqlQueryRequestOperationHandler;
 import 
org.apache.geode.internal.protocol.protobuf.v1.operations.PutAllRequestOperationHandler;
@@ -116,10 +116,10 @@ public class ProtobufOperationContextRegistry {
             opsResp -> 
ClientProtocol.Message.newBuilder().setGetRegionNamesResponse(opsResp),
             ResourcePermissions.DATA_READ));
 
-    
operationContexts.put(ClientProtocol.Message.MessageTypeCase.GETREGIONREQUEST,
-        new 
ProtobufOperationContext<>(ClientProtocol.Message::getGetRegionRequest,
-            new GetRegionRequestOperationHandler(),
-            opsResp -> 
ClientProtocol.Message.newBuilder().setGetRegionResponse(opsResp),
+    
operationContexts.put(ClientProtocol.Message.MessageTypeCase.GETSIZEREQUEST,
+        new 
ProtobufOperationContext<>(ClientProtocol.Message::getGetSizeRequest,
+            new GetSizeRequestOperationHandler(),
+            opsResp -> 
ClientProtocol.Message.newBuilder().setGetSizeResponse(opsResp),
             ResourcePermissions.DATA_READ));
 
     
operationContexts.put(ClientProtocol.Message.MessageTypeCase.GETSERVERREQUEST,
diff --git 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
index 1788992..ea39ca8 100644
--- 
a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
+++ 
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/utilities/ProtobufUtilities.java
@@ -15,8 +15,6 @@
 package org.apache.geode.internal.protocol.protobuf.v1.utilities;
 
 import org.apache.geode.annotations.Experimental;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.internal.protocol.protobuf.v1.BasicTypes;
 import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
 import 
org.apache.geode.internal.protocol.protobuf.v1.ProtobufSerializationService;
@@ -79,29 +77,4 @@ public abstract class ProtobufUtilities {
       RegionAPI.GetAllRequest getAllRequest) {
     return 
ClientProtocol.Message.newBuilder().setGetAllRequest(getAllRequest).build();
   }
-
-  /**
-   * @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();
-
-    protoRegionBuilder.setName(region.getName());
-    protoRegionBuilder.setSize(region.size());
-
-    
protoRegionBuilder.setPersisted(regionAttributes.getDataPolicy().withPersistence());
-    if (regionAttributes.getKeyConstraint() != null) {
-      
protoRegionBuilder.setKeyConstraint(regionAttributes.getKeyConstraint().toString());
-    }
-    if (regionAttributes.getValueConstraint() != null) {
-      
protoRegionBuilder.setValueConstraint(regionAttributes.getValueConstraint().toString());
-    }
-
-    protoRegionBuilder.setScope(regionAttributes.getScope().toString());
-    
protoRegionBuilder.setDataPolicy(regionAttributes.getDataPolicy().toString());
-    return protoRegionBuilder.build();
-  }
-
 }
diff --git 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/MessageUtil.java
 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/MessageUtil.java
index 9e9f41d..156e9ce 100644
--- 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/MessageUtil.java
+++ 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/MessageUtil.java
@@ -29,7 +29,6 @@ import 
org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufRequestU
 import 
org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufUtilities;
 
 public class MessageUtil {
-
   public static void performAndVerifyHandshake(Socket socket) throws 
IOException {
     sendHandshake(socket);
     verifyHandshakeSuccess(socket);
@@ -48,13 +47,13 @@ public class MessageUtil {
         .writeDelimitedTo(socket.getOutputStream());
   }
 
-  public static RegionAPI.GetRegionRequest makeGetRegionRequest(String 
requestRegion) {
-    return 
RegionAPI.GetRegionRequest.newBuilder().setRegionName(requestRegion).build();
+  public static RegionAPI.GetSizeRequest makeGetSizeRequest(String 
requestRegion) {
+    return 
RegionAPI.GetSizeRequest.newBuilder().setRegionName(requestRegion).build();
   }
 
-  public static ClientProtocol.Message makeGetRegionRequestMessage(String 
requestRegion) {
-    return ClientProtocol.Message.newBuilder()
-        .setGetRegionRequest(makeGetRegionRequest(requestRegion)).build();
+  public static ClientProtocol.Message makeGetSizeRequestMessage(String 
requestRegion) {
+    return 
ClientProtocol.Message.newBuilder().setGetSizeRequest(makeGetSizeRequest(requestRegion))
+        .build();
   }
 
   public static ClientProtocol.Message createGetRequestMessage() {
diff --git 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java
 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java
index 848afff..44a45d6 100644
--- 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java
+++ 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/acceptance/CacheOperationsJUnitTest.java
@@ -50,9 +50,7 @@ import org.junit.rules.TestName;
 
 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;
@@ -78,6 +76,7 @@ import org.apache.geode.util.test.TestUtil;
 @Category(IntegrationTest.class)
 public class CacheOperationsJUnitTest {
   private final String TEST_KEY = "testKey";
+  private final String TEST_VALUE = "testValue";
   private final String TEST_REGION = "testRegion";
 
   private final String DEFAULT_STORE = "default.keystore";
@@ -250,26 +249,24 @@ public class CacheOperationsJUnitTest {
   }
 
   @Test
-  public void testNewProtocolGetRegionCall() throws Exception {
+  public void testNewProtocolGetSizeCall() throws Exception {
     System.setProperty("geode.feature-protobuf-protocol", "true");
 
     ProtobufProtocolSerializer protobufProtocolSerializer = new 
ProtobufProtocolSerializer();
-    ClientProtocol.Message getRegionMessage = 
MessageUtil.makeGetRegionRequestMessage(TEST_REGION);
+    ClientProtocol.Message putMessage = 
ProtobufRequestUtilities.createPutRequest(TEST_REGION,
+        ProtobufUtilities.createEntry(serializationService, TEST_KEY, 
TEST_VALUE));
+    protobufProtocolSerializer.serialize(putMessage, outputStream);
+    ClientProtocol.Message response = deserializeResponse(socket, 
protobufProtocolSerializer);
+    assertEquals(ClientProtocol.Message.MessageTypeCase.PUTRESPONSE, 
response.getMessageTypeCase());
+
+    ClientProtocol.Message getRegionMessage = 
MessageUtil.makeGetSizeRequestMessage(TEST_REGION);
     protobufProtocolSerializer.serialize(getRegionMessage, outputStream);
     ClientProtocol.Message message =
         protobufProtocolSerializer.deserialize(socket.getInputStream());
-    assertEquals(ClientProtocol.Message.MessageTypeCase.GETREGIONRESPONSE,
+    assertEquals(ClientProtocol.Message.MessageTypeCase.GETSIZERESPONSE,
         message.getMessageTypeCase());
-    RegionAPI.GetRegionResponse getRegionResponse = 
message.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()));
+    RegionAPI.GetSizeResponse getSizeResponse = message.getGetSizeResponse();
+    assertEquals(1, getSizeResponse.getSize());
   }
 
   private void validateGetResponse(Socket socket,
@@ -412,6 +409,4 @@ public class CacheOperationsJUnitTest {
     SocketCreator socketCreator = new SocketCreator(sslConfig);
     return socketCreator.connectForClient("localhost", cacheServerPort, 5000);
   }
-
-
 }
diff --git 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandlerJUnitTest.java
 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetSizeRequestOperationHandlerJUnitTest.java
similarity index 77%
rename from 
geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandlerJUnitTest.java
rename to 
geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetSizeRequestOperationHandlerJUnitTest.java
index 2354e68..6abde82 100644
--- 
a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetRegionRequestOperationHandlerJUnitTest.java
+++ 
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/GetSizeRequestOperationHandlerJUnitTest.java
@@ -40,16 +40,16 @@ import 
org.apache.geode.internal.protocol.protobuf.v1.Result;
 import org.apache.geode.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
-public class GetRegionRequestOperationHandlerJUnitTest extends 
OperationHandlerJUnitTest {
+public class GetSizeRequestOperationHandlerJUnitTest extends 
OperationHandlerJUnitTest {
   private final String TEST_REGION1 = "test region 1";
   private Region region1Stub;
 
   @Before
-  public void setUp() throws Exception {
+  public void setUp() {
     region1Stub = mock(Region.class);
     when(region1Stub.getName()).thenReturn(TEST_REGION1);
 
-    operationHandler = new GetRegionRequestOperationHandler();
+    operationHandler = new GetSizeRequestOperationHandler();
   }
 
   @Test
@@ -67,16 +67,9 @@ public class GetRegionRequestOperationHandlerJUnitTest 
extends OperationHandlerJ
 
 
     Result result = operationHandler.process(serializationService,
-        MessageUtil.makeGetRegionRequest(TEST_REGION1), 
getNoAuthCacheExecutionContext(cacheStub));
-    RegionAPI.GetRegionResponse response = (RegionAPI.GetRegionResponse) 
result.getMessage();
-    BasicTypes.Region region = response.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.getDataPolicy());
-    Assert.assertEquals(Integer.class.toString(), region.getValueConstraint());
-    Assert.assertEquals(true, region.getPersisted());
-    Assert.assertEquals(10, region.getSize());
+        MessageUtil.makeGetSizeRequest(TEST_REGION1), 
getNoAuthCacheExecutionContext(cacheStub));
+    RegionAPI.GetSizeResponse response = (RegionAPI.GetSizeResponse) 
result.getMessage();
+    Assert.assertEquals(10, response.getSize());
   }
 
   @Test
@@ -86,12 +79,10 @@ public class GetRegionRequestOperationHandlerJUnitTest 
extends OperationHandlerJ
         .thenReturn(Collections.unmodifiableSet(new HashSet<Region<String, 
String>>()));
     String unknownRegionName = "UNKNOWN_REGION";
     Result result = operationHandler.process(serializationService,
-        MessageUtil.makeGetRegionRequest(unknownRegionName),
+        MessageUtil.makeGetSizeRequest(unknownRegionName),
         getNoAuthCacheExecutionContext(emptyCache));
     Assert.assertTrue(result instanceof Failure);
-    ClientProtocol.ErrorResponse errorMessage =
-        (ClientProtocol.ErrorResponse) result.getErrorMessage();
+    ClientProtocol.ErrorResponse errorMessage = result.getErrorMessage();
     Assert.assertEquals(BasicTypes.ErrorCode.SERVER_ERROR, 
errorMessage.getError().getErrorCode());
   }
-
 }

-- 
To stop receiving notification emails like this one, please contact
pivotalsa...@apache.org.

Reply via email to