@Test
  public void test_DiscoverLocators_whenOneLocatorWasShutdown() throws Exception {
    startFakeLocator();
    int secondPort = AvailablePortHelper.getRandomAvailableTCPPort();

    TcpServer server2 =
        new TcpServer(secondPort, InetAddress.getLocalHost(), handler,
            "tcp server", new ProtocolCheckerImpl(),
            DistributionStats::getStatTime,
            Executors::newCachedThreadPool,
            SocketCreatorFactory
                .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR),
            InternalDataSerializer.getDSFIDSerializer().getObjectSerializer(),
            InternalDataSerializer.getDSFIDSerializer().getObjectDeserializer(),
            GeodeGlossary.GEMFIRE_PREFIX + "TcpServer.READ_TIMEOUT",
            GeodeGlossary.GEMFIRE_PREFIX + "TcpServer.BACKLOG");
    server2.start();

    try {
      ArrayList<ServerLocation> locators = new ArrayList<>();
      locators.add(new ServerLocation(InetAddress.getLocalHost().getHostName(), secondPort));
      handler.nextLocatorListResponse = new LocatorListResponse(locators, false);
      await().until(() -> !source.getOnlineLocators().isEmpty());
      try {
        issueStopRequest(port);
      } catch (ConnectException ignore) {
        // must not be running
      }
      server.join(1000);

      ServerLocation server1 = new ServerLocation("localhost", 10);
      handler.nextConnectionResponse = new ClientConnectionResponse(server1);
      assertThat(source.findServer(null)).isEqualTo(server1);
    } finally {
      try {
        issueStopRequest(secondPort);
      } catch (ConnectException ignore) {
        // must not be running
      }
      server.join(60 * 1000);
    }
  }
This tests that discovery works even after one of two locators was shut down
geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplIntegrationTest.java