Program: 89917
Project: 89917
Buggy source:
/** 
 * Test that a BitarchiveServer is removed as listener of the ANY_BA queue when a directory disappears. We currently don't resend the message, but just reply.
 */
public void testVisitUploadMessageDiskcrash(){
  Settings.set(CommonSettings.DIR_COMMONTEMPDIR,SERVER1.getAbsolutePath());
  Settings.set(ArchiveSettings.BITARCHIVE_SERVER_FILEDIR,BITARCHIVE1.getAbsolutePath());
  bas=BitarchiveServer.getInstance();
  ChannelID arcReposQ=Channels.getTheRepos();
  ChannelID anyBa=Channels.getAnyBa();
  JMSConnectionMockupMQ conn=(JMSConnectionMockupMQ)JMSConnectionFactory.getInstance();
  GenericMessageListener listener=new GenericMessageListener();
  conn.setListener(arcReposQ,listener);
  int expectedListeners=1;
  assertEquals("String_Node_Str" + anyBa + "String_Node_Str"+ expectedListeners+ "String_Node_Str",expectedListeners,conn.getListeners(anyBa).size());
  File testFile=TestInfo.UPLOADMESSAGE_TESTFILE_1;
  RemoteFile rf=TestRemoteFile.getInstance(testFile,false,false,true);
  UploadMessage msg=new UploadMessage(anyBa,arcReposQ,rf);
  bas.visit(msg);
  conn.waitForConcurrentTasksToFinish();
  expectedListeners=1;
  assertEquals("String_Node_Str" + anyBa + "String_Node_Str"+ expectedListeners+ "String_Node_Str",expectedListeners,conn.getListeners(anyBa).size());
  assertTrue("String_Node_Str",listener.messagesReceived.size() >= 1);
  FileUtils.removeRecursively(BITARCHIVE1);
  bas.visit(msg);
  conn.waitForConcurrentTasksToFinish();
  expectedListeners=0;
  assertEquals("String_Node_Str" + anyBa + "String_Node_Str"+ expectedListeners+ "String_Node_Str",expectedListeners,conn.getListeners(anyBa).size());
  assertTrue("String_Node_Str",listener.messagesReceived.size() >= 2);
}

Fixed version (ground truth):
/** 
 * Test that a BitarchiveServer is removed as listener of the ANY_BA queue when a directory disappears. We currently don't resend the message, but just reply.
 */
public void testVisitUploadMessageDiskcrash(){
  Settings.set(CommonSettings.DIR_COMMONTEMPDIR,SERVER1.getAbsolutePath());
  Settings.set(ArchiveSettings.BITARCHIVE_SERVER_FILEDIR,BITARCHIVE1.getAbsolutePath());
  bas=BitarchiveServer.getInstance();
  ChannelID arcReposQ=Channels.getTheRepos();
  ChannelID anyBa=Channels.getAnyBa();
  JMSConnectionMockupMQ conn=(JMSConnectionMockupMQ)JMSConnectionFactory.getInstance();
  GenericMessageListener listener=new GenericMessageListener();
  conn.setListener(arcReposQ,listener);
  int expectedListeners=1;
  assertEquals("String_Node_Str" + anyBa + "String_Node_Str"+ expectedListeners+ "String_Node_Str",expectedListeners,conn.getListeners(anyBa).size());
  File testFile=TestInfo.UPLOADMESSAGE_TESTFILE_1;
  RemoteFile rf=TestRemoteFile.getInstance(testFile,false,false,true);
  UploadMessage msg=new UploadMessage(anyBa,arcReposQ,rf);
  JMSConnectionMockupMQ.updateMsgID(msg,"String_Node_Str");
  bas.visit(msg);
  conn.waitForConcurrentTasksToFinish();
  expectedListeners=1;
  assertEquals("String_Node_Str" + anyBa + "String_Node_Str"+ expectedListeners+ "String_Node_Str",expectedListeners,conn.getListeners(anyBa).size());
  assertTrue("String_Node_Str",listener.messagesReceived.size() >= 1);
  FileUtils.removeRecursively(BITARCHIVE1);
  bas.visit(msg);
  conn.waitForConcurrentTasksToFinish();
  expectedListeners=0;
  assertEquals("String_Node_Str" + anyBa + "String_Node_Str"+ expectedListeners+ "String_Node_Str",expectedListeners,conn.getListeners(anyBa).size());
  assertTrue("String_Node_Str",listener.messagesReceived.size() >= 2);
}