@Test
  public void testLocatorAndTwoServersJoinUsingDiffeHellman() throws Exception {

    Membership<InternalDistributedMember> m1 = null, m2 = null;
    InternalLocator internalLocator = null;
    int mcastPort = AvailablePortHelper.getRandomAvailableUDPPort();

    try {

      // boot up a locator
      int port = AvailablePortHelper.getRandomAvailableTCPPort();
      HostAddress localHost = new HostAddress(LocalHostUtil.getLocalHost());
      Properties p = new Properties();
      p.setProperty(ConfigurationProperties.SECURITY_UDP_DHALGO, "AES:128");
      // this locator will hook itself up with the first Membership
      // to be created
      internalLocator =
          InternalLocator.startLocator(port, new File(""), null, null, localHost, false, p,
              null,
              temporaryFolder.getRoot().toPath());

      // create configuration objects
      Properties nonDefault = new Properties();
      nonDefault.put(DistributionConfig.DISABLE_TCP_NAME, "true");
      nonDefault.put(DistributionConfig.MCAST_PORT_NAME, String.valueOf(mcastPort));
      nonDefault.put(DistributionConfig.LOG_FILE_NAME, "");
      nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
      nonDefault.put(DistributionConfig.GROUPS_NAME, "red, blue");
      nonDefault.put(DistributionConfig.MEMBER_TIMEOUT_NAME, "2000");
      nonDefault.put(DistributionConfig.LOCATORS_NAME, localHost.getHostName() + '[' + port + ']');
      nonDefault.put(ConfigurationProperties.SECURITY_UDP_DHALGO, "AES:128");
      DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
      RemoteTransportConfig transport =
          new RemoteTransportConfig(config, ClusterDistributionManager.LOCATOR_DM_TYPE);

      // start the first membership manager
      final MembershipLocator<InternalDistributedMember> membershipLocator =
          internalLocator.getMembershipLocator();

      m1 = createMembershipManager(config, transport, membershipLocator).getLeft();

      // start the second membership manager
      final Pair<Membership, MessageListener> pair =
          createMembershipManager(config, transport, membershipLocator);
      m2 = pair.getLeft();
      final MessageListener listener2 = pair.getRight();

      // we have to check the views with JoinLeave because the membership
      // manager queues new views for processing through the DM listener,
      // which is a mock object in this test
      System.out.println("waiting for views to stabilize");
      final Membership mgr1 = m1;
      final Membership mgr2 = m2;
      long giveUp = System.currentTimeMillis() + 15000;
      for (;;) {
        try {
          assertTrue("view = " + mgr2.getView(), mgr2.getView().size() == 2);
          assertTrue("view = " + mgr1.getView(), mgr1.getView().size() == 2);
          assertTrue(mgr1.getView().getCreator().equals(mgr2.getView().getCreator()));
          assertTrue(mgr1.getView().getViewId() == mgr2.getView().getViewId());
          break;
        } catch (AssertionError e) {
          if (System.currentTimeMillis() > giveUp) {
            throw e;
          }
        }
      }

      System.out.println("testing multicast availability");
      assertTrue(m1.testMulticast());

      System.out.println("multicasting SerialAckedMessage from m1 to m2");
      SerialAckedMessage msg = new SerialAckedMessage();
      msg.setRecipient(m2.getLocalMember());
      msg.setMulticast(true);
      m1.send(new InternalDistributedMember[] {m2.getLocalMember()}, msg);
      giveUp = System.currentTimeMillis() + 5000;
      boolean verified = false;
      Throwable problem = null;
      while (giveUp > System.currentTimeMillis()) {
        try {
          verify(listener2).messageReceived(isA(SerialAckedMessage.class));
          verified = true;
          break;
        } catch (Error e) {
          problem = e;
          Thread.sleep(500);
        }
      }
      if (!verified) {
        if (problem != null) {
          problem.printStackTrace();
        }
        fail("Expected a multicast message to be received");
      }

      // let the managers idle for a while and get used to each other
      Thread.sleep(4000l);

      m2.disconnect(false);
      assertTrue(!m2.isConnected());

      Membership waitingMember = m1;
      await().untilAsserted(() -> assertTrue(waitingMember.getView().size() == 1));

    } finally {

      if (m2 != null) {
        m2.disconnect(false);
      }
      if (m1 != null) {
        m1.disconnect(false);
      }
      if (internalLocator != null) {
        internalLocator.stop();
      }
    }
  }
This test ensures that secure communications are enabled.

This test creates a locator with a colocated membership manager and then creates a second
manager that joins the system of the first.

It then makes assertions about the state of the membership view, closes one of the managers and
makes more assertions.
geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/membership/MembershipJUnitTest.java