@Test
  public void testReconnectALocator() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    DistributedMember dm, newdm;

    final int locPort = locatorPort;
    final int secondLocPort = AvailablePortHelper.getRandomAvailableTCPPort();

    Invoke
        .invokeInEveryVM(() -> DistributedTestUtils.deleteLocatorStateFile(locPort, secondLocPort));

    final String xmlFileLoc = (new File(".")).getAbsolutePath();

    vm0.invoke("Create a second locator", () -> {
      locatorPort = locPort;
      Properties props = getDistributedSystemProperties();
      props.put(MAX_WAIT_TIME_RECONNECT, "1000");
      props.put(LOCATORS, props.get(LOCATORS) + ",localhost[" + locPort + "]");
      props.put(ENABLE_CLUSTER_CONFIGURATION, "false");
      InternalLocator locator =
          (InternalLocator) Locator.startLocatorAndDS(secondLocPort, null, props);
      system = (InternalDistributedSystem) locator.getDistributedSystem();
      cache = locator.getCache();
    });

    // create a cache in vm1 so there is more weight in the system
    vm1.invoke("Create Cache and Regions from cache.xml", () -> {
      locatorPort = locPort;
      Properties props = getDistributedSystemProperties();
      props.put(CACHE_XML_FILE, xmlFileLoc + fileSeparator + "MyDisconnect-cache.xml");
      props.put(MAX_WAIT_TIME_RECONNECT, "1000");
      ReconnectDUnitTest.savedSystem = getSystem(props);
      cache = getCache();
      Region myRegion = cache.getRegion("root" + SEPARATOR + "myRegion");
      myRegion.put("MyKey1", "MyValue1");
      return savedSystem.getDistributedMember();
    });

    try {
      dm = vm0.invoke("get ID", () -> {
        ReconnectDUnitTest.savedSystem = cache.getDistributedSystem();
        return ReconnectDUnitTest.savedSystem.getDistributedMember();
      });

      startWaitOnLocatorToStopThread(vm0);
      forceDisconnect(vm0);
      newdm = waitForReconnect(vm0);
      vm0.invoke("assert the locator thread is still waiting", () -> {
        await().during(1, SECONDS)
            .untilAsserted(() -> assertThat(waitOnLocatorToStopThread.isAlive()).isTrue());
      });

      assertTrue("Expected the restarted member to be hosting a running locator",
          vm0.invoke("check for running locator", () -> {
            await("waiting for locator to restart")
                .until(Locator::getLocator, notNullValue());
            if (((InternalLocator) Locator.getLocator()).isStopped()) {
              System.err.println("found a stopped locator");
              return false;
            }
            return true;
          }));

      assertNotSame("expected a reconnect to occur in the locator", dm, newdm);
    } finally {
      vm0.invoke("stop locator", () -> {
        Locator loc = Locator.getLocator();
        if (loc != null) {
          loc.stop();
        }
        if (waitOnLocatorToStopThread != null && waitOnLocatorToStopThread.isAlive()) {
          waitOnLocatorToStopThread.interrupt();
        }
        waitOnLocatorToStopThread = null;
      });
      Invoke.invokeInEveryVM(
          () -> DistributedTestUtils.deleteLocatorStateFile(locPort, secondLocPort));
    }
  }
this will throw an exception if location services aren't running
geode-core/src/distributedTest/java/org/apache/geode/cache30/ReconnectDUnitTest.java