@Test
  public void testLocatorBecomesCoordinator() {
    addIgnoredException(ConnectException.class);

    String locators = hostName + "[" + port2 + "]";

    startLocatorPreferredCoordinators(vm0, port2);

    Properties props = new Properties();
    props.setProperty(LOCATORS, locators);
    props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
    addDSProps(props);

    vm1.invoke(() -> {
      getSystem(props);
    });
    vm2.invoke(() -> {
      getSystem(props);
    });

    system = getSystem(props);

    DistributedMember coord = MembershipManagerHelper.getCoordinator(system);
    logger.info("coordinator before termination of locator is " + coord);

    vm0.invoke(LocatorDUnitTest::stopLocator);

    // now ensure that one of the remaining members became the coordinator
    await().until(() -> !coord.equals(MembershipManagerHelper.getCoordinator(system)));

    final DistributedMember newCoord = MembershipManagerHelper.getCoordinator(system);
    logger.info("coordinator after shutdown of locator was " + newCoord);
    if (newCoord == null || coord.equals(newCoord)) {
      fail("another member should have become coordinator after the locator was stopped: "
          + newCoord);
    }

    // restart the locator to demonstrate reconnection & make disconnects faster
    // it should also regain the role of coordinator, so we check to make sure
    // that the coordinator has changed
    startLocatorPreferredCoordinators(vm0, port2);

    await().until(() -> !newCoord.equals(MembershipManagerHelper.getCoordinator(system)));

    system.disconnect();

    checkConnectionAndPrintInfo(vm1);
    checkConnectionAndPrintInfo(vm2);
  }
Tests starting one locator in a remote VM and having multiple members of the distributed system
join it. This ensures that members start up okay, and that handling of a stopped locator is
correct. It then restarts the locator to demonstrate that it can connect to and function as the
group coordinator
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java