Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1372 d6fb78341 -> 667c4259f


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6a73441/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
index 3a06c1c..701cc07 100755
--- 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -109,6 +109,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
       system = null;
     }
   }
+  
+  //for child classes 
+  protected void addDSProps(Properties p) {
+    
+  }
 
   ////////  Test Methods
 
@@ -120,7 +125,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
    * it hung with the restarted locator trying to become elder again because
    * it put its address at the beginning of the new view it sent out.
    */
-  public void testCollocatedLocatorWithSecurity() throws Exception {
+  public void ntestCollocatedLocatorWithSecurity() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm1 = host.getVM(1);
@@ -139,6 +144,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("security-peer-authenticator", 
"com.gemstone.gemfire.distributed.MyAuthenticator.create");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
     properties.put(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "false");
+    addDSProps(properties);
     system = (InternalDistributedSystem) DistributedSystem.connect(properties);
     InternalDistributedMember mbr = system.getDistributedMember();
     assertEquals("expected the VM to have NORMAL vmKind",
@@ -249,7 +255,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
    *
    * @throws Exception
    */
-  public void testStartTwoLocators() throws Exception {
+  public void ntestStartTwoLocators() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM loc1 = host.getVM(1);
@@ -273,7 +279,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("member-timeout", "2000");
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    addDSProps(properties);
     SerializableCallable startLocator1 = new SerializableCallable("start 
locator1") {
       @Override
       public Object call() throws Exception {
@@ -362,7 +368,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
   /**
    * test lead member selection
    */
-  public void testLeadMemberSelection() throws Exception {
+  public void ntestLeadMemberSelection() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm1 = host.getVM(1);
@@ -377,7 +383,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("locators", locators);
     properties.put("enable-network-partition-detection", "true");
     properties.put("disable-auto-reconnect", "true");
-
+    addDSProps(properties);
     File logFile = new File("");
     if (logFile.exists()) {
       logFile.delete();
@@ -471,7 +477,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
    * We then kill the lead member and demonstrate that the original locator
    * (which is now the sole remaining member) shuts itself down.
    */
-  public void testLeadAndCoordFailure() throws Exception {
+  public void ntestLeadAndCoordFailure() throws Exception {
     IgnoredException.addIgnoredException("Possible loss of quorum due");
     disconnectAllFromDS();
     Host host = Host.getHost(0);
@@ -497,7 +503,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
     //    properties.put("log-level", "fine");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    addDSProps(properties);
     try {
       final String uname = getUniqueName();
       File logFile = new File("");
@@ -604,7 +610,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
    * We then shut down the group coordinator and observe the second locator
    * pick up the job and the remaining member continues to operate normally.
    */
-  public void testLeadFailureAndCoordShutdown() throws Exception {
+  public void ntestLeadFailureAndCoordShutdown() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm1 = host.getVM(1);
@@ -628,7 +634,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("disable-auto-reconnect", "true");
     properties.put("member-timeout", "2000");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    addDSProps(properties);
     SerializableRunnable stopLocator = getStopLocatorRunnable();
 
     try {
@@ -750,7 +756,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
    */
   // disabled on trunk - should be reenabled on cedar_dev_Oct12
   // this test leaves a CloserThread around forever that logs "pausing" 
messages every 500 ms
-  public void testForceDisconnectAndPeerShutdownCause() throws Exception {
+  public void ntestForceDisconnectAndPeerShutdownCause() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm1 = host.getVM(1);
@@ -774,7 +780,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("member-timeout", "2000");
     properties.put("log-level", LogWriterUtils.getDUnitLogLevel());
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    addDSProps(properties);
     SerializableRunnable stopLocator = getStopLocatorRunnable();
 
     try {
@@ -887,7 +893,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
    * We kill the coordinator and shut down the lead member and observe the 
second locator
    * pick up the job and the remaining member continue to operate normally.
    */
-  public void testLeadShutdownAndCoordFailure() throws Exception {
+  public void ntestLeadShutdownAndCoordFailure() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm1 = host.getVM(1);
@@ -910,7 +916,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
     properties.put("disable-auto-reconnect", "true");
     properties.put("member-timeout", "2000");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    addDSProps(properties);
     SerializableRunnable disconnect =
         new SerializableRunnable("Disconnect from " + locators) {
           public void run() {
@@ -1012,7 +1018,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
    * Tests that attempting to connect to a distributed system in which
    * no locator is defined throws an exception.
    */
-  public void testNoLocator() {
+  public void ntestNoLocator() {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     int port =
@@ -1022,7 +1028,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
     Properties props = new Properties();
     props.setProperty("mcast-port", "0");
     props.setProperty("locators", locators);
-
+    addDSProps(props);
     final String expected = "java.net.ConnectException";
     final String addExpected =
         "<ExpectedException action=add>" + expected + "</ExpectedException>";
@@ -1072,7 +1078,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
    * <p>The locator is then restarted and is shown to take over the
    * role of membership coordinator.
    */
-  public void testOneLocator() throws Exception {
+  public void ntestOneLocator() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
@@ -1093,7 +1099,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
           locProps.setProperty("mcast-port", "0");
           locProps.setProperty("member-timeout", "1000");
           locProps.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+          addDSProps(locProps);  
           Locator.startLocatorAndDS(port, logFile, locProps);
         } catch (IOException ex) {
           com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator 
on port " + port, ex);
@@ -1110,6 +1116,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
               props.setProperty("mcast-port", "0");
               props.setProperty("locators", locators);
               props.setProperty("member-timeout", "1000");
+              addDSProps(props);
               DistributedSystem.connect(props);
             }
           };
@@ -1120,7 +1127,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
       props.setProperty("mcast-port", "0");
       props.setProperty("locators", locators);
       props.setProperty("member-timeout", "1000");
-
+      addDSProps(props);
       system = (InternalDistributedSystem) DistributedSystem.connect(props);
 
       final DistributedMember coord = 
MembershipManagerHelper.getCoordinator(system);
@@ -1164,7 +1171,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
    * is correct.  It then restarts the locator to demonstrate that
    * it can connect to and function as the group coordinator
    */
-  public void testLocatorBecomesCoordinator() throws Exception {
+  public void ntestLocatorBecomesCoordinator() throws Exception {
     disconnectAllFromDS();
     final String expected = "java.net.ConnectException";
     final String addExpected =
@@ -1189,7 +1196,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
       props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
       
props.setProperty(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, 
"true");
       props.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-
+      addDSProps(props);
       SerializableRunnable connect =
           new SerializableRunnable("Connect to " + locators) {
             public void run() {
@@ -1301,7 +1308,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
   /**
    * Tests starting multiple locators in multiple VMs.
    */
-  public void testMultipleLocators() throws Exception {
+  public void ntestMultipleLocators() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
@@ -1323,7 +1330,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
     dsProps.setProperty("locators", locators);
     dsProps.setProperty("mcast-port", "0");
     dsProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    addDSProps(dsProps);
     vm0.invoke(new SerializableRunnable("Start locator on " + port1) {
       public void run() {
         File logFile = new File("");
@@ -1357,6 +1364,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
                 Properties props = new Properties();
                 props.setProperty("mcast-port", "0");
                 props.setProperty("locators", locators);
+                addDSProps(props);
                 DistributedSystem.connect(props);
               }
             };
@@ -1366,7 +1374,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
         Properties props = new Properties();
         props.setProperty("mcast-port", "0");
         props.setProperty("locators", locators);
-
+        addDSProps(props);
         system = (InternalDistributedSystem) DistributedSystem.connect(props);
 
         WaitCriterion ev = new WaitCriterion() {
@@ -1417,7 +1425,6 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
    * end up only have 1 master.
    * GEODE-870
    */
-  @Category(FlakyTest.class) // GEODE-1150: random ports, disk pollution, 
waitForCriterion, time sensitive, eats exceptions (fixed several)
   public void testMultipleLocatorsRestartingAtSameTime() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
@@ -1441,8 +1448,8 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
     dsProps.setProperty(DistributionConfig.LOCATORS_NAME, locators);
     dsProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, 
LogWriterUtils.getDUnitLogLevel());
     
dsProps.setProperty(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, 
"true");
-    dsProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+    dsProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");    
+    addDSProps(dsProps);
     startLocatorSync(vm0, new Object[] { port1, dsProps });
     startLocatorSync(vm1, new Object[] { port2, dsProps });
     startLocatorSync(vm2, new Object[] { port3, dsProps });
@@ -1620,7 +1627,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
   /**
    * Tests starting multiple locators in multiple VMs.
    */
-  public void testMultipleMcastLocators() throws Exception {
+  public void ntestMultipleMcastLocators() throws Exception {
     disconnectAllFromDS();
     IgnoredException.addIgnoredException("Could not stop  Distribution 
Locator"); // shutdown timing issue in InternalLocator
     Host host = Host.getHost(0);
@@ -1653,7 +1660,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
           props.setProperty("mcast-ttl", "0");
           props.setProperty("enable-network-partition-detection", "true");
           
props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
-
+          addDSProps(props);
           Locator.startLocatorAndDS(port1, logFile, null, props);
         } catch (IOException ex) {
           com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator 
on port " + port1, ex);
@@ -1671,6 +1678,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
           props.setProperty("mcast-ttl", "0");
           props.setProperty("enable-network-partition-detection", "true");
           
props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
+          addDSProps(props);
           Locator.startLocatorAndDS(port2, logFile, null, props);
         } catch (IOException ex) {
           com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator 
on port " + port2, ex);
@@ -1687,6 +1695,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
             props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
             props.setProperty("mcast-ttl", "0");
             props.setProperty("enable-network-partition-detection", "true");
+            addDSProps(props);
             DistributedSystem.connect(props);
           }
         };
@@ -1700,7 +1709,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
       props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
       props.setProperty("mcast-ttl", "0");
       props.setProperty("enable-network-partition-detection", "true");
-
+      addDSProps(props);
       system = (InternalDistributedSystem) DistributedSystem.connect(props);
       WaitCriterion ev = new WaitCriterion() {
         public boolean done() {
@@ -1735,7 +1744,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
    * Tests that a VM can connect to a locator that is hosted in its
    * own VM.
    */
-  public void testConnectToOwnLocator() throws Exception {
+  public void ntestConnectToOwnLocator() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
 
@@ -1752,6 +1761,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
       props.setProperty("mcast-port", "0");
       props.setProperty("locators", locators);
       props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
+      addDSProps(props);
       system = (InternalDistributedSystem) DistributedSystem.connect(props);
       system.disconnect();
     } finally {
@@ -1762,7 +1772,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
   /**
    * Tests that a single VM can NOT host multiple locators
    */
-  public void testHostingMultipleLocators() throws Exception {
+  public void ntestHostingMultipleLocators() throws Exception {
     disconnectAllFromDS();
     Host host = Host.getHost(0);
     //VM vm = host.getVM(0);
@@ -1797,6 +1807,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
               props.setProperty("mcast-port", "0");
               props.setProperty("locators", locators);
               props.setProperty("log-level", 
LogWriterUtils.getDUnitLogLevel());
+              addDSProps(props);
               DistributedSystem.connect(props);
             }
           };
@@ -1819,7 +1830,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
    *
    * @since 4.1
    */
-  public void testRestartLocator() throws Exception {
+  public void ntestRestartLocator() throws Exception {
     disconnectAllFromDS();
     port1 =
         AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
@@ -1831,6 +1842,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
     p.setProperty(DistributionConfig.LOCATORS_NAME, 
Host.getHost(0).getHostName() + "[" + port1 + "]");
     p.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
     p.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, 
"false");
+    addDSProps(p);
     if (stateFile.exists()) {
       stateFile.delete();
     }
@@ -1916,6 +1928,7 @@ public class LocatorDUnitTest extends DistributedTestCase 
{
           Properties locProps = new Properties();
           locProps.put("mcast-port", "0");
           locProps.put("log-level", LogWriterUtils.getDUnitLogLevel());
+          addDSProps(locProps);
           Locator.startLocatorAndDS(port, logFile, locProps);
         } catch (IOException ex) {
           com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator 
on port " + port, ex);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6a73441/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
new file mode 100755
index 0000000..37f14c3
--- /dev/null
+++ 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
@@ -0,0 +1,28 @@
+package com.gemstone.gemfire.distributed;
+
+import java.util.Properties;
+
+import org.junit.Test;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+
+public class LocatorUDPSecurityDUnitTest extends LocatorDUnitTest{
+
+  public LocatorUDPSecurityDUnitTest(String name) {
+    super(name);
+  }
+  
+  @Test
+  public void testLoop() throws Exception {
+    for(int i=0; i < 2; i++) {
+      testMultipleLocatorsRestartingAtSameTime();
+      tearDown();
+      setUp();
+    }
+  }
+  
+  @Override
+  protected void addDSProps(Properties p) {
+    p.setProperty(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6a73441/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index 1e1724d..0d3b9fc 100755
--- 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -190,7 +190,7 @@ public class GMSJoinLeaveJUnitTest {
     
     // simulate a response being received
     InternalDistributedMember sender = mockMembers[2];
-    FindCoordinatorResponse resp = new FindCoordinatorResponse(coordinator, 
sender);
+    FindCoordinatorResponse resp = new FindCoordinatorResponse(coordinator, 
sender, null, 0);
     gmsJoinLeave.processMessage(resp);
     // tell GMSJoinLeave that a unit test is running so it won't clear the
     // responses collection
@@ -207,7 +207,7 @@ public class GMSJoinLeaveJUnitTest {
   public void testProcessJoinMessageRejectOldMemberVersion() throws 
IOException {
     initMocks();
  
-    gmsJoinLeave.processMessage(new JoinRequestMessage(mockOldMember, 
mockOldMember, null, -1));
+    gmsJoinLeave.processMessage(new JoinRequestMessage(mockOldMember, 
mockOldMember, null, -1, 0));
     assertTrue("JoinRequest should not have been added to view request", 
gmsJoinLeave.getViewRequests().size() == 0);
     verify(messenger).send(any(JoinResponseMessage.class));
   }
@@ -230,7 +230,7 @@ public class GMSJoinLeaveJUnitTest {
     when(authenticator.authenticate(mockMembers[0], 
credentials)).thenThrow(new AuthenticationFailedException("we want to fail auth 
here"));
     when(services.getMessenger()).thenReturn(messenger);
          
-    gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], 
mockMembers[0], credentials, -1));
+    gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], 
mockMembers[0], credentials, -1, 0));
     assertTrue("JoinRequest should not have been added to view request", 
gmsJoinLeave.getViewRequests().size() == 0);
     verify(messenger).send(any(JoinResponseMessage.class));
   }
@@ -242,7 +242,7 @@ public class GMSJoinLeaveJUnitTest {
     when(authenticator.authenticate(mockMembers[0], null)).thenThrow(new 
AuthenticationFailedException("we want to fail auth here"));
     when(services.getMessenger()).thenReturn(messenger);
       
-    gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], 
mockMembers[0], null, -1));
+    gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], 
mockMembers[0], null, -1, 0));
     assertTrue("JoinRequest should not have been added to view request", 
gmsJoinLeave.getViewRequests().size() == 0);
     verify(messenger).send(any(JoinResponseMessage.class));
   }
@@ -257,9 +257,22 @@ public class GMSJoinLeaveJUnitTest {
       
     JoinResponseMessage[] joinResponse = gmsJoinLeave.getJoinResponseMessage();
     
-    JoinResponseMessage jrm = new JoinResponseMessage();
+    JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], new 
byte[9], 233);
     gmsJoinLeave.processMessage(jrm);
+    //this should NOT logs, this is just to inform member succesful joining
+    Assert.assertEquals(null, joinResponse[0]);
+    
+    jrm = new JoinResponseMessage("rejected...", 0);
+    gmsJoinLeave.processMessage(jrm);
+    //this should log..
     Assert.assertEquals(jrm, joinResponse[0]);
+    
+    gmsJoinLeave.setJoinResponseMessage(null);
+    
+    jrm = new JoinResponseMessage(mockMembers[0], new NetView(), 0);
+    gmsJoinLeave.processMessage(jrm);
+    //this should log..
+    Assert.assertEquals(jrm, joinResponse[0]);       
   }
   
   /**
@@ -475,10 +488,10 @@ public class GMSJoinLeaveJUnitTest {
     prepareAndInstallView(gmsJoinLeaveMemberId, 
createMemberList(gmsJoinLeaveMemberId,mockMembers[0]));
     gmsJoinLeave.getView().add(mockMembers[1]);
     GMSJoinLeaveTestHelper.becomeCoordinatorForTest(gmsJoinLeave);
-    JoinRequestMessage msg = new JoinRequestMessage(gmsJoinLeaveMemberId, 
mockMembers[2], null, -1);
+    JoinRequestMessage msg = new JoinRequestMessage(gmsJoinLeaveMemberId, 
mockMembers[2], null, -1, 0);
     msg.setSender(mockMembers[2]);
     gmsJoinLeave.processMessage(msg);
-    msg = new JoinRequestMessage(gmsJoinLeaveMemberId, mockMembers[2], null, 
-1);
+    msg = new JoinRequestMessage(gmsJoinLeaveMemberId, mockMembers[2], null, 
-1, 0);
     msg.setSender(mockMembers[2]);
     gmsJoinLeave.processMessage(msg);
     
@@ -872,7 +885,7 @@ public class GMSJoinLeaveJUnitTest {
     initMocks(false);
     System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
     gmsJoinLeave.join();
-    gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], 
mockMembers[0], credentials, -1));
+    gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], 
mockMembers[0], credentials, -1, 0));
     int viewRequests = gmsJoinLeave.getViewRequests().size();
     
     assertTrue( "There should be 1 viewRequest but found " + viewRequests, 
viewRequests == 1);
@@ -1072,13 +1085,13 @@ public class GMSJoinLeaveJUnitTest {
       initMocks(false);
       HashSet<InternalDistributedMember> registrants = new HashSet<>();
       registrants.add(mockMembers[0]);
-      FindCoordinatorResponse fcr = new 
FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, null, 
registrants, false, true);
+      FindCoordinatorResponse fcr = new 
FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, null, 
registrants, false, true, null);
       NetView view = createView();
-      JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view);
+      JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view, 
0);
       
       TcpClientWrapper tcpClientWrapper = mock(TcpClientWrapper.class);
       gmsJoinLeave.setTcpClientWrapper(tcpClientWrapper);
-      FindCoordinatorRequest fcreq = new 
FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1);
+      FindCoordinatorRequest fcreq = new 
FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1, null, 0);
       int connectTimeout = (int)services.getConfig().getMemberTimeout() * 2;
       when(tcpClientWrapper.sendCoordinatorFindRequest(new 
InetSocketAddress("localhost", 12345), fcreq, connectTimeout)).thenReturn(fcr);
       callAsnyc(()->{gmsJoinLeave.installView(view);});
@@ -1099,14 +1112,14 @@ public class GMSJoinLeaveJUnitTest {
       initMocks(false);
       HashSet<InternalDistributedMember> registrants = new HashSet<>();
       registrants.add(mockMembers[0]);
-      FindCoordinatorResponse fcr = new 
FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, null, 
registrants, false, true);
+      FindCoordinatorResponse fcr = new 
FindCoordinatorResponse(mockMembers[0], mockMembers[0], false, null, 
registrants, false, true, null);
       NetView view = createView();
-      JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view);
+      JoinResponseMessage jrm = new JoinResponseMessage(mockMembers[0], view, 
0);
       gmsJoinLeave.setJoinResponseMessage(jrm);
       
       TcpClientWrapper tcpClientWrapper = mock(TcpClientWrapper.class);
       gmsJoinLeave.setTcpClientWrapper(tcpClientWrapper);
-      FindCoordinatorRequest fcreq = new 
FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1);
+      FindCoordinatorRequest fcreq = new 
FindCoordinatorRequest(gmsJoinLeaveMemberId, new HashSet<>(), -1, null, 0);
       int connectTimeout = (int)services.getConfig().getMemberTimeout() * 2;
       //passing wrong port here, so ot will fail
       when(tcpClientWrapper.sendCoordinatorFindRequest(new 
InetSocketAddress("localhost", 12346), fcreq, connectTimeout)).thenReturn(fcr);
@@ -1224,7 +1237,7 @@ public class GMSJoinLeaveJUnitTest {
   }
   
   private void processJoinMessage(InternalDistributedMember coordinator, 
InternalDistributedMember newMember, int port) {
-    JoinRequestMessage reqMsg = new JoinRequestMessage(coordinator, newMember, 
null, port);
+    JoinRequestMessage reqMsg = new JoinRequestMessage(coordinator, newMember, 
null, port, 0);
     gmsJoinLeave.processMessage(reqMsg);
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6a73441/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
index 3a08faa..1d7b8d0 100755
--- 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
+++ 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/GMSEncryptJUnitTest.java
@@ -158,7 +158,7 @@ public class GMSEncryptJUnitTest {
     initMocks();
 
     GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this 
will be the sender
-    gmsEncrypt1.addClusterKey();
+    gmsEncrypt1.initClusterSecretKey();
     // establish the public keys for the sender and receiver
     netView.setPublicKey(mockMembers[1], gmsEncrypt1.getPublicKeyBytes());
     
@@ -182,7 +182,7 @@ public class GMSEncryptJUnitTest {
     initMocks();
 
     GMSEncrypt gmsEncrypt1 = new GMSEncrypt(services, mockMembers[1]); // this 
will be the sender
-    gmsEncrypt1.addClusterKey();
+    gmsEncrypt1.initClusterSecretKey();
     GMSEncrypt gmsEncrypt2 = new GMSEncrypt(services, mockMembers[2]); // this 
will be the sender
     
     // establish the public keys for the sender and receiver
@@ -191,7 +191,7 @@ public class GMSEncryptJUnitTest {
     
     gmsEncrypt1.installView(netView, mockMembers[1]);
     
-    byte[] secretBytes = gmsEncrypt1.getSecretBytes();
+    byte[] secretBytes = gmsEncrypt1.getClusterSecretKey();
     gmsEncrypt2.addClusterKey(secretBytes);
     
     gmsEncrypt2.installView(netView, mockMembers[1]);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b6a73441/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index 60e790b..14a0df1 100755
--- 
a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ 
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -69,6 +70,9 @@ import 
com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Healt
 import 
com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.JoinLeave;
 import 
com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Manager;
 import 
com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.MessageHandler;
+import 
com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorRequest;
+import 
com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorResponse;
+import 
com.gemstone.gemfire.distributed.internal.membership.gms.messages.InstallViewMessage;
 import 
com.gemstone.gemfire.distributed.internal.membership.gms.messages.JoinRequestMessage;
 import 
com.gemstone.gemfire.distributed.internal.membership.gms.messages.JoinResponseMessage;
 import 
com.gemstone.gemfire.distributed.internal.membership.gms.messages.LeaveRequestMessage;
@@ -96,10 +100,14 @@ public class JGroupsMessengerJUnitTest {
   private InterceptUDP interceptor;
   private long statsId = 123;
 
+  private void initMocks(boolean enableMcast) throws Exception {
+    initMocks(enableMcast, new Properties());
+  }
+  
   /**
    * Create stub and mock objects
    */
-  private void initMocks(boolean enableMcast) throws Exception {
+  private void initMocks(boolean enableMcast, Properties addProp) throws 
Exception {
     if (messenger != null) {
       messenger.stop();
       messenger = null;
@@ -112,6 +120,7 @@ public class JGroupsMessengerJUnitTest {
     nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
     nonDefault.put(DistributionConfig.LOCATORS_NAME, "localhost[10344]");
     nonDefault.put(DistributionConfig.ACK_WAIT_THRESHOLD_NAME, "1");
+    nonDefault.putAll(addProp);
     DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
     RemoteTransportConfig tconfig = new RemoteTransportConfig(config,
         DistributionManager.NORMAL_DM_TYPE);
@@ -134,6 +143,7 @@ public class JGroupsMessengerJUnitTest {
     when(services.getHealthMonitor()).thenReturn(healthMonitor);
     when(services.getManager()).thenReturn(manager);
     when(services.getJoinLeave()).thenReturn(joinLeave);
+    
     DM dm = mock(DM.class);
     InternalDistributedSystem system = 
InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
     when(services.getStatistics()).thenReturn(new DistributionStats(system, 
statsId));
@@ -141,6 +151,9 @@ public class JGroupsMessengerJUnitTest {
     messenger = new JGroupsMessenger();
     messenger.init(services);
     
+    //if I do this earlier then test this return messenger as null
+    when(services.getMessenger()).thenReturn(messenger);
+    
     String jgroupsConfig = messenger.getJGroupsStackConfig();
     int startIdx = jgroupsConfig.indexOf("<com");
     int insertIdx = jgroupsConfig.indexOf('>', startIdx+4) + 1;
@@ -429,15 +442,15 @@ public class JGroupsMessengerJUnitTest {
     when(joinLeave.getView()).thenReturn(v);
 
     InternalDistributedMember sender = createAddress(8888);
-    JoinRequestMessage msg = new JoinRequestMessage(messenger.localAddress, 
sender, null, -1);
+    JoinRequestMessage msg = new JoinRequestMessage(messenger.localAddress, 
sender, null, -1, 0);
     
-    Message jmsg = messenger.createJGMessage(msg, messenger.jgAddress, null, 
Version.CURRENT_ORDINAL);
+    Message jmsg = messenger.createJGMessage(msg, messenger.jgAddress, 
Version.CURRENT_ORDINAL);
     interceptor.up(new Event(Event.MSG, jmsg));
     
     verify(mh, times(1)).processMessage(any(JoinRequestMessage.class));
     
     LeaveRequestMessage lmsg = new LeaveRequestMessage(messenger.localAddress, 
sender, "testing");
-    jmsg = messenger.createJGMessage(lmsg, messenger.jgAddress, null, 
Version.CURRENT_ORDINAL);
+    jmsg = messenger.createJGMessage(lmsg, messenger.jgAddress, 
Version.CURRENT_ORDINAL);
     interceptor.up(new Event(Event.MSG, jmsg));
     
     verify(manager).processMessage(any(LeaveRequestMessage.class));
@@ -469,7 +482,7 @@ public class JGroupsMessengerJUnitTest {
     NetView v = new NetView(sender);
     when(joinLeave.getView()).thenReturn(v);
     messenger.installView(v);
-    JoinRequestMessage msg = new JoinRequestMessage(messenger.localAddress, 
sender, null, -1);
+    JoinRequestMessage msg = new JoinRequestMessage(messenger.localAddress, 
sender, null, -1, 0);
     if (mcastMsg) {
       msg.setMulticast(true);
     }
@@ -481,7 +494,7 @@ public class JGroupsMessengerJUnitTest {
         sentMessages == 1);
 
     // send a big message and expect fragmentation
-    msg = new JoinRequestMessage(messenger.localAddress, sender, new 
byte[(int)(services.getConfig().getDistributionConfig().getUdpFragmentSize()*(1.5))],
 -1);
+    msg = new JoinRequestMessage(messenger.localAddress, sender, new 
byte[(int)(services.getConfig().getDistributionConfig().getUdpFragmentSize()*(1.5))],
 -1, 0);
 
     // configure an incoming message handler for JoinRequestMessage
     final DistributionMessage[] messageReceived = new DistributionMessage[1];
@@ -697,7 +710,7 @@ public class JGroupsMessengerJUnitTest {
     NetView view = new NetView(mbr);
     
     // the digest should be set in an outgoing join response
-    JoinResponseMessage joinResponse = new JoinResponseMessage(mbr, view);
+    JoinResponseMessage joinResponse = new JoinResponseMessage(mbr, view, 0);
     messenger.filterOutgoingMessage(joinResponse);
     assertNotNull(joinResponse.getMessengerData());
     
@@ -709,7 +722,7 @@ public class JGroupsMessengerJUnitTest {
     assertNull(joinResponse.getMessengerData());
     
     // the digest shouldn't be set in an outgoing rejection message
-    joinResponse = new JoinResponseMessage("you can't join my distributed 
system.  nyah nyah nyah!");
+    joinResponse = new JoinResponseMessage("you can't join my distributed 
system.  nyah nyah nyah!", 0);
     messenger.filterOutgoingMessage(joinResponse);
     assertNull(joinResponse.getMessengerData());
     
@@ -805,7 +818,7 @@ public class JGroupsMessengerJUnitTest {
       dmsg.setRecipients(recipients);
   
       // a message is ignored during manager shutdown
-      msg = messenger.createJGMessage(dmsg, new JGAddress(other), null, 
Version.CURRENT_ORDINAL);
+      msg = messenger.createJGMessage(dmsg, new JGAddress(other), 
Version.CURRENT_ORDINAL);
       when(manager.shutdownInProgress()).thenReturn(Boolean.TRUE);
       receiver.receive(msg);
       verify(manager, never()).processMessage(isA(DistributionMessage.class));
@@ -896,6 +909,174 @@ public class JGroupsMessengerJUnitTest {
     
assertFalse(AvailablePort.isPortAvailable(services.getConfig().getDistributionConfig().getMcastPort(),
 AvailablePort.MULTICAST));
   }
   
+  private NetView createView(InternalDistributedMember otherMbr) {
+    InternalDistributedMember sender = messenger.getMemberID();
+    List<InternalDistributedMember> mbrs = new ArrayList<>();
+    mbrs.add(sender);
+    mbrs.add(otherMbr);
+    NetView v = new NetView(sender, 1, mbrs);
+    return v;
+  }
+  
+  @Test
+  public void testEncryptedFindCoordinatorRequest() throws Exception{
+    InternalDistributedMember otherMbr = new 
InternalDistributedMember("localhost", 8888);
+    
+    Properties p = new Properties();    
+    p.put(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+    initMocks(false, p);
+    
+    NetView v = createView(otherMbr);
+    
+    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
+    
+    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
+    messenger.initClusterKey();
+    
+    FindCoordinatorRequest gfmsg = new 
FindCoordinatorRequest(messenger.getMemberID(), new 
ArrayList<InternalDistributedMember>(2), 1, 
messenger.getPublickey(messenger.getMemberID()), 1);
+    Set<InternalDistributedMember> recipients = new HashSet<>();
+    recipients.add(otherMbr);
+    gfmsg.setRecipients(recipients);
+    
+    short version = Version.CURRENT_ORDINAL;
+    
+    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
+    
+    messenger.writeEncryptedMessage(gfmsg, version, out);
+    
+    byte[] requestBytes = out.toByteArray();
+    
+    DataInputStream dis = new DataInputStream(new 
ByteArrayInputStream(requestBytes));
+    
+    DistributionMessage distributionMessage = 
messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
+    
+    assertEquals(gfmsg, distributionMessage);
+  }
+  
+  @Test
+  public void testEncryptedFindCoordinatorResponse() throws Exception{
+    InternalDistributedMember otherMbr = new 
InternalDistributedMember("localhost", 8888);
+    
+    Properties p = new Properties();    
+    p.put(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+    initMocks(false, p);
+    
+    NetView v = createView(otherMbr);
+    
+    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
+    
otherMbrEncrptor.setPublicKey(messenger.getPublickey(messenger.getMemberID()), 
messenger.getMemberID());
+    
+    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
+    messenger.initClusterKey();
+    
+    FindCoordinatorResponse gfmsg = new 
FindCoordinatorResponse(messenger.getMemberID(), messenger.getMemberID(),  
messenger.getClusterSecretKey(), 1);
+    Set<InternalDistributedMember> recipients = new HashSet<>();
+    recipients.add(otherMbr);
+    gfmsg.setRecipients(recipients);
+    
+    short version = Version.CURRENT_ORDINAL;
+    
+    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
+    
+    messenger.writeEncryptedMessage(gfmsg, version, out);
+    
+    byte[] requestBytes = out.toByteArray();
+    
+    DataInputStream dis = new DataInputStream(new 
ByteArrayInputStream(requestBytes));
+    
+    messenger.addRequestId(1, messenger.getMemberID());
+    
+    DistributionMessage distributionMessage = 
messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
+    
+    assertEquals(gfmsg, distributionMessage);
+  }
+  
+  @Test
+  public void testEncryptedJoinRequest() throws Exception{
+    InternalDistributedMember otherMbr = new 
InternalDistributedMember("localhost", 8888);
+    
+    Properties p = new Properties();    
+    p.put(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+    initMocks(false, p);
+    
+    NetView v = createView(otherMbr);
+    
+    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
+    
+    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
+    messenger.initClusterKey();
+    
+    JoinRequestMessage gfmsg = new JoinRequestMessage(otherMbr, 
messenger.getMemberID(), null, 9789, 1);
+    
+    short version = Version.CURRENT_ORDINAL;
+    
+    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
+    
+    messenger.writeEncryptedMessage(gfmsg, version, out);
+    
+    byte[] requestBytes = out.toByteArray();
+    
+    DataInputStream dis = new DataInputStream(new 
ByteArrayInputStream(requestBytes));
+    
+    DistributionMessage distributionMessage = 
messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
+    
+    assertEquals(gfmsg, distributionMessage);
+  }
+  
+  @Test
+  public void testEncryptedJoinResponse() throws Exception{
+    InternalDistributedMember otherMbr = new 
InternalDistributedMember("localhost", 8888);
+    
+    Properties p = new Properties();    
+    p.put(DistributionConfig.SECURITY_CLIENT_DHALGO_NAME, "AES:128");
+    initMocks(false, p);
+    
+    NetView v = createView(otherMbr);
+    
+    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
+    
otherMbrEncrptor.setPublicKey(messenger.getPublickey(messenger.getMemberID()), 
messenger.getMemberID());
+    
+    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
+    messenger.initClusterKey();
+    
+    JoinResponseMessage gfmsg = new JoinResponseMessage(otherMbr, 
messenger.getClusterSecretKey(), 1);
+    
+    short version = Version.CURRENT_ORDINAL;
+    
+    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
+    
+    messenger.writeEncryptedMessage(gfmsg, version, out);
+    
+    byte[] requestBytes = out.toByteArray();
+    
+    DataInputStream dis = new DataInputStream(new 
ByteArrayInputStream(requestBytes));
+    
+    messenger.addRequestId(1, messenger.getMemberID());
+    
+    DistributionMessage gfMessageAtOtherMbr = 
messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
+    
+    assertEquals(gfmsg, gfMessageAtOtherMbr);
+    
+    //lets send view as well..
+    
+    InstallViewMessage installViewMessage = new InstallViewMessage(v, null, 
true);
+    
+    out = new HeapDataOutputStream(Version.CURRENT);
+    
+    messenger.writeEncryptedMessage(installViewMessage, version, out);
+    
+    requestBytes = out.toByteArray();
+    
+    
otherMbrEncrptor.addClusterKey(((JoinResponseMessage)gfMessageAtOtherMbr).getSecretPk());
+    
+    dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
+    
+    gfMessageAtOtherMbr = messenger.readEncryptedMessage(dis, version, 
otherMbrEncrptor);
+    
+    assertEquals(installViewMessage, gfMessageAtOtherMbr);
+    
+  }
+  
   /**
    * creates an InternalDistributedMember address that can be used
    * with the doctored JGroups channel.  This includes a logical


Reply via email to