@Test
  public void testReadyForEventsNotCalledImplicitlyForRegisterInterestWithCacheXML() {
    regionName = "testReadyForEventsNotCalledImplicitlyWithCacheXML_region";
    // Start a server
    server1Port =
        server1VM.invoke(() -> createCacheServerFromXmlN(
            DurableClientTestBase.class.getResource("durablecq-server-cache.xml")));

    // Start a durable client that is not kept alive on the server when it
    // stops normally
    final String durableClientId = getName() + "_client";

    // create client cache from xml
    durableClientVM.invoke(() -> createCacheClientFromXmlN(
        DurableClientTestBase.class.getResource("durablecq-client-cache.xml"), "client",
        durableClientId, DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, true));

    // verify that readyForEvents has not yet been called on all the client's pools
    durableClientVM.invoke("check readyForEvents not called", new CacheSerializableRunnable() {
      @Override
      public void run2() throws CacheException {
        for (Pool p : PoolManager.getAll().values()) {
          assertThat(((PoolImpl) p).getReadyForEventsCalled()).isFalse();
        }
      }
    });

    // Send clientReady message
    sendClientReady(durableClientVM);

    // Durable client registers durable cq on server
    registerInterest(durableClientVM, regionName, true, InterestResultPolicy.KEYS_VALUES);

    // Verify durable client on server1
    verifyDurableClientPresent(DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, durableClientId,
        server1VM);

    // Start normal publisher client
    publisherClientVM.invoke(() -> createCacheClient(
        getClientPool(getServerHostName(), server1Port, false),
        regionName));

    // Publish some entries
    final int numberOfEntries = 10;
    publishEntries(publisherClientVM, 0, numberOfEntries);

    // Verify the durable client received the updates
    checkListenerEvents(numberOfEntries, 1, -1, durableClientVM);

    // Stop the durable client
    durableClientVM.invoke(() -> CacheServerTestUtil.closeCache(true));

    // Verify the durable client still exists on the server
    verifyDurableClientPresent(DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, durableClientId,
        server1VM);

    // Publish some more entries
    publisherClientVM.invoke("Publish additional updates", new CacheSerializableRunnable() {
      @Override
      public void run2() throws CacheException {
        // Get the region
        Region<String, String> region = getCache().getRegion(regionName);
        assertThat(region).isNotNull();

        // Publish some entries
        for (int i = 0; i < numberOfEntries; i++) {
          String keyAndValue = String.valueOf(i);
          region.put(keyAndValue, keyAndValue + "lkj");
        }
      }
    });

    publisherClientVM.invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);

    // Re-start the durable client
    durableClientVM.invoke(() -> createCacheClientFromXmlN(
        DurableClientTestBase.class.getResource("durablecq-client-cache.xml"), "client",
        durableClientId, DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, true));

    // Durable client registers durable cq on server'
    registerInterest(durableClientVM, regionName, true, InterestResultPolicy.KEYS_VALUES);

    // Send clientReady message
    sendClientReady(durableClientVM);

    // Verify durable client on server
    verifyDurableClientPresent(DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, durableClientId,
        server1VM);

    // Verify the durable client received the updates held for it on the server
    checkListenerEvents(numberOfEntries, 1, -1, durableClientVM);

    // Stop the durable client
    durableClientVM.invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);

    // Stop the server
    server1VM.invoke((SerializableRunnableIF) CacheServerTestUtil::closeCache);
  }
Tests whether a durable client reconnects properly to two servers.
geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientSimpleDUnitTest.java