Program: 81532
Project: 81532
Buggy source:
public void testRead2() throws IOException {
  InputStream inputXLS=new BufferedInputStream(getClass().getResourceAsStream(dataXLS));
  POIFSFileSystem fsInput=new POIFSFileSystem(inputXLS);
  HSSFWorkbook hssfInputWorkbook=new HSSFWorkbook(fsInput);
  HSSFSheet sheet=hssfInputWorkbook.getSheetAt(2);
  Department department;
  Map beans=new HashMap();
  List departments=new ArrayList();
  beans.put("String_Node_Str",departments);
  List chiefMappings=new ArrayList();
  chiefMappings.add(new BeanCellMapping(0,(short)1,"String_Node_Str","String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)0,"String_Node_Str","String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)1,"String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)2,"String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)3,"String_Node_Str","String_Node_Str"));
  XLSBlockReader chiefReader=new SimpleBlockReaderImpl(0,6,chiefMappings);
  List employeeMappings=new ArrayList();
  employeeMappings.add(new BeanCellMapping(7,(short)0,"String_Node_Str","String_Node_Str"));
  employeeMappings.add(new BeanCellMapping(7,(short)1,"String_Node_Str","String_Node_Str"));
  employeeMappings.add(new BeanCellMapping(7,(short)2,"String_Node_Str","String_Node_Str"));
  employeeMappings.add(new BeanCellMapping(7,(short)3,"String_Node_Str","String_Node_Str"));
  XLSBlockReader employeeReader=new SimpleBlockReaderImpl(7,7,employeeMappings);
  XLSLoopBlockReader employeesReader=new XLSForEachBlockReaderImpl(7,7,"String_Node_Str","String_Node_Str",Employee.class);
  employeesReader.addBlockReader(employeeReader);
  SectionCheck loopBreakCheck=getLoopBreakCheck();
  employeesReader.setLoopBreakCondition(loopBreakCheck);
  XLSLoopBlockReader departmentInfoReader=new XLSForEachBlockReaderImpl(0,8,"String_Node_Str","String_Node_Str",Department.class);
  departmentInfoReader.addBlockReader(chiefReader);
  departmentInfoReader.addBlockReader(employeesReader);
  departmentInfoReader.addBlockReader(new SimpleBlockReaderImpl(8,8,new ArrayList()));
  loopBreakCheck=new SimpleSectionCheck();
  loopBreakCheck.addRowCheck(new OffsetRowCheckImpl(0));
  loopBreakCheck.addRowCheck(new OffsetRowCheckImpl(1));
  departmentInfoReader.setLoopBreakCondition(loopBreakCheck);
  XLSRowCursor cursor=new XLSRowCursorImpl(sheet);
  cursor.setCurrentRowNum(0);
  departmentInfoReader.read(cursor,beans);
  assertEquals(3,departments.size());
  department=(Department)departments.get(0);
  checkDepartmentInfo(department,"String_Node_Str","String_Node_Str",new Integer(35),new Double(3000.0),new Double(0.30));
  assertEquals(5,department.getStaff().size());
  Employee employee=(Employee)department.getStaff().get(0);
  checkEmployee(employee,"String_Node_Str",new Integer(28),new Double(1500.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(1);
  checkEmployee(employee,"String_Node_Str",new Integer(32),new Double(2300.0),new Double(0.25));
  employee=(Employee)department.getStaff().get(2);
  checkEmployee(employee,"String_Node_Str",new Integer(34),new Double(2500.0),new Double(0.00));
  employee=(Employee)department.getStaff().get(3);
  checkEmployee(employee,"String_Node_Str",new Integer(34),new Double(1700.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(4);
  checkEmployee(employee,"String_Node_Str",new Integer(35),new Double(2800.0),new Double(0.20));
  department=(Department)departments.get(1);
  checkDepartmentInfo(department,"String_Node_Str","String_Node_Str",new Integer(37),new Double(2200.0),new Double(0.30));
  assertEquals(4,department.getStaff().size());
  employee=(Employee)department.getStaff().get(0);
  checkEmployee(employee,"String_Node_Str",new Integer(26),new Double(1400.0),new Double(0.20));
  employee=(Employee)department.getStaff().get(1);
  checkEmployee(employee,"String_Node_Str",new Integer(30),new Double(2100.0),new Double(0.10));
  employee=(Employee)department.getStaff().get(2);
  checkEmployee(employee,"String_Node_Str",new Integer(24),new Double(1800.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(3);
  checkEmployee(employee,"String_Node_Str",new Integer(34),new Double(1900.0),new Double(0.15));
  department=(Department)departments.get(2);
  checkDepartmentInfo(department,"String_Node_Str","String_Node_Str",new Integer(35),new Double(2900.0),new Double(0.35));
  assertEquals(4,department.getStaff().size());
  employee=(Employee)department.getStaff().get(0);
  checkEmployee(employee,"String_Node_Str",new Integer(30),new Double(2400.0),new Double(0.20));
  employee=(Employee)department.getStaff().get(1);
  checkEmployee(employee,"String_Node_Str",new Integer(32),new Double(2200.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(2);
  checkEmployee(employee,"String_Node_Str",new Integer(28),new Double(2600.0),new Double(0.10));
  employee=(Employee)department.getStaff().get(3);
  checkEmployee(employee,"String_Node_Str",new Integer(33),new Double(2150.0),new Double(0.25));
}

Fixed version (ground truth):
public void testRead2() throws IOException {
  InputStream inputXLS=new BufferedInputStream(getClass().getResourceAsStream(departmentDataXLS));
  POIFSFileSystem fsInput=new POIFSFileSystem(inputXLS);
  HSSFWorkbook hssfInputWorkbook=new HSSFWorkbook(fsInput);
  HSSFSheet sheet=hssfInputWorkbook.getSheetAt(2);
  Department department;
  Map beans=new HashMap();
  List departments=new ArrayList();
  beans.put("String_Node_Str",departments);
  List chiefMappings=new ArrayList();
  chiefMappings.add(new BeanCellMapping(0,(short)1,"String_Node_Str","String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)0,"String_Node_Str","String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)1,"String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)2,"String_Node_Str"));
  chiefMappings.add(new BeanCellMapping(3,(short)3,"String_Node_Str","String_Node_Str"));
  XLSBlockReader chiefReader=new SimpleBlockReaderImpl(0,6,chiefMappings);
  List employeeMappings=new ArrayList();
  employeeMappings.add(new BeanCellMapping(7,(short)0,"String_Node_Str","String_Node_Str"));
  employeeMappings.add(new BeanCellMapping(7,(short)1,"String_Node_Str","String_Node_Str"));
  employeeMappings.add(new BeanCellMapping(7,(short)2,"String_Node_Str","String_Node_Str"));
  employeeMappings.add(new BeanCellMapping(7,(short)3,"String_Node_Str","String_Node_Str"));
  XLSBlockReader employeeReader=new SimpleBlockReaderImpl(7,7,employeeMappings);
  XLSLoopBlockReader employeesReader=new XLSForEachBlockReaderImpl(7,7,"String_Node_Str","String_Node_Str",Employee.class);
  employeesReader.addBlockReader(employeeReader);
  SectionCheck loopBreakCheck=getLoopBreakCheck();
  employeesReader.setLoopBreakCondition(loopBreakCheck);
  XLSLoopBlockReader departmentInfoReader=new XLSForEachBlockReaderImpl(0,8,"String_Node_Str","String_Node_Str",Department.class);
  departmentInfoReader.addBlockReader(chiefReader);
  departmentInfoReader.addBlockReader(employeesReader);
  departmentInfoReader.addBlockReader(new SimpleBlockReaderImpl(8,8,new ArrayList()));
  loopBreakCheck=new SimpleSectionCheck();
  loopBreakCheck.addRowCheck(new OffsetRowCheckImpl(0));
  loopBreakCheck.addRowCheck(new OffsetRowCheckImpl(1));
  departmentInfoReader.setLoopBreakCondition(loopBreakCheck);
  XLSRowCursor cursor=new XLSRowCursorImpl(sheet);
  cursor.setCurrentRowNum(0);
  departmentInfoReader.read(cursor,beans);
  assertEquals(3,departments.size());
  department=(Department)departments.get(0);
  checkDepartmentInfo(department,"String_Node_Str","String_Node_Str",new Integer(35),new Double(3000.0),new Double(0.30));
  assertEquals(5,department.getStaff().size());
  Employee employee=(Employee)department.getStaff().get(0);
  checkEmployee(employee,"String_Node_Str",new Integer(28),new Double(1500.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(1);
  checkEmployee(employee,"String_Node_Str",new Integer(32),new Double(2300.0),new Double(0.25));
  employee=(Employee)department.getStaff().get(2);
  checkEmployee(employee,"String_Node_Str",new Integer(34),new Double(2500.0),new Double(0.00));
  employee=(Employee)department.getStaff().get(3);
  checkEmployee(employee,"String_Node_Str",new Integer(34),new Double(1700.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(4);
  checkEmployee(employee,"String_Node_Str",new Integer(35),new Double(2800.0),new Double(0.20));
  department=(Department)departments.get(1);
  checkDepartmentInfo(department,"String_Node_Str","String_Node_Str",new Integer(37),new Double(2200.0),new Double(0.30));
  assertEquals(4,department.getStaff().size());
  employee=(Employee)department.getStaff().get(0);
  checkEmployee(employee,"String_Node_Str",new Integer(26),new Double(1400.0),new Double(0.20));
  employee=(Employee)department.getStaff().get(1);
  checkEmployee(employee,"String_Node_Str",new Integer(30),new Double(2100.0),new Double(0.10));
  employee=(Employee)department.getStaff().get(2);
  checkEmployee(employee,"String_Node_Str",new Integer(24),new Double(1800.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(3);
  checkEmployee(employee,"String_Node_Str",new Integer(34),new Double(1900.0),new Double(0.15));
  department=(Department)departments.get(2);
  checkDepartmentInfo(department,"String_Node_Str","String_Node_Str",new Integer(35),new Double(2900.0),new Double(0.35));
  assertEquals(4,department.getStaff().size());
  employee=(Employee)department.getStaff().get(0);
  checkEmployee(employee,"String_Node_Str",new Integer(30),new Double(2400.0),new Double(0.20));
  employee=(Employee)department.getStaff().get(1);
  checkEmployee(employee,"String_Node_Str",new Integer(32),new Double(2200.0),new Double(0.15));
  employee=(Employee)department.getStaff().get(2);
  checkEmployee(employee,"String_Node_Str",new Integer(28),new Double(2600.0),new Double(0.10));
  employee=(Employee)department.getStaff().get(3);
  checkEmployee(employee,"String_Node_Str",new Integer(33),new Double(2150.0),new Double(0.25));
}