Program: 89919
Project: 89919
Buggy source:
/** 
 * Test that a visit(RemoveAndGetMessage) call actually removes (moves) the file.
 * @throws Exception
 */
public void testVisitRemoveAndGetFileMessage() throws Exception {
  String arcFile=TestInfo.BA1_FILENAME;
  String dummyReplicaId="String_Node_Str";
  String checksum=TestInfo.BA1_CHECKSUM;
  String credentials=Settings.get(ArchiveSettings.ENVIRONMENT_THIS_CREDENTIALS);
  Settings.set(ArchiveSettings.BITARCHIVE_SERVER_FILEDIR,BITARCHIVE1.getAbsolutePath());
  Settings.set(CommonSettings.DIR_COMMONTEMPDIR,SERVER1.getAbsolutePath());
  bas=BitarchiveServer.getInstance();
  File baFile=TestInfo.BA1_ORG_FILE;
  File backupFile=TestInfo.BA1_ATTIC_FILE;
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  RemoveAndGetFileMessage m1=new RemoveAndGetFileMessage(arcFile + "String_Node_Str",dummyReplicaId,checksum,credentials);
  bas.visit(m1);
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  RemoveAndGetFileMessage m2=new RemoveAndGetFileMessage(arcFile,dummyReplicaId,checksum + "String_Node_Str",credentials);
  bas.visit(m2);
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  LogUtils.flushLogs(BitarchiveServer.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  assertFalse("String_Node_Str",m2.isOk());
  RemoveAndGetFileMessage m3=new RemoveAndGetFileMessage(arcFile,dummyReplicaId,checksum,credentials + "String_Node_Str");
  bas.visit(m3);
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  LogUtils.flushLogs(BitarchiveServer.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  assertFalse("String_Node_Str",m3.isOk());
  RemoveAndGetFileMessage m4=new RemoveAndGetFileMessage(arcFile,dummyReplicaId,checksum,credentials);
  long len=baFile.length();
  bas.visit(m4);
  MessageAsserts.assertMessageOk("String_Node_Str",m4);
  assertFalse("String_Node_Str",baFile.exists());
  assertTrue("String_Node_Str",backupFile.exists());
  LogUtils.flushLogs(BitarchiveServer.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  File f=m4.getData();
  assertNotNull("String_Node_Str",f);
  assertEquals("String_Node_Str",len,f.length());
  assertEquals("String_Node_Str",0,TestRemoteFile.remainingFiles().size());
}

Fixed version (ground truth):
/** 
 * Test that a visit(RemoveAndGetMessage) call actually removes (moves) the file.
 * @throws Exception
 */
public void testVisitRemoveAndGetFileMessage() throws Exception {
  String arcFile=TestInfo.BA1_FILENAME;
  String dummyReplicaId="String_Node_Str";
  String checksum=TestInfo.BA1_CHECKSUM;
  String credentials=Settings.get(ArchiveSettings.ENVIRONMENT_THIS_CREDENTIALS);
  Settings.set(ArchiveSettings.BITARCHIVE_SERVER_FILEDIR,BITARCHIVE1.getAbsolutePath());
  Settings.set(CommonSettings.DIR_COMMONTEMPDIR,SERVER1.getAbsolutePath());
  bas=BitarchiveServer.getInstance();
  File baFile=TestInfo.BA1_ORG_FILE;
  File backupFile=TestInfo.BA1_ATTIC_FILE;
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  RemoveAndGetFileMessage m1=new RemoveAndGetFileMessage(arcFile + "String_Node_Str",dummyReplicaId,checksum,credentials);
  bas.visit(m1);
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  RemoveAndGetFileMessage m2=new RemoveAndGetFileMessage(arcFile,dummyReplicaId,checksum + "String_Node_Str",credentials);
  JMSConnectionMockupMQ.updateMsgID(m2,"String_Node_Str");
  bas.visit(m2);
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  LogUtils.flushLogs(BitarchiveServer.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  assertFalse("String_Node_Str",m2.isOk());
  RemoveAndGetFileMessage m3=new RemoveAndGetFileMessage(arcFile,dummyReplicaId,checksum,credentials + "String_Node_Str");
  JMSConnectionMockupMQ.updateMsgID(m3,"String_Node_Str");
  bas.visit(m3);
  assertTrue("String_Node_Str",baFile.exists());
  assertFalse("String_Node_Str",backupFile.exists());
  LogUtils.flushLogs(BitarchiveServer.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  assertFalse("String_Node_Str",m3.isOk());
  RemoveAndGetFileMessage m4=new RemoveAndGetFileMessage(arcFile,dummyReplicaId,checksum,credentials);
  long len=baFile.length();
  JMSConnectionMockupMQ.updateMsgID(m4,"String_Node_Str");
  bas.visit(m4);
  MessageAsserts.assertMessageOk("String_Node_Str",m4);
  assertFalse("String_Node_Str",baFile.exists());
  assertTrue("String_Node_Str",backupFile.exists());
  LogUtils.flushLogs(BitarchiveServer.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  File f=m4.getData();
  assertNotNull("String_Node_Str",f);
  assertEquals("String_Node_Str",len,f.length());
  assertEquals("String_Node_Str",0,TestRemoteFile.remainingFiles().size());
}