@Test
  public void testNetSearchObservesIdleTime() {
    assumeThat(getRegionAttributes().getPartitionAttributes())
        .withFailMessage("the region has partition attributes").isNull();

    final String name = getUniqueName();
    final int shortTimeout = 10; // ms
    final int longTimeout = 10000; // ms
    final Object key = "KEY";
    final Object value = "VALUE";

    // if using shared memory, make sure we use two VMs on different
    // gemfire systems

    vm1.invoke("Create with IdleTimeout", () -> {
      RegionFactory<Object, Object> factory1 =
          getCache().createRegionFactory(getRegionAttributes());
      factory1.setStatisticsEnabled(true);
      ExpirationAttributes expire1 =
          new ExpirationAttributes(longTimeout, ExpirationAction.DESTROY);
      factory1.setEntryIdleTimeout(expire1);
      System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
      try {
        Region<Object, Object> region1 = createRegion(name, factory1);
        region1.create(key, value);
      } finally {
        System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY);
      }
    });

    // vm0 - Create region, short timeout
    vm0.invoke("Create with IdleTimeout", () -> {
      RegionAttributes<?, ?> ra = getRegionAttributes();
      AttributesFactory<?, ?> factory = new AttributesFactory<>(ra);
      final boolean partitioned =
          ra.getPartitionAttributes() != null || ra.getDataPolicy().withPartitioning();
      // MUST be nonmirrored, so turn off persistBackup if this is a disk region test
      if (!partitioned) {
        if (ra.getEvictionAttributes() == null
            || !ra.getEvictionAttributes().getAction().isOverflowToDisk()) {
          factory.setDiskStoreName(null);
        }
        factory.setDataPolicy(DataPolicy.NORMAL);
      }
      factory.setStatisticsEnabled(true);
      ExpirationAttributes expire =
          new ExpirationAttributes(shortTimeout, ExpirationAction.DESTROY);
      factory.setEntryIdleTimeout(expire);
      System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
      try {
        createRegion(name, factory.create());
      } finally {
        System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY);
      }
    });

    // Even though netSearch finds vm1's entry is not expired, it is considered
    // expired with respect to vm0's attributes
    vm0.invoke("get(key), expect null", () -> {
      Region<Object, Object> region = getRootRegion().getSubregion(name);
      await().pollDelay(1, SECONDS).untilAsserted(() -> assertThat(region.get(key)).isNull());
    });

    // We see the object is actually still there
    vm1.invoke("get(key), expect value", () -> {
      Region<Object, Object> region = getRootRegion().getSubregion(name);
      await().untilAsserted(() -> assertThat(region.get(key)).isEqualTo(value));
    });
  }
Tests that a region is not kept alive
geode-dunit/src/main/java/org/apache/geode/cache30/MultiVMRegionTestCase.java