geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [17/26] incubator-geode git commit: GEODE-420: Clean up of SocketCreator code in tests. SocketCreatorFactory currently singleton, to amend at later stage
Date Fri, 22 Jul 2016 00:20:04 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
index 3c05794..3ce3ec5 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/DistributedMulticastRegionDUnitTest.java
@@ -54,38 +54,36 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
   static int locatorVM = 3;
   static String mcastport = "42786";
   static String mcastttl = "0";
-  
+
   private int locatorPort;
 
   @Override
   public final void preSetUp() throws Exception {
     clean();
   }
-  
+
   @Override
   public final void preTearDownCacheTestCase() throws Exception {
     clean();
   }
-  
-  private void clean(){
-    SerializableRunnable cleanVM =
-        new CacheSerializableRunnable("clean VM") {
-            public void run2() throws CacheException {
-              disconnectFromDS();
-            }
-        };
-    Invoke.invokeInEveryVM(cleanVM);    
+
+  private void clean() {
+    SerializableRunnable cleanVM = new CacheSerializableRunnable("clean VM") {
+      public void run2() throws CacheException {
+        disconnectFromDS();
+      }
+    };
+    Invoke.invokeInEveryVM(cleanVM);
   }
-  
+
   @Test
   public void testMulticastEnabled() {
     final String name = "mcastRegion";
-    SerializableRunnable create =
-      new CacheSerializableRunnable("Create Region") {
-          public void run2() throws CacheException {
-            createRegion(name, getRegionAttributes());
-          }
-        };
+    SerializableRunnable create = new CacheSerializableRunnable("Create Region") {
+      public void run2() throws CacheException {
+        createRegion(name, getRegionAttributes());
+      }
+    };
 
     locatorPort = startLocator();
     Host host = Host.getHost(0);
@@ -106,39 +104,37 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
     vm0.invoke(validateMulticastBeforeRegionOps);
     vm1.invoke(validateMulticastBeforeRegionOps);
     */
-    
-    SerializableRunnable doPuts =
-      new CacheSerializableRunnable("do put") {
-          public void run2() throws CacheException {
-            final Region region =
-                getRootRegion().getSubregion(name);
-            for(int i =0 ; i < 5; i++) {
-              region.put(i, i);
-            }
-          }
-      };
-      
+
+    SerializableRunnable doPuts = new CacheSerializableRunnable("do put") {
+      public void run2() throws CacheException {
+        final Region region = getRootRegion().getSubregion(name);
+        for (int i = 0; i < 5; i++) {
+          region.put(i, i);
+        }
+      }
+    };
+
     vm0.invoke(doPuts);
-    
-    SerializableRunnable validateMulticastAfterRegionOps =
-      new CacheSerializableRunnable("validateMulticast after region ops") {
-          public void run2() throws CacheException {
-            validateMulticastOpsAfterRegionOps();
-          }
-      };
-    
-      vm0.invoke(validateMulticastAfterRegionOps);
-      vm1.invoke(validateMulticastAfterRegionOps);
-   
-      closeLocator();      
+
+    SerializableRunnable validateMulticastAfterRegionOps = new CacheSerializableRunnable("validateMulticast after region ops") {
+      public void run2() throws CacheException {
+        validateMulticastOpsAfterRegionOps();
+      }
+    };
+
+    vm0.invoke(validateMulticastAfterRegionOps);
+    vm1.invoke(validateMulticastAfterRegionOps);
+
+    closeLocator();
   }
-  
+
   private static class TestObjectThrowsException implements PdxSerializable {
+
     String name = "TestObjectThrowsException";
 
     @Override
     public void toData(PdxWriter writer) {
-      writer.writeString("name", name);      
+      writer.writeString("name", name);
     }
 
     @Override
@@ -146,7 +142,7 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
       throw new RuntimeException("Unable to deserialize message ");
     }
   }
-  
+
   @Test
   public void testMulticastWithRegionOpsException() {
     Host host = Host.getHost(0);
@@ -155,31 +151,21 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
 
     try {
       final String name = "mcastRegion";
-      
-      SerializableRunnable setSysProp = new CacheSerializableRunnable("Create Region") {
-        public void run2() throws CacheException {
-          CachedDeserializableFactory.STORE_ALL_VALUE_FORMS = true;
-        }
-      };
-      
-      
-      SerializableRunnable create =
-        new CacheSerializableRunnable("Create Region") {
-            public void run2() throws CacheException {
-              createRegion(name, getRegionAttributes());
-            }
-          };
-  
+
       locatorPort = startLocator();
-      
-      vm0.invoke(setSysProp);
-      vm1.invoke(setSysProp);
-      
+
+      vm0.invoke("setSysProps", () -> setSysProps());
+      //      vm1.invoke("setSysProps", () -> setSysProps());
+      setSysProps();
       //1. start locator with mcast port
-      vm0.invoke(create);
-      vm1.invoke(create);
-      
-    //There is possibility that you may get this packet from other tests
+      vm0.invoke("createRegion", () -> {
+        createRegion(name, getRegionAttributes());
+        return "";
+      });
+      //      vm1.invoke("createRegion", () -> createRegion(name,getRegionAttributes()));
+      createRegion(name, getRegionAttributes());
+
+      //There is possibility that you may get this packet from other tests
       /*
       SerializableRunnable validateMulticastBeforeRegionOps =
           new CacheSerializableRunnable("validateMulticast before region ops") {
@@ -191,40 +177,37 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
       vm0.invoke(validateMulticastBeforeRegionOps);
       vm1.invoke(validateMulticastBeforeRegionOps);
       */
-      
-      SerializableRunnable doPuts =
-        new CacheSerializableRunnable("do put") {
-            public void run2() throws CacheException {
-              final Region region =
-                  getRootRegion().getSubregion(name);
-              boolean gotReplyException = false;
-              for(int i =0 ; i < 1; i++) {
-                try {
-                  region.put(i, new TestObjectThrowsException());
-                }catch(PdxSerializationException e) {
-                  gotReplyException = true;
-                }catch(Exception e ) {
-                  region.getCache().getLogger().info("Got exception of type " + e.getClass().toString());
-                } 
-              }
-              assertTrue("We should have got ReplyEception ", gotReplyException);
+
+      SerializableRunnable doPuts = new CacheSerializableRunnable("do put") {
+        public void run2() throws CacheException {
+          final Region region = getRootRegion().getSubregion(name);
+          boolean gotReplyException = false;
+          for (int i = 0; i < 1; i++) {
+            try {
+              region.put(i, new TestObjectThrowsException());
+            } catch (PdxSerializationException e) {
+              gotReplyException = true;
+            } catch (Exception e) {
+              region.getCache().getLogger().info("Got exception of type " + e.getClass().toString());
             }
-        };
-        
+          }
+          assertTrue("We should have got ReplyEception ", gotReplyException);
+        }
+      };
+
       vm0.invoke(doPuts);
-      
-      SerializableRunnable validateMulticastAfterRegionOps =
-        new CacheSerializableRunnable("validateMulticast after region ops") {
-            public void run2() throws CacheException {
-              validateMulticastOpsAfterRegionOps();
-            }
-        };
-      
-        vm0.invoke(validateMulticastAfterRegionOps);
-        vm1.invoke(validateMulticastAfterRegionOps);
-     
-        closeLocator();
-    }finally {
+
+      SerializableRunnable validateMulticastAfterRegionOps = new CacheSerializableRunnable("validateMulticast after region ops") {
+        public void run2() throws CacheException {
+          validateMulticastOpsAfterRegionOps();
+        }
+      };
+
+      vm0.invoke(validateMulticastAfterRegionOps);
+      vm1.invoke(validateMulticastAfterRegionOps);
+
+      closeLocator();
+    } finally {
       SerializableRunnable unsetSysProp = new CacheSerializableRunnable("Create Region") {
         public void run2() throws CacheException {
           CachedDeserializableFactory.STORE_ALL_VALUE_FORMS = false;
@@ -234,7 +217,11 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
       vm1.invoke(unsetSysProp);
     }
   }
-  
+
+  private void setSysProps() {
+    CachedDeserializableFactory.STORE_ALL_VALUE_FORMS = true;
+  }
+
   protected RegionAttributes getRegionAttributes() {
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.DISTRIBUTED_ACK);
@@ -244,7 +231,7 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
     factory.setMulticastEnabled(true);
     return factory.create();
   }
-  
+
   public Properties getDistributedSystemProperties() {
     Properties p = new Properties();
     p.put(STATISTIC_SAMPLING_ENABLED, "true");
@@ -254,66 +241,66 @@ public class DistributedMulticastRegionDUnitTest extends JUnit4CacheTestCase {
     p.put(LOCATORS, "localhost[" + locatorPort + "]");
     p.put(LOG_LEVEL, "info");
     return p;
-  } 
-  
+  }
+
   private void validateMulticastOpsAfterRegionOps() {
     int writes = getGemfireCache().getDistributionManager().getStats().getMcastWrites();
     int reads = getGemfireCache().getDistributionManager().getStats().getMcastReads();
-    assertTrue("Should have multicast writes or reads. Writes=  " + writes +  " ,read= " + reads, 
-        writes > 0 || reads > 0);
+    assertTrue("Should have multicast writes or reads. Writes=  " + writes + " ,read= " + reads, writes > 0 || reads > 0);
   }
-  
+
   private void validateMulticastOpsBeforeRegionOps() {
     int writes = getGemfireCache().getDistributionManager().getStats().getMcastWrites();
     int reads = getGemfireCache().getDistributionManager().getStats().getMcastReads();
     int total = writes + reads;
-    assertTrue("Should not have any multicast writes or reads before region ops. Writes=  " + writes +  " ,read= " + reads, 
-        total == 0);
+    assertTrue("Should not have any multicast writes or reads before region ops. Writes=  " + writes + " ,read= " + reads, total == 0);
   }
-  
+
   private int startLocator() {
-    final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     final int locatorPort = ports[0];
 
     VM locator1Vm = Host.getHost(0).getVM(locatorVM);
-      locator1Vm.invoke(new SerializableCallable() {
-        @Override
-        public Object call() {
-          final File locatorLogFile = new File(getTestMethodName() + "-locator-" + locatorPort + ".log");
-          final Properties locatorProps = new Properties();
-          locatorProps.setProperty(NAME, "LocatorWithMcast");
-          locatorProps.setProperty(MCAST_PORT, mcastport);
-          locatorProps.setProperty(MCAST_TTL, mcastttl);
-          locatorProps.setProperty(LOG_LEVEL, "info");
-          //locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-          try {
-            final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, null, null,
-                locatorProps);
-            System.out.println("test Locator started " + locatorPort);
-             } catch (IOException ioex) {
-            fail("Unable to create a locator with a shared configuration");
-          }
-
-          return null;
+    locator1Vm.invoke(new SerializableCallable() {
+      @Override
+      public Object call() {
+        final File locatorLogFile = new File(getTestMethodName() + "-locator-" + locatorPort + ".log");
+        final Properties locatorProps = new Properties();
+        locatorProps.setProperty(NAME, "LocatorWithMcast");
+        locatorProps.setProperty(MCAST_PORT, mcastport);
+        locatorProps.setProperty(MCAST_TTL, mcastttl);
+        locatorProps.setProperty(LOG_LEVEL, "info");
+        //locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        try {
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, null, null, locatorProps);
+          System.out.println("test Locator started " + locatorPort);
+        } catch (IOException ioex) {
+          fail("Unable to create a locator with a shared configuration");
         }
+
+        return null;
+      }
     });
     return locatorPort;
   }
-  
+
   private void closeLocator() {
-    VM locator1Vm = Host.getHost(0).getVM(locatorVM);;
+    VM locator1Vm = Host.getHost(0).getVM(locatorVM);
+    ;
     SerializableRunnable locatorCleanup = new SerializableRunnable() {
       @Override
       public void run() {
-        System.out.println("test Locator closing " + locatorPort);;
+        System.out.println("test Locator closing " + locatorPort);
+        ;
         InternalLocator locator = InternalLocator.getLocator();
-        if (locator != null ) {
+        if (locator != null) {
           locator.stop();
-          System.out.println("test Locator closed " + locatorPort);;
+          System.out.println("test Locator closed " + locatorPort);
+          ;
         }
       }
     };
     locator1Vm.invoke(locatorCleanup);
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
index cc13c48..f323574 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
@@ -51,18 +51,17 @@ public abstract class AbstractLauncherIntegrationTestCase {
   
   protected static final int WAIT_FOR_PROCESS_TO_DIE_TIMEOUT = 5 * 60 * 1000; // 5 minutes
   protected static final int TIMEOUT_MILLISECONDS = WAIT_FOR_PROCESS_TO_DIE_TIMEOUT;
-  protected static final int WAIT_FOR_FILE_CREATION_TIMEOUT = 10*1000;
-  protected static final int WAIT_FOR_FILE_DELETION_TIMEOUT = 10*1000;
-  protected static final int WAIT_FOR_MBEAN_TIMEOUT = 10*1000;
-  protected static final int INTERVAL = 100;
-  protected static final int INTERVAL_MILLISECONDS = INTERVAL;
+  protected static final int WAIT_FOR_FILE_CREATION_TIMEOUT = 10*1000; // 10s
+  protected static final int WAIT_FOR_FILE_DELETION_TIMEOUT = 10*1000; // 10s
+  protected static final int WAIT_FOR_MBEAN_TIMEOUT = 10*1000; // 10s
+  protected static final int INTERVAL_MILLISECONDS = 100;
   
   private static final String EXPECTED_EXCEPTION_ADD = "<ExpectedException action=add>{}</ExpectedException>";
   private static final String EXPECTED_EXCEPTION_REMOVE = "<ExpectedException action=remove>{}</ExpectedException>";
   private static final String EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED = "MBean Not Registered In GemFire Domain";
   
   protected volatile ServerSocket socket;
-  
+
   protected volatile File pidFile;
   protected volatile File stopRequestFile;
   protected volatile File statusRequestFile;
@@ -106,7 +105,7 @@ public abstract class AbstractLauncherIntegrationTestCase {
         }
         return !file.exists();
       }
-    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL);
+    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL_MILLISECONDS);
   }
   
   protected void waitForPidToStop(final int pid, boolean throwOnTimeout) throws Exception {
@@ -115,7 +114,7 @@ public abstract class AbstractLauncherIntegrationTestCase {
       public Boolean call() throws Exception {
         return ProcessUtils.isProcessAlive(pid);
       }
-    }, WAIT_FOR_PROCESS_TO_DIE_TIMEOUT, INTERVAL);
+    }, WAIT_FOR_PROCESS_TO_DIE_TIMEOUT, INTERVAL_MILLISECONDS);
   }
   
   protected void waitForPidToStop(final int pid) throws Exception {
@@ -131,7 +130,7 @@ public abstract class AbstractLauncherIntegrationTestCase {
       public Boolean call() throws Exception {
         return !file.exists();
       }
-    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL);
+    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL_MILLISECONDS);
   }
   
   protected void waitForFileToDelete(final File file) throws Exception {
@@ -214,7 +213,7 @@ public abstract class AbstractLauncherIntegrationTestCase {
       public Boolean call() throws Exception {
         return file.exists();
       }
-    }, WAIT_FOR_FILE_CREATION_TIMEOUT, INTERVAL);
+    }, WAIT_FOR_FILE_CREATION_TIMEOUT, INTERVAL_MILLISECONDS);
   }
   
   protected void waitForFileToExist(final File file) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
index d59fecb..143723e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.messenger.JGroup
 import com.gemstone.gemfire.distributed.internal.membership.gms.mgr.GMSMembershipManager;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.test.dunit.*;
 import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
index 438c3f7..0aa7bbd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
@@ -24,7 +24,7 @@ import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.util.StopWatch;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
index 8c570ac..bdd1fdb 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
@@ -143,6 +143,6 @@ public class LauncherMemberMXBeanIntegrationTest extends AbstractLauncherIntegra
         Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
         return !mbeanNames.isEmpty();
       }
-    }, WAIT_FOR_MBEAN_TIMEOUT, INTERVAL);
+    }, WAIT_FOR_MBEAN_TIMEOUT, INTERVAL_MILLISECONDS);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
index faf6d31..01c76f0 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
@@ -21,6 +21,8 @@ import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
 import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.internal.*;
+import com.gemstone.gemfire.internal.net.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
 import com.gemstone.gemfire.internal.process.ProcessType;
 import com.gemstone.gemfire.internal.process.ProcessUtils;
@@ -325,7 +327,7 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
       return;
     }
 
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.locatorPort, 50, null, -1);
     assertTrue(this.socket.isBound());
     assertFalse(this.socket.isClosed());
     assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
@@ -542,7 +544,7 @@ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncher
     }
 
     // generate one free port and then use it instead of default
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.locatorPort, 50, null, -1);
     
     this.launcher = new Builder()
         .setMemberName(getUniqueName())

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
index 8e978e9..a2ae73d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
@@ -20,12 +20,14 @@ import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
 import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
 import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.DistributionLocator;
 import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LocalLogWriter;
+import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
 import com.gemstone.gemfire.internal.process.ProcessStreamReader;
 import com.gemstone.gemfire.internal.process.ProcessType;
@@ -49,6 +51,7 @@ import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static com.gemstone.gemfire.distributed.ConfigurationProperties.MCAST_PORT;
@@ -397,7 +400,7 @@ public class LocatorLauncherRemoteIntegrationTest extends AbstractLocatorLaunche
 
   @Test
   public void testStartUsingPortInUseFails() throws Throwable {
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.locatorPort, 50, null, -1);
     this.locatorPort = this.socket.getLocalPort();
 
     final List<String> jvmArguments = getJvmArguments();
@@ -469,7 +472,7 @@ public class LocatorLauncherRemoteIntegrationTest extends AbstractLocatorLaunche
     String expectedString = "java.net.BindException";
     AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
 
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.locatorPort, 50, null, -1);
     this.locatorPort = this.socket.getLocalPort();
 
     assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
index 1baf48d..854f02d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
@@ -27,11 +27,12 @@ import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
 import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
 import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
 import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
+import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
 import com.gemstone.gemfire.internal.process.ProcessType;
 import com.gemstone.gemfire.internal.process.ProcessUtils;
@@ -349,7 +350,7 @@ public class ServerLauncherLocalIntegrationTest extends AbstractServerLauncherIn
     String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
 
     // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.serverPort, 50, null, -1);
     assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
     
     // build and start the server
@@ -608,7 +609,7 @@ public class ServerLauncherLocalIntegrationTest extends AbstractServerLauncherIn
     String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
 
     // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.serverPort, 50, null, -1);
     assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
     
     // build and start the server
@@ -769,7 +770,7 @@ public class ServerLauncherLocalIntegrationTest extends AbstractServerLauncherIn
 
     // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
     final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(freeTCPPort, 50, null, -1);
     
     // build and start the server
     final Builder builder = new Builder()

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
index 6d20673..f1a8d41 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
@@ -25,13 +25,14 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
 import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
 import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
 import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.LocalLogWriter;
+import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 import com.gemstone.gemfire.internal.process.*;
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@@ -427,7 +428,7 @@ public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherR
   @Test
   public void testStartUsingDisableDefaultServerSkipsPortCheck() throws Throwable {
     // make serverPort in use
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.serverPort, 50, null, -1);
     assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
     
     // build and start the server
@@ -551,7 +552,7 @@ public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherR
   @Test
   public void testStartUsingServerPortInUseFails() throws Throwable {
     // make serverPort in use
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.serverPort, 50, null, -1);
     assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
     
     final List<String> jvmArguments = getJvmArguments();
@@ -798,7 +799,7 @@ public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherR
     AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
 
     // make serverPort in use
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    this.socket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(this.serverPort, 50, null, -1);
     assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
     
     // launch server

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
index 80a3140..55c741b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
@@ -113,9 +113,9 @@ public class DistributionConfigJUnitTest {
     //TODO - This makes no sense. One has no idea what the correct expected number of attributes are.
     assertEquals(27, boolList.size());
     assertEquals(33, intList.size());
-    assertEquals(74, stringList.size());
+    assertEquals(73, stringList.size());
     assertEquals(5, fileList.size());
-    assertEquals(3, otherList.size());
+    assertEquals(4, otherList.size());
   }
 
   @Test
@@ -356,4 +356,32 @@ public class DistributionConfigJUnitTest {
     DistributionConfig config = new DistributionConfigImpl(props);
     assertEquals(config.getSecurityProps().size(), 4);
   }
+
+  @Test
+  public void testSSLEnabledComponents() {
+    Properties props = new Properties();
+    props.put(CLUSTER_SSL_ENABLED, "true");
+    props.put(SSL_ENABLED_COMPONENTS, "all");
+
+    DistributionConfig config = new DistributionConfigImpl(props);
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSSLEnabledComponentsLegacyFail() {
+    Properties props = new Properties();
+    props.put(CLUSTER_SSL_ENABLED, "true");
+    props.put(HTTP_SERVICE_SSL_ENABLED, "true");
+    props.put(SSL_ENABLED_COMPONENTS, "all");
+
+    DistributionConfig config = new DistributionConfigImpl(props);
+  }
+  @Test
+  public void testSSLEnabledComponentsLegacyPass() {
+    Properties props = new Properties();
+    props.put(CLUSTER_SSL_ENABLED, "true");
+    props.put(HTTP_SERVICE_SSL_ENABLED, "true");
+    props.put(SSL_ENABLED_COMPONENTS, "");
+
+    DistributionConfig config = new DistributionConfigImpl(props);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/StartupMessageDataJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/StartupMessageDataJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/StartupMessageDataJUnitTest.java
index 6aa4248..787aae0 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/StartupMessageDataJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/StartupMessageDataJUnitTest.java
@@ -30,8 +30,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.internal.InternalDataSerializer;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.ByteArrayData;
 import com.gemstone.gemfire.internal.admin.remote.DistributionLocatorId;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
index 9c7180e..996fbf6 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
@@ -27,7 +27,7 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.membership.GMSJo
 import com.gemstone.gemfire.distributed.internal.membership.gms.messages.*;
 import com.gemstone.gemfire.distributed.internal.membership.gms.mgr.GMSMembershipManager;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 import org.apache.logging.log4j.Level;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/NetViewJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/NetViewJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/NetViewJUnitTest.java
index fbc4189..421a381 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/NetViewJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/NetViewJUnitTest.java
@@ -30,7 +30,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
index d29553c..e487e39 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.messages.Heartbe
 import com.gemstone.gemfire.distributed.internal.membership.gms.messages.HeartbeatRequestMessage;
 import com.gemstone.gemfire.distributed.internal.membership.gms.messages.SuspectMembersMessage;
 import com.gemstone.gemfire.distributed.internal.membership.gms.messages.SuspectRequest;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 import org.jgroups.util.UUID;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
index fcf77a0..b98de78 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
@@ -25,7 +25,7 @@ import com.gemstone.gemfire.distributed.internal.membership.MemberFactory;
 import com.gemstone.gemfire.distributed.internal.membership.MembershipManager;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerBackwardCompatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerBackwardCompatDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerBackwardCompatDUnitTest.java
index 954aff4..3cb91f7 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerBackwardCompatDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServerBackwardCompatDUnitTest.java
@@ -34,7 +34,7 @@ import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedM
 import com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorRequest;
 import com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorResponse;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.Invoke;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java
index ef07633..48fe4dd 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/GemFireStatSamplerJUnitTest.java
@@ -23,6 +23,7 @@ import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.internal.GemFireStatSampler.LocalStatListenerImpl;
 import com.gemstone.gemfire.internal.cache.control.HeapMemoryMonitor;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.statistics.SampleCollector;
 import com.gemstone.gemfire.internal.statistics.StatArchiveHandler;
 import com.gemstone.gemfire.internal.statistics.StatArchiveHandlerConfig;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/JSSESocketJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/JSSESocketJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/JSSESocketJUnitTest.java
deleted file mode 100755
index 30899be..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/JSSESocketJUnitTest.java
+++ /dev/null
@@ -1,252 +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 com.gemstone.gemfire.internal;
-
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.test.dunit.ThreadUtils;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import com.gemstone.gemfire.util.test.TestUtil;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.appender.AbstractAppender;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-import java.io.*;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.Properties;
-
-import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Test creation of server sockets and client sockets with various JSSE
- * configurations.
- */
-@Category(IntegrationTest.class)
-public class JSSESocketJUnitTest {
-  public
-  @Rule
-  TestName name = new TestName();
-
-  private static final org.apache.logging.log4j.Logger logger = LogService.getLogger();
-
-  ServerSocket acceptor;
-  Socket server;
-
-  static ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-  private int randport = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-
-  @Before
-  public void setUp() throws Exception {
-    System.out.println("\n\n########## setup " + name.getMethodName() + " ############\n\n");
-    server = null;
-    acceptor = null;
-    baos.reset();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    System.out.println("\n\n########## teardown " + name.getMethodName() + " ############\n\n");
-
-    if (server != null) {
-      server.close();
-    }
-    if (acceptor != null) {
-      acceptor.close();
-    }
-    System.out.println(baos.toString());
-  }
-
-  //----- test methods ------
-
-  @Test
-  public void testSSLSocket() throws Exception {
-    final Object[] receiver = new Object[1];
-
-    TestAppender.create();
-
-    // Get original base log level
-    Level originalBaseLevel = LogService.getBaseLogLevel();
-    try {
-      // Set base log level to debug to log the SSL messages
-      LogService.setBaseLogLevel(Level.DEBUG);
-      {
-        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + MCAST_PORT, "0");
-        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_ENABLED, "true");
-        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_REQUIRE_AUTHENTICATION, "true");
-        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_CIPHERS, "any");
-        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_PROTOCOLS, "TLSv1.2");
-
-        File jks = findTestJKS();
-        System.setProperty("javax.net.ssl.trustStore", jks.getCanonicalPath());
-        System.setProperty("javax.net.ssl.trustStorePassword", "password");
-        System.setProperty("javax.net.ssl.keyStore", jks.getCanonicalPath());
-        System.setProperty("javax.net.ssl.keyStorePassword", "password");
-      }
-
-      assertTrue(SocketCreator.getDefaultInstance().useSSL());
-
-      Thread serverThread = startServer(receiver);
-
-      Socket client = SocketCreator.getDefaultInstance().connectForServer(InetAddress.getByName("localhost"), randport);
-
-      ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream());
-      String expected = new String("testing " + name.getMethodName());
-      oos.writeObject(expected);
-      oos.flush();
-
-      ThreadUtils.join(serverThread, 30 * 1000);
-
-      client.close();
-      if (expected.equals(receiver[0])) {
-        System.out.println("received " + receiver[0] + " as expected.");
-      } else {
-        throw new Exception("Expected \"" + expected + "\" but received \"" + receiver[0] + "\"");
-      }
-
-      String logOutput = baos.toString();
-      StringReader sreader = new StringReader(logOutput);
-      LineNumberReader reader = new LineNumberReader(sreader);
-      int peerLogCount = 0;
-      String line = null;
-      while ((line = reader.readLine()) != null) {
-
-        if (line.matches(".*peer CN=.*")) {
-          System.out.println("Found peer log statement.");
-          peerLogCount++;
-        }
-      }
-      if (peerLogCount != 2) {
-        throw new Exception("Expected to find to peer identities logged.");
-      }
-    } finally {
-      // Reset original base log level
-      LogService.setBaseLogLevel(originalBaseLevel);
-    }
-  }
-
-  /**
-   * not actually related to this test class, but this is as good a place
-   * as any for this little test of the client-side ability to tell gemfire
-   * to use a given socket factory.  We just test the connectForClient method
-   * to see if it's used
-   */
-  @Test
-  public void testClientSocketFactory() {
-    System.getProperties().put(DistributionConfig.GEMFIRE_PREFIX + "clientSocketFactory",
-        TSocketFactory.class.getName());
-    System.getProperties().remove(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_ENABLED);
-    SocketCreator.getDefaultInstance(new Properties());
-    factoryInvoked = false;
-    try {
-      try {
-        Socket sock = SocketCreator.getDefaultInstance().connectForClient("localhost", 12345,
-            0);
-        sock.close();
-        fail("socket factory was not invoked");
-      } catch (IOException e) {
-        assertTrue("socket factory was not invoked: " + factoryInvoked, factoryInvoked);
-      }
-    } finally {
-      System.getProperties().remove(DistributionConfig.GEMFIRE_PREFIX + "clientSocketFactory");
-      SocketCreator.getDefaultInstance().initializeClientSocketFactory();
-    }
-  }
-
-  static boolean factoryInvoked;
-
-  public static class TSocketFactory implements com.gemstone.gemfire.distributed.ClientSocketFactory {
-    public TSocketFactory() {
-    }
-
-    public Socket createSocket(InetAddress address, int port) throws IOException {
-      JSSESocketJUnitTest.factoryInvoked = true;
-      throw new IOException("splort!");
-    }
-  }
-
-  //------------- utilities -----
-
-  private File findTestJKS() {
-    return new File(TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore"));
-  }
-
-  private Thread startServer(final Object[] receiver) throws Exception {
-    final ServerSocket ss = SocketCreator.getDefaultInstance().createServerSocket(randport, 0, InetAddress.getByName("localhost"));
-
-    Thread t = new Thread(new Runnable() {
-      public void run() {
-        try {
-          Socket s = ss.accept();
-          SocketCreator.getDefaultInstance().configureServerSSLSocket(s);
-          ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
-          receiver[0] = ois.readObject();
-          server = s;
-          acceptor = ss;
-        } catch (Exception e) {
-          e.printStackTrace();
-          receiver[0] = e;
-        }
-      }
-    }, name.getMethodName() + "-server");
-    t.start();
-    return t;
-  }
-
-  public static final class TestAppender extends AbstractAppender {
-    private static final String APPENDER_NAME = TestAppender.class.getName();
-    private final static String SOCKET_CREATOR_CLASSNAME = SocketCreator.class.getName();
-
-    private TestAppender() {
-      super(APPENDER_NAME, null, PatternLayout.createDefaultLayout());
-      start();
-    }
-
-    public static Appender create() {
-      Appender appender = new TestAppender();
-      Logger socketCreatorLogger = (Logger) LogManager.getLogger(SOCKET_CREATOR_CLASSNAME);
-      LoggerConfig config = socketCreatorLogger.getContext().getConfiguration().getLoggerConfig(SOCKET_CREATOR_CLASSNAME);
-      config.addAppender(appender, Level.DEBUG, null);
-      return appender;
-    }
-
-    @SuppressWarnings("synthetic-access")
-    @Override
-    public void append(final LogEvent event) {
-      try {
-        baos.write(new String(event.getMessage().getFormattedMessage() + "\n").getBytes());
-      } catch (IOException ioex) {
-        logger.warn(ioex);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/SSLConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SSLConfigJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/SSLConfigJUnitTest.java
index ff93ad7..925dcef 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SSLConfigJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/SSLConfigJUnitTest.java
@@ -101,24 +101,6 @@ public class SSLConfigJUnitTest {
   }
   
   @Test
-  public void testMCastPortWithSSL() throws Exception {
-    Properties props = new Properties( );
-    // default mcast-port is not 0.
-    props.setProperty(CLUSTER_SSL_ENABLED, "true");
-    
-    try {
-      new DistributionConfigImpl( props );
-    } catch ( IllegalArgumentException e ) {
-      if (! e.toString().matches( ".*Could not set \"ssl-enabled.*" ) ) { // TODO: what if this isn't thrown at all?? Is it expected?
-        throw new Exception( "did not get expected exception, got this instead...", e );
-      }
-    }
-
-    props.setProperty(MCAST_PORT, "0");
-    new DistributionConfigImpl( props );
-  }
-  
-  @Test
   public void testMCastPortWithClusterSSL() throws Exception {
     Properties props = new Properties( );
     // default mcast-port is not 0.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java
index 5d7c9f4..9a101fb 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/SimpleStatSamplerJUnitTest.java
@@ -33,6 +33,7 @@ import org.junit.rules.TestName;
 import com.gemstone.gemfire.CancelCriterion;
 import com.gemstone.gemfire.Statistics;
 import com.gemstone.gemfire.StatisticsType;
+import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.stats50.VMStats50;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
@@ -105,7 +106,7 @@ public class SimpleStatSamplerJUnitTest extends StatSamplerTestCase {
     
     assertEquals(getStatisticsManager().getId(), statSampler.getSystemId());
     assertTrue(statSampler.getSystemStartTime() <= System.currentTimeMillis());
-    assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), 
+    assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()),
                  statSampler.getSystemDirectoryPath());
 
     VMStatsContract vmStats = statSampler.getVMStats();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
deleted file mode 100644
index cc71738..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
+++ /dev/null
@@ -1,193 +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 com.gemstone.gemfire.internal;
-
-import static org.junit.Assert.*;
-
-import java.net.Socket;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.dunit.Wait;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-/**
- * Tests the default SocketCloser.
- */
-@Category(UnitTest.class)
-public class SocketCloserJUnitTest {
-
-  private SocketCloser socketCloser;
-  
-  @Before
-  public void setUp() throws Exception {
-    this.socketCloser = createSocketCloser();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    this.socketCloser.close();
-  }
-  
-  private Socket createClosableSocket() {
-    return new Socket();
-  }
-
-  protected SocketCloser createSocketCloser() {
-    return new SocketCloser();
-  }
-  
-  /**
-   * Test that close requests are async.
-   */
-  @Test
-  public void testAsync() {
-    final CountDownLatch cdl = new CountDownLatch(1);
-    final AtomicInteger waitingToClose = new AtomicInteger(0);
-    Runnable r = new Runnable() {
-      @Override
-      public void run() {
-        try {
-          waitingToClose.incrementAndGet();
-          cdl.await();
-        } catch (InterruptedException e) {
-        }
-      }
-    };
-    
-    final int SOCKET_COUNT = 100;
-    final Socket[] aSockets = new Socket[SOCKET_COUNT];
-    for (int i=0; i < SOCKET_COUNT; i++) {
-      aSockets[i] = createClosableSocket();
-    }
-    // Schedule a 100 sockets for async close.
-    // They should all be stuck on cdl.
-    for (int i=0; i < SOCKET_COUNT; i++) {
-      this.socketCloser.asyncClose(aSockets[i], "A", r);
-    }
-    // Make sure the sockets have not been closed
-    for (int i=0; i < SOCKET_COUNT; i++) {
-      assertEquals(false, aSockets[i].isClosed());
-    }
-    final Socket[] bSockets = new Socket[SOCKET_COUNT];
-    for (int i=0; i < SOCKET_COUNT; i++) {
-      bSockets[i] = createClosableSocket();
-    }
-    // Schedule a 100 sockets for async close.
-    // They should all be stuck on cdl.
-    for (int i=0; i < SOCKET_COUNT; i++) {
-      this.socketCloser.asyncClose(bSockets[i], "B", r);
-    }
-    // Make sure the sockets have not been closed
-    for (int i=0; i < SOCKET_COUNT; i++) {
-      assertEquals(false, bSockets[i].isClosed());
-    }
-    // close the socketCloser first to verify that the sockets
-    // that have already been scheduled will be still be closed.
-    this.socketCloser.releaseResourcesForAddress("A");
-    this.socketCloser.close();
-    // Each thread pool (one for A and one for B) has a max of 8 threads.
-    // So verify that this many are currently waiting on cdl.
-    {
-      final int maxThreads = this.socketCloser.getMaxThreads();
-      WaitCriterion wc = new WaitCriterion() {
-        public boolean done() {
-          return waitingToClose.get() == 2*maxThreads;
-        }
-        public String description() {
-          return "expected " + 2*maxThreads + " waiters but found only " + waitingToClose.get();
-        }
-      };
-      Wait.waitForCriterion(wc, 5000, 10, true);
-    }
-    // now count down the latch that allows the sockets to close
-    cdl.countDown();
-    // now all the sockets should get closed; use a wait criteria
-    // since a thread pool is doing to closes
-    {
-      WaitCriterion wc = new WaitCriterion() {
-        public boolean done() {
-          for (int i=0; i < SOCKET_COUNT; i++) {
-            if (!aSockets[i].isClosed() || !bSockets[i].isClosed()) {
-              return false;
-            }
-          }
-          return true;
-        }
-        public String description() {
-          return "one or more sockets did not close";
-        }
-      };
-      Wait.waitForCriterion(wc, 5000, 10, true);
-    }
-  }
-  
-  /**
-   * Verify that requesting an asyncClose on an already
-   * closed socket is a noop.
-   */
-  @Test
-  public void testClosedSocket() throws Exception {
-    final AtomicBoolean runnableCalled = new AtomicBoolean();
-    Runnable r = new Runnable() {
-      @Override
-      public void run() {
-        runnableCalled.set(true);
-      }
-    };
-    
-    Socket s = createClosableSocket();
-    s.close();
-    this.socketCloser.asyncClose(s, "A", r);
-    Wait.pause(10);
-    assertEquals(false, runnableCalled.get());
-  }
-  
-  /**
-   * Verify that a closed SocketCloser will still close an open socket
-   */
-  @Test
-  public void testClosedSocketCloser() {
-    final AtomicBoolean runnableCalled = new AtomicBoolean();
-    Runnable r = new Runnable() {
-      @Override
-      public void run() {
-        runnableCalled.set(true);
-      }
-    };
-    
-    final Socket s = createClosableSocket();
-    this.socketCloser.close();
-    this.socketCloser.asyncClose(s, "A", r);
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return runnableCalled.get() && s.isClosed(); 
-      }
-      public String description() {
-        return "runnable was not called or socket was not closed";
-      }
-    };
-    Wait.waitForCriterion(wc, 5000, 10, true);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
deleted file mode 100644
index 0ba41ba..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
+++ /dev/null
@@ -1,39 +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 com.gemstone.gemfire.internal;
-
-import java.util.concurrent.TimeUnit;
-
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-/**
- * Tests SocketCloser with a wait time. The default SocketCloser does not wait.
- * This test configures a closer much like the one used by CacheClientNotifier.
- */
-@Category(UnitTest.class)
-public class SocketCloserWithWaitJUnitTest extends SocketCloserJUnitTest {
-
-  @Override
-  protected SocketCloser createSocketCloser() {
-    return new SocketCloser(
-        SocketCloser.ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS,
-        1, // max threads
-        1, TimeUnit.NANOSECONDS);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/net/JSSESocketJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/net/JSSESocketJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/JSSESocketJUnitTest.java
new file mode 100755
index 0000000..63c556b
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/JSSESocketJUnitTest.java
@@ -0,0 +1,260 @@
+/*
+ * 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 com.gemstone.gemfire.internal.net;
+
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StringReader;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.test.dunit.ThreadUtils;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.util.test.TestUtil;
+
+/**
+ * Test creation of server sockets and client sockets with various JSSE
+ * configurations.
+ */
+@Category(IntegrationTest.class)
+public class JSSESocketJUnitTest {
+
+  public
+  @Rule
+  TestName name = new TestName();
+
+  private static final org.apache.logging.log4j.Logger logger = LogService.getLogger();
+
+  ServerSocket acceptor;
+  Socket server;
+
+  static ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+  private int randport = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+
+  @Before
+  public void setUp() throws Exception {
+    System.out.println("\n\n########## setup " + name.getMethodName() + " ############\n\n");
+    server = null;
+    acceptor = null;
+    baos.reset();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    System.out.println("\n\n########## teardown " + name.getMethodName() + " ############\n\n");
+
+    if (server != null) {
+      server.close();
+    }
+    if (acceptor != null) {
+      acceptor.close();
+    }
+    System.out.println(baos.toString());
+  }
+
+  //----- test methods ------
+
+  @Test
+  public void testSSLSocket() throws Exception {
+    final Object[] receiver = new Object[1];
+
+    TestAppender.create();
+
+    // Get original base log level
+    Level originalBaseLevel = LogService.getBaseLogLevel();
+    try {
+      // Set base log level to debug to log the SSL messages
+      LogService.setBaseLogLevel(Level.DEBUG);
+      {
+        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + MCAST_PORT, "0");
+        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_ENABLED, "true");
+        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_REQUIRE_AUTHENTICATION, "true");
+        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_CIPHERS, "any");
+        System.setProperty(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_PROTOCOLS, "TLSv1.2");
+
+        File jks = findTestJKS();
+        System.setProperty("javax.net.ssl.trustStore", jks.getCanonicalPath());
+        System.setProperty("javax.net.ssl.trustStorePassword", "password");
+        System.setProperty("javax.net.ssl.keyStore", jks.getCanonicalPath());
+        System.setProperty("javax.net.ssl.keyStorePassword", "password");
+      }
+
+      assertTrue(SocketCreatorFactory.getClusterSSLSocketCreator().useSSL());
+
+      final ServerSocket serverSocket = SocketCreatorFactory.getClusterSSLSocketCreator().createServerSocket(randport, 0, InetAddress.getByName("localhost"));
+
+      Thread serverThread = startServer(serverSocket, receiver);
+
+      Socket client = SocketCreatorFactory.getClusterSSLSocketCreator().connectForServer(InetAddress.getByName("localhost"), randport);
+
+      ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream());
+      String expected = new String("testing " + name.getMethodName());
+      oos.writeObject(expected);
+      oos.flush();
+
+      ThreadUtils.join(serverThread, 30 * 1000);
+
+      client.close();
+      serverSocket.close();
+      if (expected.equals(receiver[0])) {
+        System.out.println("received " + receiver[0] + " as expected.");
+      } else {
+        throw new Exception("Expected \"" + expected + "\" but received \"" + receiver[0] + "\"");
+      }
+
+      String logOutput = baos.toString();
+      StringReader sreader = new StringReader(logOutput);
+      LineNumberReader reader = new LineNumberReader(sreader);
+      int peerLogCount = 0;
+      String line = null;
+      while ((line = reader.readLine()) != null) {
+
+        if (line.matches(".*peer CN=.*")) {
+          System.out.println("Found peer log statement.");
+          peerLogCount++;
+        }
+      }
+      if (peerLogCount != 2) {
+        throw new Exception("Expected to find to peer identities logged.");
+      }
+    } finally {
+      // Reset original base log level
+      LogService.setBaseLogLevel(originalBaseLevel);
+      SocketCreatorFactory.close();
+    }
+  }
+
+  /**
+   * not actually related to this test class, but this is as good a place
+   * as any for this little test of the client-side ability to tell gemfire
+   * to use a given socket factory.  We just test the connectForClient method
+   * to see if it's used
+   */
+  @Test
+  public void testClientSocketFactory() {
+    System.getProperties().put(DistributionConfig.GEMFIRE_PREFIX + "clientSocketFactory", TSocketFactory.class.getName());
+    System.getProperties().remove(DistributionConfig.GEMFIRE_PREFIX + CLUSTER_SSL_ENABLED);
+    factoryInvoked = false;
+    try {
+      try {
+        Socket sock = SocketCreatorFactory.getClusterSSLSocketCreator().connectForClient("localhost", 12345, 0);
+        sock.close();
+        fail("socket factory was invoked");
+      } catch (IOException e) {
+        assertTrue("socket factory was not invoked: " + factoryInvoked, factoryInvoked);
+      }
+    } finally {
+      System.getProperties().remove(DistributionConfig.GEMFIRE_PREFIX + "clientSocketFactory");
+      SocketCreatorFactory.getClusterSSLSocketCreator().initializeClientSocketFactory();
+    }
+  }
+
+  static boolean factoryInvoked;
+
+  public static class TSocketFactory implements com.gemstone.gemfire.distributed.ClientSocketFactory {
+
+    public TSocketFactory() {
+    }
+
+    public Socket createSocket(InetAddress address, int port) throws IOException {
+      JSSESocketJUnitTest.factoryInvoked = true;
+      throw new IOException("splort!");
+    }
+  }
+
+  //------------- utilities -----
+
+  protected File findTestJKS() {
+    return new File(TestUtil.getResourcePath(getClass(), "/ssl/trusted.keystore"));
+  }
+
+  private Thread startServer(final ServerSocket serverSocket, final Object[] receiver) throws Exception {
+    Thread t = new Thread(new Runnable() {
+      public void run() {
+        try {
+          Socket s = serverSocket.accept();
+          SocketCreatorFactory.getClusterSSLSocketCreator().configureServerSSLSocket(s);
+          ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
+          receiver[0] = ois.readObject();
+          server = s;
+          acceptor = serverSocket;
+        } catch (Exception e) {
+          e.printStackTrace();
+          receiver[0] = e;
+        }
+      }
+    }, name.getMethodName() + "-server");
+    t.start();
+    return t;
+  }
+
+  public static final class TestAppender extends AbstractAppender {
+
+    private static final String APPENDER_NAME = TestAppender.class.getName();
+    private final static String SOCKET_CREATOR_CLASSNAME = SocketCreator.class.getName();
+
+    private TestAppender() {
+      super(APPENDER_NAME, null, PatternLayout.createDefaultLayout());
+      start();
+    }
+
+    public static Appender create() {
+      Appender appender = new TestAppender();
+      Logger socketCreatorLogger = (Logger) LogManager.getLogger(SOCKET_CREATOR_CLASSNAME);
+      LoggerConfig config = socketCreatorLogger.getContext().getConfiguration().getLoggerConfig(SOCKET_CREATOR_CLASSNAME);
+      config.addAppender(appender, Level.DEBUG, null);
+      return appender;
+    }
+
+    @SuppressWarnings("synthetic-access")
+    @Override
+    public void append(final LogEvent event) {
+      try {
+        baos.write(new String(event.getMessage().getFormattedMessage() + "\n").getBytes());
+      } catch (IOException ioex) {
+        logger.warn(ioex);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserJUnitTest.java
new file mode 100644
index 0000000..2063063
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserJUnitTest.java
@@ -0,0 +1,194 @@
+/*
+ * 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 com.gemstone.gemfire.internal.net;
+
+import static org.junit.Assert.*;
+
+import java.net.Socket;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.net.SocketCloser;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+/**
+ * Tests the default SocketCloser.
+ */
+@Category(UnitTest.class)
+public class SocketCloserJUnitTest {
+
+  private SocketCloser socketCloser;
+  
+  @Before
+  public void setUp() throws Exception {
+    this.socketCloser = createSocketCloser();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    this.socketCloser.close();
+  }
+  
+  private Socket createClosableSocket() {
+    return new Socket();
+  }
+
+  protected SocketCloser createSocketCloser() {
+    return new SocketCloser();
+  }
+  
+  /**
+   * Test that close requests are async.
+   */
+  @Test
+  public void testAsync() {
+    final CountDownLatch cdl = new CountDownLatch(1);
+    final AtomicInteger waitingToClose = new AtomicInteger(0);
+    Runnable r = new Runnable() {
+      @Override
+      public void run() {
+        try {
+          waitingToClose.incrementAndGet();
+          cdl.await();
+        } catch (InterruptedException e) {
+        }
+      }
+    };
+    
+    final int SOCKET_COUNT = 100;
+    final Socket[] aSockets = new Socket[SOCKET_COUNT];
+    for (int i=0; i < SOCKET_COUNT; i++) {
+      aSockets[i] = createClosableSocket();
+    }
+    // Schedule a 100 sockets for async close.
+    // They should all be stuck on cdl.
+    for (int i=0; i < SOCKET_COUNT; i++) {
+      this.socketCloser.asyncClose(aSockets[i], "A", r);
+    }
+    // Make sure the sockets have not been closed
+    for (int i=0; i < SOCKET_COUNT; i++) {
+      assertEquals(false, aSockets[i].isClosed());
+    }
+    final Socket[] bSockets = new Socket[SOCKET_COUNT];
+    for (int i=0; i < SOCKET_COUNT; i++) {
+      bSockets[i] = createClosableSocket();
+    }
+    // Schedule a 100 sockets for async close.
+    // They should all be stuck on cdl.
+    for (int i=0; i < SOCKET_COUNT; i++) {
+      this.socketCloser.asyncClose(bSockets[i], "B", r);
+    }
+    // Make sure the sockets have not been closed
+    for (int i=0; i < SOCKET_COUNT; i++) {
+      assertEquals(false, bSockets[i].isClosed());
+    }
+    // close the socketCloser first to verify that the sockets
+    // that have already been scheduled will be still be closed.
+    this.socketCloser.releaseResourcesForAddress("A");
+    this.socketCloser.close();
+    // Each thread pool (one for A and one for B) has a max of 8 threads.
+    // So verify that this many are currently waiting on cdl.
+    {
+      final int maxThreads = this.socketCloser.getMaxThreads();
+      WaitCriterion wc = new WaitCriterion() {
+        public boolean done() {
+          return waitingToClose.get() == 2*maxThreads;
+        }
+        public String description() {
+          return "expected " + 2*maxThreads + " waiters but found only " + waitingToClose.get();
+        }
+      };
+      Wait.waitForCriterion(wc, 5000, 10, true);
+    }
+    // now count down the latch that allows the sockets to close
+    cdl.countDown();
+    // now all the sockets should get closed; use a wait criteria
+    // since a thread pool is doing to closes
+    {
+      WaitCriterion wc = new WaitCriterion() {
+        public boolean done() {
+          for (int i=0; i < SOCKET_COUNT; i++) {
+            if (!aSockets[i].isClosed() || !bSockets[i].isClosed()) {
+              return false;
+            }
+          }
+          return true;
+        }
+        public String description() {
+          return "one or more sockets did not close";
+        }
+      };
+      Wait.waitForCriterion(wc, 5000, 10, true);
+    }
+  }
+  
+  /**
+   * Verify that requesting an asyncClose on an already
+   * closed socket is a noop.
+   */
+  @Test
+  public void testClosedSocket() throws Exception {
+    final AtomicBoolean runnableCalled = new AtomicBoolean();
+    Runnable r = new Runnable() {
+      @Override
+      public void run() {
+        runnableCalled.set(true);
+      }
+    };
+    
+    Socket s = createClosableSocket();
+    s.close();
+    this.socketCloser.asyncClose(s, "A", r);
+    Wait.pause(10);
+    assertEquals(false, runnableCalled.get());
+  }
+  
+  /**
+   * Verify that a closed SocketCloser will still close an open socket
+   */
+  @Test
+  public void testClosedSocketCloser() {
+    final AtomicBoolean runnableCalled = new AtomicBoolean();
+    Runnable r = new Runnable() {
+      @Override
+      public void run() {
+        runnableCalled.set(true);
+      }
+    };
+    
+    final Socket s = createClosableSocket();
+    this.socketCloser.close();
+    this.socketCloser.asyncClose(s, "A", r);
+    WaitCriterion wc = new WaitCriterion() {
+      public boolean done() {
+        return runnableCalled.get() && s.isClosed(); 
+      }
+      public String description() {
+        return "runnable was not called or socket was not closed";
+      }
+    };
+    Wait.waitForCriterion(wc, 5000, 10, true);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5ed7a6c/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserWithWaitJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserWithWaitJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserWithWaitJUnitTest.java
new file mode 100644
index 0000000..82e7bdc
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SocketCloserWithWaitJUnitTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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 com.gemstone.gemfire.internal.net;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+/**
+ * Tests SocketCloser with a wait time. The default SocketCloser does not wait.
+ * This test configures a closer much like the one used by CacheClientNotifier.
+ */
+@Category(UnitTest.class)
+public class SocketCloserWithWaitJUnitTest extends SocketCloserJUnitTest {
+
+  @Override
+  protected SocketCloser createSocketCloser() {
+    return new SocketCloser(
+        SocketCloser.ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS,
+        1, // max threads
+        1, TimeUnit.NANOSECONDS);
+  }
+}


Mime
View raw message