Program: 90045
Project: 90045
Buggy source:
/** 
 * Test that the constructor exposes N MBeans, and each can be connected to and returns the empty string. It is tested that the names of the objects are generated from: "location" =  Settings.get(CommonSettings.ENVIRONMENT_THIS_PHYSICAL_LOCATION) "machine" = InetAddress.getLocalHost().getCanonicalHostName()  "httpport" = Settings.get(CommonSettings.HTTP_PORT_NUMBER)  "applicationname" = Settings.get(CommonSettings.APPLICATION_NAME)  "applicationinstid" = Settings.get(CommonSettings.APPLICATIONINSTANCE_ID)  "index" = (index in the cache; 0 is always the most recent log record) It is also tested that no MBeans were registered before this call.
 * @throws Exception
 */
public void testCachingLogHandler() throws Exception {
  int before=mBeanServer.getMBeanCount();
  ObjectName name=getObjectName(-1);
  assertEquals("String_Node_Str",0,mBeanServer.queryNames(name,null).size());
  cachingLogHandler=new CachingLogHandler();
  int after=mBeanServer.getMBeanCount();
  assertEquals(LOG_HISTORY_SIZE + "String_Node_Str",LOG_HISTORY_SIZE,after - before);
  assertEquals("String_Node_Str" + LOG_HISTORY_SIZE + "String_Node_Str"+ name+ "String_Node_Str",LOG_HISTORY_SIZE,mBeanServer.queryNames(name,null).size());
  ObjectInstance mbean=getObjectInstance(mBeanServer,0);
  assertTrue("String_Node_Str",SingleLogRecord.class.isAssignableFrom(Class.forName(mbean.getClassName())));
  mbean=getObjectInstance(mBeanServer,LOG_HISTORY_SIZE - 1);
  assertTrue("String_Node_Str",SingleLogRecord.class.isAssignableFrom(Class.forName(mbean.getClassName())));
  try {
    getObjectInstance(mBeanServer,LOG_HISTORY_SIZE);
    fail("String_Node_Str" + LOG_HISTORY_SIZE);
  }
 catch (  InstanceNotFoundException e) {
  }
  for (int i=0; i < LOG_HISTORY_SIZE; i++) {
    String logRecordI=getLogRecordAtIndex(i,mBeanServer);
    assertEquals("String_Node_Str","String_Node_Str",logRecordI);
  }
}

Fixed version (ground truth):
/** 
 * Test that the constructor exposes N MBeans, and each can be connected to and returns the empty string. It is tested that the names of the objects are generated from: "location" =  Settings.get(CommonSettings.ENVIRONMENT_THIS_PHYSICAL_LOCATION) "machine" = InetAddress.getLocalHost().getCanonicalHostName()  "httpport" = Settings.get(CommonSettings.HTTP_PORT_NUMBER)  "applicationname" = Settings.get(CommonSettings.APPLICATION_NAME)  "applicationinstid" = Settings.get(CommonSettings.APPLICATIONINSTANCE_ID)  "index" = (index in the cache; 0 is always the most recent log record) It is also tested that no MBeans were registered before this call.
 * @throws Exception
 */
public void testCachingLogHandler() throws Exception {
  int before=mBeanServer.getMBeanCount();
  ObjectName name=getObjectName(-1);
  assertEquals("String_Node_Str",0,mBeanServer.queryNames(name,null).size());
  cachingLogHandler=new CachingLogHandler();
  int after=mBeanServer.getMBeanCount();
  assertEquals(LOG_HISTORY_SIZE + "String_Node_Str",LOG_HISTORY_SIZE,after - before);
  Set<ObjectName> names=mBeanServer.queryNames(null,null);
  for (  ObjectName currentName : names) {
    System.out.println(currentName);
  }
  assertEquals("String_Node_Str" + LOG_HISTORY_SIZE + "String_Node_Str"+ name+ "String_Node_Str",LOG_HISTORY_SIZE,mBeanServer.queryNames(name,null).size());
  ObjectInstance mbean=getObjectInstance(mBeanServer,0);
  assertTrue("String_Node_Str",SingleLogRecord.class.isAssignableFrom(Class.forName(mbean.getClassName())));
  mbean=getObjectInstance(mBeanServer,LOG_HISTORY_SIZE - 1);
  assertTrue("String_Node_Str",SingleLogRecord.class.isAssignableFrom(Class.forName(mbean.getClassName())));
  try {
    getObjectInstance(mBeanServer,LOG_HISTORY_SIZE);
    fail("String_Node_Str" + LOG_HISTORY_SIZE);
  }
 catch (  InstanceNotFoundException e) {
  }
  for (int i=0; i < LOG_HISTORY_SIZE; i++) {
    String logRecordI=getLogRecordAtIndex(i,mBeanServer);
    assertEquals("String_Node_Str","String_Node_Str",logRecordI);
  }
}