Program: 89916
Project: 89916
Buggy source:
/** 
 * Test that a BitarchiveServer is removed as listener of the ANY_BA queue when trying to upload a file that cannot fit in the archive. We currently don't resend the message, but just reply.
 */
public void testVisitUploadMessage(){
  SERVER1.mkdirs();
  Settings.set(ArchiveSettings.BITARCHIVE_MIN_SPACE_LEFT,"String_Node_Str" + (FileUtils.getBytesFree(SERVER1) - 12000));
  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=RemoteFileFactory.getInstance(testFile,false,false,true);
  UploadMessage msg=new UploadMessage(anyBa,arcReposQ,rf);
  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() >= 1);
  assertEquals("String_Node_Str" + "String_Node_Str",msg,listener.messagesReceived.get(0));
}

Fixed version (ground truth):
/** 
 * Test that a BitarchiveServer is removed as listener of the ANY_BA queue when trying to upload a file that cannot fit in the archive. We currently don't resend the message, but just reply.
 */
public void testVisitUploadMessage(){
  SERVER1.mkdirs();
  Settings.set(ArchiveSettings.BITARCHIVE_MIN_SPACE_LEFT,"String_Node_Str" + (FileUtils.getBytesFree(SERVER1) - 12000));
  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=RemoteFileFactory.getInstance(testFile,false,false,true);
  UploadMessage msg=new UploadMessage(anyBa,arcReposQ,rf);
  JMSConnectionMockupMQ.updateMsgID(msg,"String_Node_Str");
  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() >= 1);
  assertEquals("String_Node_Str" + "String_Node_Str",msg,listener.messagesReceived.get(0));
}