private void runRegisterInterestWithCacheLoaderTest(boolean addReplicatedRegion) {
    // Stop the server (since it was already started with a replicated region)
    vm0.invoke(InterestListDUnitTest::closeCache);

    // Start two servers with the appropriate region
    int port1 =
        vm0.invoke(() -> InterestListDUnitTest.createServerCache(addReplicatedRegion));
    VM server2VM = Host.getHost(0).getVM(3);
    int port2 = server2VM
        .invoke(() -> InterestListDUnitTest.createServerCache(addReplicatedRegion));

    // Add a cache loader to the region in both cache servers
    vm0.invoke(InterestListDUnitTest::addCacheLoader);
    server2VM.invoke(InterestListDUnitTest::addCacheLoader);

    // Create client cache
    vm1.invoke(() -> InterestListDUnitTest
        .createClientCache(NetworkUtils.getServerHostName(vm0.getHost()), port1, port2));

    // Register interest in all keys
    vm1.invoke(InterestListDUnitTest::registerALL_KEYS);

    // Add CacheListener
    int numEvents = 100;
    vm1.invoke(() -> InterestListDUnitTest.addCacheListener(numEvents));

    // Do gets on the client
    vm1.invoke(() -> InterestListDUnitTest.doGets(numEvents));

    // Wait for cache listener create events
    vm1.invoke(InterestListDUnitTest::waitForCacheListenerCreates);

    // Confirm there are no cache listener update events
    vm1.invoke(InterestListDUnitTest::confirmNoCacheListenerUpdates);

    // Confirm there are no cache listener invalidate events
    vm1.invoke(InterestListDUnitTest::confirmNoCacheListenerInvalidates);
  }
This tests whether an exception is thrown in register/unregister when no server is available.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java