@Test
  public void testEntryFromLoadTtlInvalidate() throws CacheException {

    final String name = getUniqueName();
    final int timeout = 20; // ms!
    final String key = "KEY";
    final String value = "VALUE";

    RegionFactory<Object, Object> factory = getCache().createRegionFactory(getRegionAttributes());
    ExpirationAttributes expire = new ExpirationAttributes(timeout, ExpirationAction.INVALIDATE);
    factory.setEntryTimeToLive(expire);
    factory.setStatisticsEnabled(true);
    factory.setCacheLoader(new TestCacheLoader<Object, Object>() {
      @Override
      public Object load2(LoaderHelper helper) {
        return value;
      }
    });

    Region<Object, Object> region;
    System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
    try {
      region = createRegion(name, factory);

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