@Test
  @Parameters({"LOCAL_DESTROY", "DESTROY", "LOCAL_INVALIDATE", "INVALIDATE"})
  @TestCaseName("{method}({params})")
  public void regionExpiresAfterTtl(final Verification verification) throws Exception {
    // In withoutExpirationVM1, create the region - no ttl
    withoutExpirationVM1.invoke(() -> {
      cacheRule.getCache().createRegionFactory(REPLICATE).create(regionName);
    });

    // In withExpirationVM0, create the region with ttl, and put value
    withExpirationVM0.invoke(() -> {
      spyCacheListener = spy(CacheListener.class);

      RegionFactory<String, String> regionFactory =
          cacheRule.getCache().createRegionFactory(REPLICATE);
      regionFactory.setRegionTimeToLive(
          new ExpirationAttributes(TTL_SECONDS, verification.expirationAction()));
      regionFactory.addCacheListener(spyCacheListener);
      Region<String, String> region = regionFactory.create(regionName);

      region.put(KEY, VALUE);
      assertThat(region.get(KEY)).isEqualTo(VALUE);
      assertThat(region.containsValueForKey(KEY)).isTrue();
    });

    withoutExpirationVM1.invoke(() -> {
      assertThat(cacheRule.getCache().getRegion(regionName).get(KEY)).isEqualTo(VALUE);
    });

    // Wait for expiration to occur
    // In withExpirationVM0, region should be absent (for destroy, localDestroy), or entry invalid
    withExpirationVM0.invoke(() -> {
      verification.verify(spyCacheListener);
      verification.assertThatExpirationOccurredInLocalMember(cacheRule.getCache(), regionName);
    });

    // In withoutExpirationVM1, region should be absent (for destroy), or entry invalid
    // (invalidate).
    withoutExpirationVM1.invoke(() -> {
      verification.assertRegionStateInRemoteMember(cacheRule.getCache(), regionName);
    });
  }
Test Region expiration - both time-to-live and idle timeout.

<p>
Note: See LocalRegionTest and MultiVMRegionTestCase for more expiration tests.

<p>
Single-JVM tests were extracted to RegionExpirationIntegrationTest.

@since GemFire 3.0
geode-core/src/distributedTest/java/org/apache/geode/cache/RegionExpirationDistributedTest.java