@After
  public void tearDown() throws Exception {
    try {
      if (r1 != null) {
        cleanUpRegion(r1);
      }
      if (r2 != null) {
        cleanUpRegion(r2);
      }
      if (r3 != null) {
        cleanUpRegion(r3);
      }
      if (r1sr1 != null) {
        cleanUpRegion(r1sr1);
      }
      Cache c = cache;
      DistributedSystem d = distSys;
      if (c != null && !c.isClosed()) {
        d = c.getDistributedSystem();
        c.close();
      }
      if (d != null && d.isConnected()) {
        d.disconnect();
      }
    } finally {
      r1 = null;
      r2 = null;
      r3 = null;
      r1sr1 = null;
      cache = null;
      distSys = null;
    }
  }
Unit test for the RegionFactory class

@since GemFire 5.0
geode-core/src/integrationTest/java/org/apache/geode/cache/RegionFactoryJUnitTest.java