Program: 19382
Project: 19382
Buggy source:
/** 
 * Ensure that a cache using a   {@link javax.cache.ExpiryPolicy} configured toreturn a  {@link Duration#ZERO} after accessing entries will immediately expire said entries.
 */
@Test public void expire_whenAccessed(){
  MutableConfiguration<Integer,Integer> config=new MutableConfiguration<Integer,Integer>();
  config.setExpiryPolicy(new ParameterizedExpiryPolicy<Integer,Integer>(Duration.ETERNAL,Duration.ZERO,null));
  Cache<Integer,Integer> cache=getCacheManager().configureCache(getTestCacheName(),config);
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.getAndReplace(1,2));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.getAndRemove(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.remove(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.remove(1,1));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.getAndPut(1,1));
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.putIfAbsent(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
  map.put(1,1);
  cache.putAll(map);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  Iterator<Entry<Integer,Integer>> iterator=cache.iterator();
  assertTrue(iterator.hasNext());
  assertEquals((Integer)1,iterator.next().getValue());
  assertFalse(cache.iterator().hasNext());
}

Fixed version (ground truth):
/** 
 * Ensure that a cache using a   {@link javax.cache.ExpiryPolicy} configured toreturn a  {@link Duration#ZERO} after accessing entries will immediately expire said entries.
 */
@Test public void expire_whenAccessed(){
  MutableConfiguration<Integer,Integer> config=new MutableConfiguration<Integer,Integer>();
  config.setExpiryPolicyFactory(Factories.of(new ParameterizedExpiryPolicy<Integer,Integer>(Duration.ETERNAL,Duration.ZERO,null)));
  Cache<Integer,Integer> cache=getCacheManager().configureCache(getTestCacheName(),config);
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.getAndReplace(1,2));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.getAndRemove(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.remove(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.remove(1,1));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.getAndPut(1,1));
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.putIfAbsent(1,1);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
  map.put(1,1);
  cache.putAll(map);
  assertTrue(cache.containsKey(1));
  assertNotNull(cache.get(1));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  Iterator<Entry<Integer,Integer>> iterator=cache.iterator();
  assertTrue(iterator.hasNext());
  assertEquals((Integer)1,iterator.next().getValue());
  assertFalse(cache.iterator().hasNext());
}