@Test
  public void testNetSearchFailoverFromOneReplicateToAnother() {
    installListenerToDisconnectOnNetSearchRequest(vm0);

    createReplicate(vm0);
    createReplicate(vm1);
    createEmpty(vm2);

    put(vm2, "a", "b");

    boolean disconnected = false;
    while (!disconnected) {
      // get() causes vm2 to send a query message to all replicated members. All members with that
      // key reply. vm2 then sends a net search request to the first one that replies. If that
      // fails, it sends a net search request to the next one that replied. And so on.
      //
      // Because we can't be sure which member will respond first to each query, we repeat the loop
      // until vm0 is the first responder. vm0 will then disconnect when it receives the net search
      // request, forcing failover to another vm (in this case vm1). If we got the correct answer
      // AND the system is disconnected, then failover occurred.
      assertThat("b").isEqualTo(get(vm2, "a"));

      // Make sure we were disconnected in vm0
      disconnected =
          vm0.invoke("check disconnected",
              () -> InternalDistributedSystem.getConnectedInstance() == null);
    }

    waitForListenerToFinish(vm0);
  }
When a replicate fails after responding to a query message, the net search should fail over to
the next replicate that responded.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/NetSearchMessagingDUnitTest.java