@Test
  public void testPeerRegion() {
    assertEquals(true, DynamicRegionFactory.get().isOpen());
    createParentRegion("parent", true);

    Properties p = new Properties();
    doParentCreateOtherVm(p, false);
    Region dr = DynamicRegionFactory.get().createDynamicRegion("parent", "dynamicRegion1");
    String drFullPath = dr.getFullPath();
    dr.put("key1", "value1");
    // test for bug 35528 - support for dynamic subregions of dynamic regions
    for (int i = 0; i < 10; i++) {
      DynamicRegionFactory.get().createDynamicRegion(drFullPath, "subregion" + i);
    }

    LogWriterUtils.getLogWriter()
        .info("testPeerRegion - check #1 make sure other region has new dynamic subregion");
    checkForRegionOtherVm(drFullPath, true);

    // spot check the subregions
    checkForSubregionOtherVm(drFullPath + SEPARATOR + "subregion7", true);

    // now see if OTHER can recreate which should fetch meta-info from controller
    recreateOtherVm();

    LogWriterUtils.getLogWriter().info(
        "testPeerRegion - check #2 make sure other region has dynamic region after restarting through getInitialImage");
    checkForRegionOtherVm(drFullPath, true);

    // now close the controller and see if OTHER can still fetch meta-info from disk
    closeCache();
    recreateOtherVm();
    LogWriterUtils.getLogWriter()
        .info("testPeerRegion - check #3 make sure dynamic region can be recovered from disk");
    checkForRegionOtherVm(drFullPath, true);
    for (int i = 0; i < 10; i++) {
      checkForSubregionOtherVm(drFullPath + SEPARATOR + "subregion" + i, true);
    }

    // now start our cache back up and see if we still have the dynamic regions
    // even if we don't have disk on the controller to recover from.
    // This means we will get them from the peer
    {
      assertEquals(true, DynamicRegionFactory.get().isClosed());
      DynamicRegionFactory.get().open(new DynamicRegionFactory.Config());
      beginCacheXml();
      createParentRegion("parent", true);
      finishCacheXml("dynamicRegionCTRDUnitTest");
      assertEquals(true, DynamicRegionFactory.get().isOpen());
      assertEquals(true, DynamicRegionFactory.get().isActive());
      Cache c = getCache();

      // verify that controller has all dynamic regions
      assertEquals(true, c.getRegion(drFullPath) != null);

      // now make sure we can destroy dynamic regions
      for (int i = 0; i < 10; i++) {
        String regName = drFullPath + SEPARATOR + "subregion" + i;
        assertEquals(true, c.getRegion(regName) != null);
        DynamicRegionFactory.get().destroyDynamicRegion(regName);
        assertEquals(null, c.getRegion(regName));
        checkForSubregionOtherVm(regName, false);
      }

      // make sure that we can explicitly destroy a region and then still
      // ask the factory to destroy it.
      c.getRegion(drFullPath).localDestroyRegion();
      checkForRegionOtherVm(drFullPath, true);
      DynamicRegionFactory.get().destroyDynamicRegion(drFullPath);
      assertEquals(null, c.getRegion(drFullPath));
      checkForRegionOtherVm(drFullPath, false);
    }
  }
Make sure dynamic regions work on peers
geode-core/src/distributedTest/java/org/apache/geode/cache30/DynamicRegionDUnitTest.java