Program: 89580
Project: 89580
Buggy source:
public void testMoveAwayForeignFiles() throws Exception {
  Method m=ReflectUtils.getPrivateMethod(HarvestDocumentation.class,"String_Node_Str",ArchiveProfile.class,File.class,IngestableFiles.class);
  Settings.set(HarvesterSettings.HARVEST_CONTROLLER_OLDJOBSDIR,new File(TestInfo.WORKING_DIR,"String_Node_Str").getAbsolutePath());
  TestInfo.WORKING_DIR.mkdirs();
  File arcsDir=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME);
  TestFileUtils.copyDirectoryNonCVS(TestInfo.METADATA_TEST_DIR_INCONSISTENT,arcsDir);
  FileUtils.copyFile(new File(TestInfo.METADATA_TEST_DIR,"String_Node_Str"),new File(arcsDir,"String_Node_Str"));
  JobInfo harvestJob=new JobInfoTestImpl(42L,117L);
  HeritrixFiles files117=new HeritrixFiles(TestInfo.WORKING_DIR,harvestJob);
  OkIngestables=new IngestableFiles(files117);
  m.invoke(null,ArchiveProfile.ARC_PROFILE,arcsDir,OkIngestables);
  LogUtils.flushLogs(HarvestDocumentation.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  String badFile="String_Node_Str";
  String goodFile="String_Node_Str";
  System.out.println("String_Node_Str");
  File oddjobsDir=new File(TestInfo.WORKING_DIR,"String_Node_Str");
  File[] oddDirs=oddjobsDir.listFiles();
  assertTrue(oddDirs.length == 1);
  for (  File oddDir : oddDirs) {
    System.out.println(oddDir.getAbsolutePath());
  }
  File oldJobsDir43=oddDirs[0];
  assertTrue("String_Node_Str",oldJobsDir43.getName().startsWith("String_Node_Str"));
  File movedFile=new File(oldJobsDir43,badFile);
  assertTrue("String_Node_Str" + movedFile + "String_Node_Str",movedFile.exists());
  File goneFile=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME + "String_Node_Str" + badFile);
  assertFalse("String_Node_Str" + goneFile + "String_Node_Str",goneFile.exists());
  File keptFile=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME + "String_Node_Str" + goodFile);
  assertTrue("String_Node_Str" + keptFile + "String_Node_Str",keptFile.exists());
}

Fixed version (ground truth):
/** 
 * Test that any files not part of the current harvest are moved away to the oldjobsdir during postprocessing. This test includes a check for issue https://sbforge.org/jira/browse/NAS-2270 which resulted in at most one old file being movied away.
 * @throws Exception
 */
public void testMoveAwayForeignFiles() throws Exception {
  Method m=ReflectUtils.getPrivateMethod(HarvestDocumentation.class,"String_Node_Str",ArchiveProfile.class,File.class,IngestableFiles.class);
  Settings.set(HarvesterSettings.HARVEST_CONTROLLER_OLDJOBSDIR,new File(TestInfo.WORKING_DIR,"String_Node_Str").getAbsolutePath());
  TestInfo.WORKING_DIR.mkdirs();
  File arcsDir=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME);
  TestFileUtils.copyDirectoryNonCVS(TestInfo.METADATA_TEST_DIR_INCONSISTENT,arcsDir);
  FileUtils.copyFile(new File(TestInfo.METADATA_TEST_DIR,"String_Node_Str"),new File(arcsDir,"String_Node_Str"));
  JobInfo harvestJob=new JobInfoTestImpl(42L,117L);
  HeritrixFiles files117=new HeritrixFiles(TestInfo.WORKING_DIR,harvestJob);
  OkIngestables=new IngestableFiles(files117);
  m.invoke(null,ArchiveProfile.ARC_PROFILE,arcsDir,OkIngestables);
  LogUtils.flushLogs(HarvestDocumentation.class.getName());
  FileAsserts.assertFileContains("String_Node_Str","String_Node_Str",TestInfo.LOG_FILE);
  String badFile="String_Node_Str";
  String goodFile="String_Node_Str";
  System.out.println("String_Node_Str");
  File oddjobsDir=new File(TestInfo.WORKING_DIR,"String_Node_Str");
  File[] oddDirs=oddjobsDir.listFiles();
  assertTrue(oddDirs.length == 1);
  for (  File oddDir : oddDirs) {
    System.out.println(oddDir.getAbsolutePath());
  }
  File oldJobsDir43=oddDirs[0];
  assertTrue("String_Node_Str",oldJobsDir43.getName().startsWith("String_Node_Str"));
  File movedFile=new File(oldJobsDir43,badFile);
  assertTrue("String_Node_Str" + movedFile + "String_Node_Str",movedFile.exists());
  File goneFile=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME + "String_Node_Str" + badFile);
  assertFalse("String_Node_Str" + goneFile + "String_Node_Str",goneFile.exists());
  File keptFile=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME + "String_Node_Str" + goodFile);
  assertTrue("String_Node_Str" + keptFile + "String_Node_Str",keptFile.exists());
  File badMetadataFile=new File(TestInfo.WORKING_DIR,Constants.ARCDIRECTORY_NAME + "String_Node_Str");
  assertFalse("String_Node_Str" + badMetadataFile + "String_Node_Str",badMetadataFile.exists());
  File movedMetadataFile=new File(oldJobsDir43,badMetadataFile.getName());
  assertTrue("String_Node_Str" + movedMetadataFile + "String_Node_Str",movedMetadataFile.exists());
}