Program: 90193
Project: 90193
Buggy source:
/** 
 * Checks, if the CDXOriginCrawlLogIterator works with password protected contents, where one crawl.log corresponds with two CDXlines, and the correct one, (the last one) needs to be selected. bug 680
 * @throws Exception
 */
public void testbug680() throws Exception {
  Method sortCDX=ReflectUtils.getPrivateMethod(CrawlLogIndexCache.class,"String_Node_Str",File.class,File.class);
  Method sortCrawlLog=ReflectUtils.getPrivateMethod(CrawlLogIndexCache.class,"String_Node_Str",File.class,File.class);
  File unsortedCrawlLogFile=new File(TestInfo.CRAWLLOGS_DIR,"String_Node_Str");
  File sortedCrawlLogFile=new File(TestInfo.CRAWLLOGS_DIR,"String_Node_Str");
  File unsortedCDXFile=new File(TestInfo.CDXDATACACHE_DIR,"String_Node_Str");
  File sortedCDXFile=new File(TestInfo.CDXDATACACHE_DIR,"String_Node_Str");
  sortCrawlLog.invoke(null,unsortedCrawlLogFile,sortedCrawlLogFile);
  sortCDX.invoke(null,unsortedCDXFile,sortedCDXFile);
  BufferedReader cdx=new BufferedReader(new FileReader(sortedCDXFile));
  CDXOriginCrawlLogIterator it=new CDXOriginCrawlLogIterator(sortedCrawlLogFile,cdx);
  String privateUrl="String_Node_Str";
  assertTrue("String_Node_Str",it.hasNext());
  boolean foundPrivateUrl=false;
  CrawlDataItem item=null;
  while (!foundPrivateUrl && it.hasNext()) {
    item=it.next();
    if (item.getURL().equals(privateUrl)) {
      foundPrivateUrl=true;
    }
  }
  assertTrue("String_Node_Str",foundPrivateUrl);
  String correctOrigin="String_Node_Str";
  assertTrue("String_Node_Str",item.getOrigin().equals(correctOrigin));
}

Fixed version (ground truth):
/** 
 * Checks, if the CDXOriginCrawlLogIterator works with password protected contents, where one crawl.log corresponds with two CDXlines, and the correct one, (the last one) needs to be selected. bug 680
 * @throws Exception
 */
public void testbug680() throws Exception {
  Method sortCDX=ReflectUtils.getPrivateMethod(CrawlLogIndexCache.class,"String_Node_Str",File.class,File.class);
  Method sortCrawlLog=ReflectUtils.getPrivateMethod(CrawlLogIndexCache.class,"String_Node_Str",File.class,File.class);
  File unsortedCrawlLogFile=new File(TestInfo.CRAWLLOGS_DIR,"String_Node_Str");
  File sortedCrawlLogFile=new File(TestInfo.CRAWLLOGS_DIR,"String_Node_Str");
  File unsortedCDXFile=new File(TestInfo.CDXDATACACHE_DIR,"String_Node_Str");
  File sortedCDXFile=new File(TestInfo.CDXDATACACHE_DIR,"String_Node_Str");
  sortCrawlLog.invoke(null,unsortedCrawlLogFile,sortedCrawlLogFile);
  sortCDX.invoke(null,unsortedCDXFile,sortedCDXFile);
  BufferedReader cdx=new BufferedReader(new FileReader(sortedCDXFile));
  CDXOriginCrawlLogIterator it=new CDXOriginCrawlLogIterator(sortedCrawlLogFile,cdx);
  String privateUrl="String_Node_Str";
  assertTrue("String_Node_Str",it.hasNext());
  boolean foundPrivateUrl=false;
  CrawlDataItem item=null;
  while (!foundPrivateUrl && it.hasNext()) {
    item=it.next();
    if (item.getURL().equals(privateUrl)) {
      foundPrivateUrl=true;
    }
  }
  assertTrue("String_Node_Str",foundPrivateUrl);
  String correctOrigin="String_Node_Str";
  assertTrue("String_Node_Str",item.getOrigin().equals(correctOrigin));
  unsortedCrawlLogFile=new File(TestInfo.CRAWLLOGS_DIR,"String_Node_Str");
  sortedCrawlLogFile=new File(TestInfo.CRAWLLOGS_DIR,"String_Node_Str");
  unsortedCDXFile=new File(TestInfo.CDXDATACACHE_DIR,"String_Node_Str");
  sortedCDXFile=new File(TestInfo.CDXDATACACHE_DIR,"String_Node_Str");
  sortCrawlLog.invoke(null,unsortedCrawlLogFile,sortedCrawlLogFile);
  sortCDX.invoke(null,unsortedCDXFile,sortedCDXFile);
  cdx=new BufferedReader(new FileReader(sortedCDXFile));
  it=new CDXOriginCrawlLogIterator(sortedCrawlLogFile,cdx);
  assertTrue("String_Node_Str",it.hasNext());
  foundPrivateUrl=false;
  item=null;
  while (!foundPrivateUrl && it.hasNext()) {
    item=it.next();
    if (item.getURL().equals(privateUrl)) {
      foundPrivateUrl=true;
    }
  }
  assertTrue("String_Node_Str",foundPrivateUrl);
  correctOrigin="String_Node_Str";
  assertTrue("String_Node_Str" + correctOrigin + "String_Node_Str"+ item.getOrigin()+ "String_Node_Str",item.getOrigin().equals(correctOrigin));
}