You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2017/06/09 15:36:38 UTC

geode git commit: GEODE-3023: Amended due to review comments

Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3023 bf58202b7 -> 0bcd66a44


GEODE-3023: Amended due to review comments


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

Branch: refs/heads/feature/GEODE-3023
Commit: 0bcd66a443a751a51bfd374ef39a971cde1f3878
Parents: bf58202
Author: Udo Kohlmeyer <uk...@pivotal.io>
Authored: Fri Jun 9 08:36:36 2017 -0700
Committer: Udo Kohlmeyer <uk...@pivotal.io>
Committed: Fri Jun 9 08:36:36 2017 -0700

----------------------------------------------------------------------
 .../tcpserver/TCPServerSSLJUnitTest.java        | 45 ++++----------------
 1 file changed, 9 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/0bcd66a4/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
index f4a79e4..ce5fe0c 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/tcpserver/TCPServerSSLJUnitTest.java
@@ -23,9 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_PROTOCOLS
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE;
 import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD;
 
-import org.apache.geode.cache.GemFireCache;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import io.codearte.catchexception.shade.mockito.Mockito;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.DistributionConfigImpl;
 import org.apache.geode.distributed.internal.PoolStatHelper;
@@ -47,15 +45,12 @@ import org.junit.Test;
 import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
-import java.io.EOFException;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicInteger;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
 
 @Category({IntegrationTest.class, MembershipTest.class})
 public class TCPServerSSLJUnitTest {
@@ -79,31 +74,34 @@ public class TCPServerSSLJUnitTest {
     SocketCreatorFactory.close();
   }
 
-  private void startTimeDelayedTcpServer(Properties sslProperties) throws IOException {
+  private void startTimeDummyTcpServer(Properties sslProperties) throws IOException {
     localhost = InetAddress.getLocalHost();
     port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 
     stats = new SimpleStats();
-    server = new DummyTcpServer(port, localhost, sslProperties, null, new EchoHandler(), stats,
-        Thread.currentThread().getThreadGroup(), "server thread");
+    server =
+        new DummyTcpServer(port, localhost, sslProperties, null, Mockito.mock(TcpHandler.class),
+            stats, Thread.currentThread().getThreadGroup(), "server thread");
     server.start();
   }
 
   @Test
   public void testSSLSocketTimeOut() throws IOException {
+    boolean caughtLocatorException = false;
     try {
-
       System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "TcpServer.READ_TIMEOUT",
           expectedSocketTimeout);
       Properties sslProperties = getSSLConfigurationProperties();
-      startTimeDelayedTcpServer(sslProperties);
+      startTimeDummyTcpServer(sslProperties);
 
       createTcpClientConnection();
 
     } catch (LocatorCancelException e) {
       // we catching the LocatorCancelException. Expected to have the exception thrown
+      caughtLocatorException = true;
     }
 
+    Assert.assertTrue(caughtLocatorException);
     List<Integer> recordedSocketsForSocketCreator = server.getRecordedSocketTimeouts();
 
     Assert.assertEquals(1, recordedSocketsForSocketCreator.size());
@@ -138,31 +136,6 @@ public class TCPServerSSLJUnitTest {
     }
   }
 
-  private static class EchoHandler implements TcpHandler {
-
-    protected/* GemStoneAddition */ boolean shutdown;
-
-
-    public void init(TcpServer tcpServer) {}
-
-    public Object processRequest(Object request) throws IOException {
-      return request;
-    }
-
-    public void shutDown() {
-      shutdown = true;
-    }
-
-    public void restarting(DistributedSystem ds, GemFireCache cache,
-        ClusterConfigurationService sharedConfig) {}
-
-    public void endRequest(Object request, long startTime) {}
-
-    public void endResponse(Object request, long startTime) {}
-
-  }
-
-
   private class DummyTcpServer extends TcpServer {
     private DistributionConfig distributionConfig;
     private List<Integer> recordedSocketsTimeouts = new ArrayList<>();