Program: 19384
Project: 19384
Buggy source:
/** 
 * Ensure that a cache using a   {@link javax.cache.ExpiryPolicy} configured toreturn a  {@link Duration#ZERO} after modifying entries will immediately expire said entries.
 */
@Test public void expire_whenModified(){
  MutableConfiguration<Integer,Integer> config=new MutableConfiguration<Integer,Integer>();
  config.setExpiryPolicy(new ParameterizedExpiryPolicy<Integer,Integer>(Duration.ETERNAL,null,Duration.ZERO));
  Cache<Integer,Integer> cache=getCacheManager().configureCache(getTestCacheName(),config);
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.remove(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.remove(1,2));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.getAndPut(1,2));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
  map.put(1,2);
  cache.putAll(map);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.replace(1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.replace(1,1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.iterator().hasNext());
  assertEquals((Integer)1,cache.iterator().next().getValue());
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.iterator().next().getValue());
  cache.put(1,2);
  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 modifying entries will immediately expire said entries.
 */
@Test public void expire_whenModified(){
  MutableConfiguration<Integer,Integer> config=new MutableConfiguration<Integer,Integer>();
  config.setExpiryPolicyFactory(Factories.of(new ParameterizedExpiryPolicy<Integer,Integer>(Duration.ETERNAL,null,Duration.ZERO)));
  Cache<Integer,Integer> cache=getCacheManager().configureCache(getTestCacheName(),config);
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.remove(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.remove(1,2));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.put(1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.getAndPut(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.getAndPut(1,2));
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
  map.put(1,2);
  cache.putAll(map);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.replace(1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.get(1));
  cache.replace(1,1,2);
  assertFalse(cache.containsKey(1));
  assertNull(cache.get(1));
  cache.put(1,1);
  assertTrue(cache.iterator().hasNext());
  assertEquals((Integer)1,cache.iterator().next().getValue());
  assertTrue(cache.containsKey(1));
  assertEquals((Integer)1,cache.iterator().next().getValue());
  cache.put(1,2);
  assertFalse(cache.iterator().hasNext());
}