public static void createClientCache(String hostName, Integer port1, Integer port2,
      Boolean listenerAttached, Boolean registerInterest) throws Exception {
    int PORT1 = port1;
    int PORT2 = port2;
    boolean isListenerAttached = listenerAttached;
    boolean isRegisterInterest = registerInterest;
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    new HAClearDistributedTest().createCache(props);
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    ClientServerTestCase.configureConnectionPool(factory, hostName, new int[] {PORT1, PORT2}, true,
        -1, 2, null);
    if (isListenerAttached) {
      factory.setCacheListener(new CacheListenerAdapter() {
        @Override
        public void afterRegionClear(RegionEvent event) {
          LogWriterUtils.getLogWriter().info("-------> afterRegionClear received");
          synchronized (HAClearDistributedTest.class) {
            gotClearCallback = true;
            HAClearDistributedTest.class.notifyAll();
          }
        }

        @Override
        public void afterRegionDestroy(RegionEvent event) {
          synchronized (HAClearDistributedTest.class) {
            LogWriterUtils.getLogWriter().info("-------> afterRegionDestroy received");
            gotDestroyRegionCallback = true;
            HAClearDistributedTest.class.notifyAll();
          }
        }
      });
    }
    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);
    Region region = cache.getRegion(SEPARATOR + REGION_NAME);
    assertNotNull(region);
    if (isRegisterInterest) {
      region.registerInterest("ALL_KEYS", InterestResultPolicy.NONE);
    } else {
      region.registerInterestRegex("*.", false, false); // don't want data but do want events
    }
  }
The test performs following operations 1. Create 2 servers and 3 clients 2. Perform put
operations for known set of keys directy from the server1. 3. Perform destroyRegion operation
from server1 4. verify the result of operation for other clients and other servers.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/ha/HAClearDistributedTest.java