geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gosulli...@apache.org
Subject [geode] branch develop updated: GEODE-4084 rename handshake.proto (#1155)
Date Fri, 15 Dec 2017 18:39:22 GMT
This is an automated email from the ASF dual-hosted git repository.

gosullivan 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 9ca4314  GEODE-4084 rename handshake.proto (#1155)
9ca4314 is described below

commit 9ca4314b242568251115283d79ed59a22a578422
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
AuthorDate: Fri Dec 15 10:39:19 2017 -0800

    GEODE-4084 rename handshake.proto (#1155)
    
    renamed to protocolVersion
---
 .../{handshake.proto => protocolVersion.proto}     |   6 +-
 .../protobuf/v1/ProtobufLocatorPipeline.java       |   6 +-
 .../protobuf/v1/ProtobufProtocolService.java       |   4 +-
 ...akeHandler.java => ProtocolVersionHandler.java} |  29 ++---
 .../protobuf/v1/operations/VersionValidator.java   |  10 +-
 .../ProtobufConnectionHandshakeStateProcessor.java |   4 +-
 .../internal/protocol/protobuf/v1/MessageUtil.java |  14 +--
 ...st.java => ProtocolVersionIntegrationTest.java} |  24 ++--
 .../v1/operations/HandshakeHandlerJUnitTest.java   | 140 ---------------------
 .../ProtocolVersionHandlerJUnitTest.java           | 126 +++++++++++++++++++
 .../v1/operations/VersionValidatorJUnitTest.java   |  14 +--
 11 files changed, 180 insertions(+), 197 deletions(-)

diff --git a/geode-protobuf-messages/src/main/proto/handshake.proto b/geode-protobuf-messages/src/main/proto/protocolVersion.proto
similarity index 93%
rename from geode-protobuf-messages/src/main/proto/handshake.proto
rename to geode-protobuf-messages/src/main/proto/protocolVersion.proto
index b3eebf6..11edf8c 100644
--- a/geode-protobuf-messages/src/main/proto/handshake.proto
+++ b/geode-protobuf-messages/src/main/proto/protocolVersion.proto
@@ -25,13 +25,13 @@ enum MinorVersions {
     CURRENT_MINOR_VERSION = 1;  // Protobuf implementation at initial release
 }
 
-message NewConnectionHandshake {
+message NewConnectionClientVersion {
     fixed32 majorVersion = 1;
     fixed32 minorVersion = 2;
 }
 
-message HandshakeAcknowledgement {
+message VersionAcknowledgement {
     int32 serverMajorVersion = 1;
     int32 serverMinorVersion = 2;
-    bool handshakePassed = 3;
+    bool versionAccepted = 3;
 }
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufLocatorPipeline.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufLocatorPipeline.java
index 0a30ae4..58e8816 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufLocatorPipeline.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufLocatorPipeline.java
@@ -26,7 +26,7 @@ import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.cache.client.protocol.ClientProtocolProcessor;
 import org.apache.geode.internal.cache.tier.CommunicationMode;
 import org.apache.geode.internal.protocol.MessageExecutionContext;
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.internal.protocol.protobuf.v1.operations.VersionValidator;
 import org.apache.geode.internal.protocol.state.ConnectionStateProcessor;
 import org.apache.geode.internal.protocol.state.NoSecurityConnectionStateProcessor;
@@ -75,8 +75,8 @@ public final class ProtobufLocatorPipeline implements ClientProtocolProcessor
{
     PushbackInputStream handshakeStream = new PushbackInputStream(inputStream);
     handshakeStream.unread(CommunicationMode.ProtobufClientServerProtocol.getModeNumber());
 
-    Handshake.NewConnectionHandshake handshakeRequest =
-        Handshake.NewConnectionHandshake.parseDelimitedFrom(handshakeStream);
+    ProtocolVersion.NewConnectionClientVersion handshakeRequest =
+        ProtocolVersion.NewConnectionClientVersion.parseDelimitedFrom(handshakeStream);
     int majorVersion = handshakeRequest.getMajorVersion();
     int minorVersion = handshakeRequest.getMinorVersion();
     if (!validator.isValid(majorVersion, minorVersion)) {
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufProtocolService.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufProtocolService.java
index 23fc804..1794a5e 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufProtocolService.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/ProtobufProtocolService.java
@@ -19,7 +19,7 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.cache.client.protocol.ClientProtocolProcessor;
 import org.apache.geode.internal.cache.client.protocol.ClientProtocolService;
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.internal.protocol.protobuf.statistics.ProtobufClientStatisticsImpl;
 import org.apache.geode.internal.protocol.statistics.NoOpStatistics;
 import org.apache.geode.internal.protocol.statistics.ProtocolClientStatistics;
@@ -63,6 +63,6 @@ public class ProtobufProtocolService implements ClientProtocolService {
 
   @Override
   public int getServiceProtocolVersion() {
-    return Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE;
+    return ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE;
   }
 }
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/HandshakeHandler.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
similarity index 60%
rename from geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/HandshakeHandler.java
rename to geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
index 0132196..85df7cc 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/HandshakeHandler.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandler.java
@@ -21,34 +21,35 @@ import java.io.OutputStream;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.internal.protocol.statistics.ProtocolClientStatistics;
 
-public class HandshakeHandler {
+public class ProtocolVersionHandler {
   private static final Logger logger = LogManager.getLogger();
   private static final VersionValidator validator = new VersionValidator();
 
-  public static boolean handleHandshake(InputStream inputStream, OutputStream outputStream,
+  public static boolean handleVersionMessage(InputStream inputStream, OutputStream outputStream,
       ProtocolClientStatistics statistics) throws IOException {
-    Handshake.NewConnectionHandshake handshakeRequest =
-        Handshake.NewConnectionHandshake.parseDelimitedFrom(inputStream);
+    ProtocolVersion.NewConnectionClientVersion versionMessage =
+        ProtocolVersion.NewConnectionClientVersion.parseDelimitedFrom(inputStream);
 
-    statistics.messageReceived(handshakeRequest.getSerializedSize());
+    statistics.messageReceived(versionMessage.getSerializedSize());
 
-    final boolean handshakeSucceeded =
-        validator.isValid(handshakeRequest.getMajorVersion(), handshakeRequest.getMinorVersion());
+    final boolean versionAccepted =
+        validator.isValid(versionMessage.getMajorVersion(), versionMessage.getMinorVersion());
 
-    Handshake.HandshakeAcknowledgement handshakeResponse = Handshake.HandshakeAcknowledgement
-        .newBuilder().setServerMajorVersion(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE)
-        .setServerMinorVersion(Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE)
-        .setHandshakePassed(handshakeSucceeded).build();
+    ProtocolVersion.VersionAcknowledgement handshakeResponse =
+        ProtocolVersion.VersionAcknowledgement.newBuilder()
+            .setServerMajorVersion(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE)
+            .setServerMinorVersion(ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE)
+            .setVersionAccepted(versionAccepted).build();
 
     handshakeResponse.writeDelimitedTo(outputStream);
     statistics.messageSent(handshakeResponse.getSerializedSize());
-    if (!handshakeSucceeded) {
+    if (!versionAccepted) {
       throw new IOException("Incompatible protobuf version.");
     }
 
-    return handshakeSucceeded;
+    return versionAccepted;
   }
 }
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidator.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidator.java
index 9d6065b..5c6e0ae 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidator.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidator.java
@@ -14,15 +14,15 @@
  */
 package org.apache.geode.internal.protocol.protobuf.v1.operations;
 
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 
 public class VersionValidator {
   private int majorVersion;
   private int minorVersion;
 
   public VersionValidator() {
-    this(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
-        Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
+    this(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
+        ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
   }
 
   VersionValidator(int majorVersion, int minorVersion) {
@@ -31,9 +31,9 @@ public class VersionValidator {
   }
 
   public boolean isValid(int majorVersion, int minorVersion) {
-    if (majorVersion != Handshake.MajorVersions.INVALID_MAJOR_VERSION_VALUE
+    if (majorVersion != ProtocolVersion.MajorVersions.INVALID_MAJOR_VERSION_VALUE
         && majorVersion == this.majorVersion) {
-      if (minorVersion != Handshake.MinorVersions.INVALID_MINOR_VERSION_VALUE
+      if (minorVersion != ProtocolVersion.MinorVersions.INVALID_MINOR_VERSION_VALUE
           && minorVersion <= this.minorVersion) {
         return true;
       }
diff --git a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
index ec39ec9..b25df72 100644
--- a/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
+++ b/geode-protobuf/src/main/java/org/apache/geode/internal/protocol/protobuf/v1/state/ProtobufConnectionHandshakeStateProcessor.java
@@ -23,7 +23,7 @@ import org.apache.geode.internal.cache.tier.CommunicationMode;
 import org.apache.geode.internal.protocol.MessageExecutionContext;
 import org.apache.geode.internal.protocol.OperationContext;
 import org.apache.geode.internal.protocol.ProtocolErrorCode;
-import org.apache.geode.internal.protocol.protobuf.v1.operations.HandshakeHandler;
+import org.apache.geode.internal.protocol.protobuf.v1.operations.ProtocolVersionHandler;
 import org.apache.geode.internal.protocol.state.ConnectionStateProcessor;
 import org.apache.geode.internal.protocol.state.LegacySecurityConnectionStateProcessor;
 import org.apache.geode.internal.protocol.state.NoSecurityConnectionStateProcessor;
@@ -64,7 +64,7 @@ public class ProtobufConnectionHandshakeStateProcessor implements ConnectionStat
     PushbackInputStream messageStream = new PushbackInputStream(inputStream);
     messageStream.unread(CommunicationMode.ProtobufClientServerProtocol.getModeNumber());
 
-    if (HandshakeHandler.handleHandshake(messageStream, outputStream,
+    if (ProtocolVersionHandler.handleVersionMessage(messageStream, outputStream,
         executionContext.getStatistics())) {
       executionContext.setConnectionStateProcessor(nextConnectionState());
     }
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 c998f4a..56ecdbb 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
@@ -23,7 +23,7 @@ import java.net.Socket;
 
 import com.google.protobuf.MessageLite;
 
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufRequestUtilities;
 import org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufUtilities;
 import org.apache.geode.internal.protocol.serialization.SerializationService;
@@ -38,15 +38,15 @@ public class MessageUtil {
   }
 
   public static void verifyHandshakeSuccess(Socket socket) throws IOException {
-    Handshake.HandshakeAcknowledgement handshakeResponse =
-        Handshake.HandshakeAcknowledgement.parseDelimitedFrom(socket.getInputStream());
-    assertTrue(handshakeResponse.getHandshakePassed());
+    ProtocolVersion.VersionAcknowledgement handshakeResponse =
+        ProtocolVersion.VersionAcknowledgement.parseDelimitedFrom(socket.getInputStream());
+    assertTrue(handshakeResponse.getVersionAccepted());
   }
 
   public static void sendHandshake(Socket socket) throws IOException {
-    Handshake.NewConnectionHandshake.newBuilder()
-        .setMajorVersion(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE)
-        .setMinorVersion(Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE).build()
+    ProtocolVersion.NewConnectionClientVersion.newBuilder()
+        .setMajorVersion(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE)
+        .setMinorVersion(ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE).build()
         .writeDelimitedTo(socket.getOutputStream());
   }
 
diff --git a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/HandshakeIntegrationTest.java
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/ProtocolVersionIntegrationTest.java
similarity index 84%
rename from geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/HandshakeIntegrationTest.java
rename to geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/ProtocolVersionIntegrationTest.java
index 0d3fd24..33f39ca 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/HandshakeIntegrationTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/ProtocolVersionIntegrationTest.java
@@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -41,15 +40,12 @@ import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.CacheServerImpl;
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.tier.CommunicationMode;
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.internal.protocol.protobuf.v1.serializer.ProtobufProtocolSerializer;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
-public class HandshakeIntegrationTest {
+public class ProtocolVersionIntegrationTest {
   private Cache cache;
 
   @Rule
@@ -104,13 +100,13 @@ public class HandshakeIntegrationTest {
 
   @Test
   public void testInvalidMajorVersionBreaksConnection() throws Exception {
-    Handshake.NewConnectionHandshake.newBuilder().setMajorVersion(2000)
-        .setMinorVersion(Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE).build()
+    ProtocolVersion.NewConnectionClientVersion.newBuilder().setMajorVersion(2000)
+        .setMinorVersion(ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE).build()
         .writeDelimitedTo(socket.getOutputStream());
 
-    Handshake.HandshakeAcknowledgement handshakeResponse =
-        Handshake.HandshakeAcknowledgement.parseDelimitedFrom(socket.getInputStream());
-    assertFalse(handshakeResponse.getHandshakePassed());
+    ProtocolVersion.VersionAcknowledgement handshakeResponse =
+        ProtocolVersion.VersionAcknowledgement.parseDelimitedFrom(socket.getInputStream());
+    assertFalse(handshakeResponse.getVersionAccepted());
 
     // Verify that connection is closed
     Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
@@ -129,9 +125,9 @@ public class HandshakeIntegrationTest {
    */
   @Test
   public void testMissingMajorVersionBreaksConnection() throws Exception {
-    Handshake.NewConnectionHandshake.newBuilder()
-        .setMajorVersion(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE).setMinorVersion(0)
-        .build().writeDelimitedTo(socket.getOutputStream());
+    ProtocolVersion.NewConnectionClientVersion.newBuilder()
+        .setMajorVersion(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE)
+        .setMinorVersion(0).build().writeDelimitedTo(socket.getOutputStream());
 
     // Verify that connection is closed
     Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
diff --git a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/HandshakeHandlerJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/HandshakeHandlerJUnitTest.java
deleted file mode 100644
index 098b1a2..0000000
--- a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/HandshakeHandlerJUnitTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.apache.geode.internal.protocol.protobuf.v1.operations;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.shiro.subject.Subject;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.exception.InvalidExecutionContextException;
-import org.apache.geode.internal.protocol.MessageExecutionContext;
-import org.apache.geode.internal.protocol.ProtocolErrorCode;
-import org.apache.geode.internal.protocol.Result;
-import org.apache.geode.internal.protocol.protobuf.Handshake;
-import org.apache.geode.internal.protocol.protobuf.v1.ClientProtocol;
-import org.apache.geode.internal.protocol.protobuf.v1.ConnectionAPI;
-import org.apache.geode.internal.protocol.protobuf.v1.MessageUtil;
-import org.apache.geode.internal.protocol.protobuf.v1.ProtobufSerializationService;
-import org.apache.geode.internal.protocol.protobuf.v1.state.ConnectionShiroAuthenticatingStateProcessor;
-import org.apache.geode.internal.protocol.protobuf.v1.state.ProtobufConnectionHandshakeStateProcessor;
-import org.apache.geode.internal.protocol.protobuf.v1.utilities.ProtobufUtilities;
-import org.apache.geode.internal.protocol.serialization.SerializationService;
-import org.apache.geode.internal.protocol.state.ConnectionShiroAuthorizingStateProcessor;
-import org.apache.geode.internal.protocol.state.NoSecurityConnectionStateProcessor;
-import org.apache.geode.internal.protocol.statistics.ProtocolClientStatistics;
-import org.apache.geode.internal.security.SecurityService;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-/*
- * 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.
- */
-
-@Category(UnitTest.class)
-public class HandshakeHandlerJUnitTest {
-  private static final int INVALID_MAJOR_VERSION = 67;
-  private static final int INVALID_MINOR_VERSION = 92347;
-
-  private HandshakeHandler handshakeHandler = new HandshakeHandler();
-
-  @Test
-  public void testCurrentVersionHandshakeSucceeds() throws Exception {
-    Handshake.NewConnectionHandshake handshakeRequest =
-        generateHandshakeRequest(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
-            Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
-
-    ByteArrayInputStream inputStream =
-        MessageUtil.writeMessageDelimitedToInputStream(handshakeRequest);
-
-    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-    assertTrue(handshakeHandler.handleHandshake(inputStream, outputStream,
-        mock(ProtocolClientStatistics.class)));
-
-    Handshake.HandshakeAcknowledgement handshakeResponse = Handshake.HandshakeAcknowledgement
-        .parseDelimitedFrom(new ByteArrayInputStream(outputStream.toByteArray()));
-    assertTrue(handshakeResponse.getHandshakePassed());
-    assertEquals(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
-        handshakeResponse.getServerMajorVersion());
-    assertEquals(Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE,
-        handshakeResponse.getServerMinorVersion());
-  }
-
-  @Test
-  public void testInvalidMajorVersionFails() throws Exception {
-    assertNotEquals(INVALID_MAJOR_VERSION, Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE);
-
-    Handshake.NewConnectionHandshake handshakeRequest = generateHandshakeRequest(
-        INVALID_MAJOR_VERSION, Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
-
-    verifyHandshakeFails(handshakeRequest);
-
-    // Also validate the protobuf INVALID_MAJOR_VERSION_VALUE constant fails
-    handshakeRequest = generateHandshakeRequest(Handshake.MajorVersions.INVALID_MAJOR_VERSION_VALUE,
-        Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
-    verifyHandshakeFails(handshakeRequest);
-  }
-
-  private void verifyHandshakeFails(Handshake.NewConnectionHandshake handshakeRequest)
-      throws Exception {
-    ByteArrayInputStream inputStream =
-        MessageUtil.writeMessageDelimitedToInputStream(handshakeRequest);
-
-    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-
-    try {
-      handshakeHandler.handleHandshake(inputStream, outputStream,
-          mock(ProtocolClientStatistics.class));
-      fail("Invalid handshake should throw IOException");
-    } catch (IOException e) {
-      // expected if handshake verification fails
-    }
-
-    Handshake.HandshakeAcknowledgement handshakeResponse = Handshake.HandshakeAcknowledgement
-        .parseDelimitedFrom(new ByteArrayInputStream(outputStream.toByteArray()));
-
-    assertFalse(handshakeResponse.getHandshakePassed());
-  }
-
-  @Test
-  public void testInvalidMinorVersionFails() throws Exception {
-    assertNotEquals(INVALID_MINOR_VERSION, Handshake.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
-
-    Handshake.NewConnectionHandshake handshakeRequest = generateHandshakeRequest(
-        Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE, INVALID_MINOR_VERSION);
-
-    verifyHandshakeFails(handshakeRequest);
-
-    // Also validate the protobuf INVALID_MINOR_VERSION_VALUE constant fails
-    handshakeRequest = generateHandshakeRequest(Handshake.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
-        Handshake.MinorVersions.INVALID_MINOR_VERSION_VALUE);
-    verifyHandshakeFails(handshakeRequest);
-  }
-
-  private Handshake.NewConnectionHandshake generateHandshakeRequest(int majorVersion,
-      int minorVersion) {
-    return Handshake.NewConnectionHandshake.newBuilder().setMajorVersion(majorVersion)
-        .setMinorVersion(minorVersion).build();
-  }
-}
diff --git a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandlerJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandlerJUnitTest.java
new file mode 100644
index 0000000..cf60f38
--- /dev/null
+++ b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/ProtocolVersionHandlerJUnitTest.java
@@ -0,0 +1,126 @@
+package org.apache.geode.internal.protocol.protobuf.v1.operations;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
+import org.apache.geode.internal.protocol.protobuf.v1.MessageUtil;
+import org.apache.geode.internal.protocol.statistics.ProtocolClientStatistics;
+import org.apache.geode.test.junit.categories.UnitTest;
+
+/*
+ * 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.
+ */
+
+@Category(UnitTest.class)
+public class ProtocolVersionHandlerJUnitTest {
+  private static final int INVALID_MAJOR_VERSION = 67;
+  private static final int INVALID_MINOR_VERSION = 92347;
+
+  private ProtocolVersionHandler protocolVersionHandler = new ProtocolVersionHandler();
+
+  @Test
+  public void testCurrentVersionVersionMessageSucceeds() throws Exception {
+    ProtocolVersion.NewConnectionClientVersion versionRequest =
+        generateVersionMessageRequest(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
+            ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
+
+    ByteArrayInputStream inputStream =
+        MessageUtil.writeMessageDelimitedToInputStream(versionRequest);
+
+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+    assertTrue(protocolVersionHandler.handleVersionMessage(inputStream, outputStream,
+        mock(ProtocolClientStatistics.class)));
+
+    ProtocolVersion.VersionAcknowledgement versionResponse = ProtocolVersion.VersionAcknowledgement
+        .parseDelimitedFrom(new ByteArrayInputStream(outputStream.toByteArray()));
+    assertTrue(versionResponse.getVersionAccepted());
+    assertEquals(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
+        versionResponse.getServerMajorVersion());
+    assertEquals(ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE,
+        versionResponse.getServerMinorVersion());
+  }
+
+  @Test
+  public void testInvalidMajorVersionFails() throws Exception {
+    assertNotEquals(INVALID_MAJOR_VERSION,
+        ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE);
+
+    ProtocolVersion.NewConnectionClientVersion versionRequest = generateVersionMessageRequest(
+        INVALID_MAJOR_VERSION, ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
+
+    verifyVersionMessageFails(versionRequest);
+
+    // Also validate the protobuf INVALID_MAJOR_VERSION_VALUE constant fails
+    versionRequest =
+        generateVersionMessageRequest(ProtocolVersion.MajorVersions.INVALID_MAJOR_VERSION_VALUE,
+            ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
+    verifyVersionMessageFails(versionRequest);
+  }
+
+  private void verifyVersionMessageFails(ProtocolVersion.NewConnectionClientVersion versionRequest)
+      throws Exception {
+    ByteArrayInputStream inputStream =
+        MessageUtil.writeMessageDelimitedToInputStream(versionRequest);
+
+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+    try {
+      protocolVersionHandler.handleVersionMessage(inputStream, outputStream,
+          mock(ProtocolClientStatistics.class));
+      fail("Invalid version should throw IOException");
+    } catch (IOException e) {
+      // expected if version verification fails
+    }
+
+    ProtocolVersion.VersionAcknowledgement versionResponse = ProtocolVersion.VersionAcknowledgement
+        .parseDelimitedFrom(new ByteArrayInputStream(outputStream.toByteArray()));
+
+    assertFalse(versionResponse.getVersionAccepted());
+  }
+
+  @Test
+  public void testInvalidMinorVersionFails() throws Exception {
+    assertNotEquals(INVALID_MINOR_VERSION,
+        ProtocolVersion.MinorVersions.CURRENT_MINOR_VERSION_VALUE);
+
+    ProtocolVersion.NewConnectionClientVersion versionRequest = generateVersionMessageRequest(
+        ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE, INVALID_MINOR_VERSION);
+
+    verifyVersionMessageFails(versionRequest);
+
+    // Also validate the protobuf INVALID_MINOR_VERSION_VALUE constant fails
+    versionRequest =
+        generateVersionMessageRequest(ProtocolVersion.MajorVersions.CURRENT_MAJOR_VERSION_VALUE,
+            ProtocolVersion.MinorVersions.INVALID_MINOR_VERSION_VALUE);
+    verifyVersionMessageFails(versionRequest);
+  }
+
+  private ProtocolVersion.NewConnectionClientVersion generateVersionMessageRequest(int majorVersion,
+      int minorVersion) {
+    return ProtocolVersion.NewConnectionClientVersion.newBuilder().setMajorVersion(majorVersion)
+        .setMinorVersion(minorVersion).build();
+  }
+}
diff --git a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidatorJUnitTest.java
b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidatorJUnitTest.java
index e83e6e0..eea03df 100644
--- a/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidatorJUnitTest.java
+++ b/geode-protobuf/src/test/java/org/apache/geode/internal/protocol/protobuf/v1/operations/VersionValidatorJUnitTest.java
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.protocol.protobuf.Handshake;
+import org.apache.geode.internal.protocol.protobuf.ProtocolVersion;
 import org.apache.geode.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
@@ -32,12 +32,12 @@ public class VersionValidatorJUnitTest {
 
   @Test
   public void testInvalidVersions() throws Exception {
-    assertFalse(
-        validator.isValid(MAJOR_VERSION, Handshake.MinorVersions.INVALID_MINOR_VERSION_VALUE));
-    assertFalse(
-        validator.isValid(Handshake.MajorVersions.INVALID_MAJOR_VERSION_VALUE, MINOR_VERSION));
-    assertFalse(validator.isValid(Handshake.MajorVersions.INVALID_MAJOR_VERSION_VALUE,
-        Handshake.MinorVersions.INVALID_MINOR_VERSION_VALUE));
+    assertFalse(validator.isValid(MAJOR_VERSION,
+        ProtocolVersion.MinorVersions.INVALID_MINOR_VERSION_VALUE));
+    assertFalse(validator.isValid(ProtocolVersion.MajorVersions.INVALID_MAJOR_VERSION_VALUE,
+        MINOR_VERSION));
+    assertFalse(validator.isValid(ProtocolVersion.MajorVersions.INVALID_MAJOR_VERSION_VALUE,
+        ProtocolVersion.MinorVersions.INVALID_MINOR_VERSION_VALUE));
   }
 
   @Test

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message