@Test
  public void testEntryTtlInvalidate() throws CacheException {

    final String name = getUniqueName();
    final int timeout = 20; // ms!
    final String key = "KEY";
    final String value = "VALUE";
    RegionFactory<Object, Object> regionFactory =
        getCache().createRegionFactory(getRegionAttributes());
    ExpirationAttributes expire = new ExpirationAttributes(timeout, ExpirationAction.INVALIDATE);
    regionFactory.setEntryTimeToLive(expire);
    regionFactory.setStatisticsEnabled(true);
    Region<Object, Object> region;
    /*
     * Crank up the expiration so test runs faster. This property only needs to be set while the
     * region is created
     */

    System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
    try {
      region = createRegion(name, regionFactory);
    } finally {
      System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY);
    }

    ExpiryTask.suspendExpiration();
    Region.Entry entry;
    long tilt;
    try {
      region.put(key, value);
      tilt = System.currentTimeMillis() + timeout;
      entry = region.getEntry(key);
      assertNotNull(entry.getValue());
    } finally {
      ExpiryTask.permitExpiration();
    }
    waitForInvalidate(entry, tilt);
  }
Tests that an entry in a region expires with an invalidation after a given time to live.
geode-dunit/src/main/java/org/apache/geode/cache30/RegionTestCase.java