Program: 19364
Project: 19364
Buggy source:
/** 
 * Check the listener is getting reads
 */
@Test public void testCacheEntryListener(){
  MyCacheEntryListener<Long,String> listener=new MyCacheEntryListener<Long,String>();
  cache.registerCacheEntryListener(listener,false,null,true);
  assertEquals(0,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(1,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  Map<Long,String> entries=new HashMap<Long,String>();
  entries.put(2l,"String_Node_Str");
  entries.put(3l,"String_Node_Str");
  cache.putAll(entries);
  assertEquals(3,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(3,listener.getCreated());
  assertEquals(1,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.putAll(entries);
  assertEquals(3,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  String value=cache.get(1l);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  Cache.EntryProcessor<Long,String,String> multiArgEP=new MultiArgumentEntryProcessor<Long,String,String>();
  String result=cache.invokeEntryProcessor(1l,multiArgEP,"String_Node_Str","String_Node_Str","String_Node_Str");
  assertEquals(value,result);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  result=cache.invokeEntryProcessor(1l,new SetEntryProcessor<Long,String,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  result=cache.invokeEntryProcessor(1l,new RemoveEntryProcessor<Long,String,String>());
  assertNull(result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  result=cache.invokeEntryProcessor(1l,new SetEntryProcessor<Long,String,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  Iterator<Cache.Entry<Long,String>> iterator=cache.iterator();
  while (iterator.hasNext()) {
    iterator.next();
    iterator.remove();
  }
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(5,listener.getRemoved());
}

Fixed version (ground truth):
/** 
 * Check the listener is getting reads
 */
@Test public void testCacheEntryListener(){
  MyCacheEntryListener<Long,String> listener=new MyCacheEntryListener<Long,String>();
  cache.registerCacheEntryListener(listener,false,null,true);
  assertEquals(0,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(1,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  Map<Long,String> entries=new HashMap<Long,String>();
  entries.put(2l,"String_Node_Str");
  entries.put(3l,"String_Node_Str");
  cache.putAll(entries);
  assertEquals(3,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(3,listener.getCreated());
  assertEquals(1,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.putAll(entries);
  assertEquals(3,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  String value=cache.get(1l);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  Cache.EntryProcessor<Long,String,String> multiArgEP=new MultiArgumentEntryProcessor<Long,String,String>();
  String result=cache.invokeEntryProcessor(1l,multiArgEP,"String_Node_Str","String_Node_Str","String_Node_Str");
  assertEquals(value,result);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  result=cache.invokeEntryProcessor(1l,new SetEntryProcessor<Long,String,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  result=cache.invokeEntryProcessor(1l,new RemoveEntryProcessor<Long,String,String>());
  assertNull(result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  result=cache.invokeEntryProcessor(1l,new SetEntryProcessor<Long,String,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  Iterator<Cache.Entry<Long,String>> iterator=cache.iterator();
  while (iterator.hasNext()) {
    iterator.next();
    iterator.remove();
  }
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(5,listener.getRemoved());
}