@Test
  public void testCollocatedLocatorWithSecurity() {
    String locators = hostName + "[" + port1 + "]";

    Properties properties = new Properties();
    properties.setProperty(SECURITY_PEER_AUTH_INIT,
        "org.apache.geode.distributed.AuthInitializer.create");
    properties.setProperty(SECURITY_PEER_AUTHENTICATOR,
        "org.apache.geode.distributed.MyAuthenticator.create");
    properties.setProperty(START_LOCATOR, locators);
    addDSProps(properties);

    system = getConnectedDistributedSystem(properties);
    assertThat(system.getDistributedMember().getVmKind())
        .describedAs("expected the VM to have NORMAL vmKind")
        .isEqualTo(ClusterDistributionManager.NORMAL_DM_TYPE);

    properties.remove(START_LOCATOR);
    properties.setProperty(LOCATORS, locators);

    SerializableRunnable startSystem = new SerializableRunnable("start system") {
      @Override
      public void run() {
        system = getConnectedDistributedSystem(properties);
      }
    };
    vm1.invoke(startSystem);
    vm2.invoke(startSystem);

    // ensure that I, as a collocated locator owner, can create a cache region
    Cache cache = CacheFactory.create(system);
    Region<?, ?> r = cache.createRegionFactory(RegionShortcut.REPLICATE).create("test-region");
    assertThat(r).describedAs("expected to create a region").isNotNull();

    // create a lock service and have every vm get a lock
    DistributedLockService service = DistributedLockService.create("test service", system);
    service.becomeLockGrantor();
    service.lock("foo0", 0, 0);

    vm1.invoke("get the lock service and lock something",
        () -> DistributedLockService.create("test service", system).lock("foo1", 0, 0));

    vm2.invoke("get the lock service and lock something",
        () -> DistributedLockService.create("test service", system).lock("foo2", 0, 0));

    // cause elder failover. vm1 will become the lock grantor
    system.disconnect();

    vm1.invoke("ensure grantor failover", () -> {
      DistributedLockService serviceNamed = DistributedLockService.getServiceNamed("test service");
      serviceNamed.lock("foo3", 0, 0);
      await().until(serviceNamed::isLockGrantor);
      assertThat(serviceNamed.isLockGrantor()).isTrue();
    });

    properties.setProperty(START_LOCATOR, locators);

    system = getConnectedDistributedSystem(properties);
    System.out.println("done connecting distributed system.  Membership view is "
        + MembershipManagerHelper.getDistribution(system).getView());

    assertThat(MembershipManagerHelper.getCoordinator(system))
        .describedAs("should be the coordinator").isEqualTo(system.getDistributedMember());
    MembershipView<InternalDistributedMember> view =
        MembershipManagerHelper.getDistribution(system).getView();
    logger.info("view after becoming coordinator is " + view);
    assertThat(system.getDistributedMember())
        .describedAs("should not be the first member in the view (" + view + ")")
        .isNotSameAs(view.get(0));

    service = DistributedLockService.create("test service", system);

    // now force a non-elder VM to get a lock. This will hang if the bug is not fixed
    vm2.invoke("get the lock service and lock something", () -> {
      DistributedLockService.getServiceNamed("test service").lock("foo4", 0, 0);
    });

    assertThat(service.isLockGrantor()).describedAs("should not have become lock grantor")
        .isFalse();

    // Now demonstrate that a new member can join and use the lock service
    properties.remove(START_LOCATOR);
    vm3.invoke(startSystem);
    vm3.invoke("get the lock service and lock something(2)",
        () -> DistributedLockService.create("test service", system).lock("foo5", 0, 0));
  }
This tests that the locator can resume control as coordinator after all locators have been shut
down and one is restarted. It's necessary to have a lock service start so elder failover is
forced to happen. Prior to fixing how this worked 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.
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java