Program: 89915
Project: 89915
Buggy source:
/** 
 * Test that monitor can receive and aggregate data from more than one BitarchiveServer and aggregate the data and upload.
 * @throws ArgumentNotValid
 * @throws UnknownID
 * @throws IOFailure        it via RemoteFile
 */
public void testBatchEndedMessageAggregation() throws InterruptedException {
  BitarchiveMonitorServer bms=BitarchiveMonitorServer.getInstance();
  TestMessageListener listener=new TestMessageListener();
  con.setListener(Channels.getTheRepos(),listener);
  con.setListener(Channels.getAllBa(),listener);
  File output_file=new File(TestInfo.BAMON_WORKING,"String_Node_Str");
  BatchMessage bm=new BatchMessage(Channels.getTheBamon(),Channels.getTheRepos(),new ChecksumJob(),Settings.get(CommonSettings.USE_REPLICA_ID));
  JMSConnectionMockupMQ.updateMsgID(bm,"String_Node_Str");
  String baID1="String_Node_Str";
  HeartBeatMessage hbm=new HeartBeatMessage(Channels.getTheBamon(),baID1);
  String baID2="String_Node_Str";
  HeartBeatMessage hbm2=new HeartBeatMessage(Channels.getTheBamon(),baID2);
  bms.visit(hbm);
  bms.visit(hbm2);
  con.waitForConcurrentTasksToFinish();
  bms.visit(bm);
  con.waitForConcurrentTasksToFinish();
  String forwardedID=((BatchMessage)listener.getAllReceived().get(0)).getID();
  File data1=new File(TestInfo.BAMON_WORKING,"String_Node_Str");
  File data2=new File(TestInfo.BAMON_WORKING,"String_Node_Str");
  RemoteFile rf1=RemoteFileFactory.getInstance(data1,true,false,true);
  BatchEndedMessage bem1=new BatchEndedMessage(Channels.getTheBamon(),baID1,forwardedID,rf1);
  JMSConnectionMockupMQ.updateMsgID(bem1,"String_Node_Str");
  RemoteFile rf2=RemoteFileFactory.getInstance(data2,true,false,true);
  BatchEndedMessage bem2=new BatchEndedMessage(Channels.getTheBamon(),baID2,forwardedID,rf2);
  JMSConnectionMockupMQ.updateMsgID(bem2,"String_Node_Str");
  bms.visit(bem1);
  bms.visit(bem2);
  con.waitForConcurrentTasksToFinish();
synchronized (this) {
    wait(100);
  }
  bms.close();
  assertEquals("String_Node_Str",2,listener.getNumReceived());
  List<NetarkivetMessage> l=listener.getAllReceived();
  BatchReplyMessage brmsg=null;
  for (  NetarkivetMessage naMsg : l) {
    if (naMsg instanceof BatchReplyMessage) {
      brmsg=(BatchReplyMessage)naMsg;
    }
  }
  brmsg.getResultFile().copyTo(output_file);
  FileAsserts.assertFileNumberOfLines("String_Node_Str" + "String_Node_Str",output_file,2);
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",output_file);
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",output_file);
  int expected_length=FileUtils.readBinaryFile(data1).length + FileUtils.readBinaryFile(data2).length;
  int actual_length=FileUtils.readBinaryFile(output_file).length;
  assertEquals("String_Node_Str",expected_length,actual_length);
  assertTrue("String_Node_Str",((TestRemoteFile)rf1).isDeleted());
  assertTrue("String_Node_Str",((TestRemoteFile)rf2).isDeleted());
}

Fixed version (ground truth):
/** 
 * Test that monitor can receive and aggregate data from more than one BitarchiveServer and aggregate the data and upload.
 * @throws ArgumentNotValid
 * @throws UnknownID
 * @throws IOFailure        it via RemoteFile
 */
public void testBatchEndedMessageAggregation() throws InterruptedException {
  BitarchiveMonitorServer bms=BitarchiveMonitorServer.getInstance();
  TestMessageListener listener=new TestMessageListener();
  con.setListener(Channels.getTheRepos(),listener);
  con.setListener(Channels.getAllBa(),listener);
  File output_file=new File(TestInfo.BAMON_WORKING,"String_Node_Str");
  BatchMessage bm=new BatchMessage(Channels.getTheBamon(),Channels.getTheRepos(),new ChecksumJob(),Settings.get(CommonSettings.USE_REPLICA_ID));
  JMSConnectionMockupMQ.updateMsgID(bm,"String_Node_Str");
  String baID1="String_Node_Str";
  HeartBeatMessage hbm=new HeartBeatMessage(Channels.getTheBamon(),baID1);
  String baID2="String_Node_Str";
  HeartBeatMessage hbm2=new HeartBeatMessage(Channels.getTheBamon(),baID2);
  bms.visit(hbm);
  bms.visit(hbm2);
  con.waitForConcurrentTasksToFinish();
  bms.visit(bm);
  con.waitForConcurrentTasksToFinish();
  String forwardedID=((BatchMessage)listener.getAllReceived().get(0)).getID();
  File data1=new File(TestInfo.BAMON_WORKING,"String_Node_Str");
  File data2=new File(TestInfo.BAMON_WORKING,"String_Node_Str");
  RemoteFile rf1=RemoteFileFactory.getInstance(data1,true,false,true);
  BatchEndedMessage bem1=new BatchEndedMessage(Channels.getTheBamon(),baID1,forwardedID,rf1);
  JMSConnectionMockupMQ.updateMsgID(bem1,"String_Node_Str");
  RemoteFile rf2=RemoteFileFactory.getInstance(data2,true,false,true);
  BatchEndedMessage bem2=new BatchEndedMessage(Channels.getTheBamon(),baID2,forwardedID,rf2);
  JMSConnectionMockupMQ.updateMsgID(bem2,"String_Node_Str");
  bms.visit(bem1);
  bms.visit(bem2);
  con.waitForConcurrentTasksToFinish();
synchronized (this) {
    wait(200);
  }
  bms.close();
  assertEquals("String_Node_Str",2,listener.getNumReceived());
  List<NetarkivetMessage> l=listener.getAllReceived();
  BatchReplyMessage brmsg=null;
  for (  NetarkivetMessage naMsg : l) {
    if (naMsg instanceof BatchReplyMessage) {
      brmsg=(BatchReplyMessage)naMsg;
    }
  }
  brmsg.getResultFile().copyTo(output_file);
  FileAsserts.assertFileNumberOfLines("String_Node_Str" + "String_Node_Str",output_file,2);
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",output_file);
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",output_file);
  int expected_length=FileUtils.readBinaryFile(data1).length + FileUtils.readBinaryFile(data2).length;
  int actual_length=FileUtils.readBinaryFile(output_file).length;
  assertEquals("String_Node_Str",expected_length,actual_length);
  assertTrue("String_Node_Str",((TestRemoteFile)rf1).isDeleted());
  assertTrue("String_Node_Str",((TestRemoteFile)rf2).isDeleted());
}