Program: 13423
Project: 13423
Buggy source:
public void testCreateNewComplexPage() throws Exception {
  String masterSpreadName="String_Node_Str";
  String INITIAL_FRAME_LABEL="String_Node_Str";
  MasterSpread masterSpread=inDesignDoc.getMasterSpread(masterSpreadName);
  assertNotNull("String_Node_Str",masterSpread);
  int overrideableFrameCount=0;
  for (  TextFrame frame : masterSpread.getAllFrames()) {
    if (frame.isOverrideable())     overrideableFrameCount++;
  }
  Spread spread=null;
  Page page=null;
  spread=inDesignDoc.getSpread(0);
  spread.setMasterSpread(masterSpread);
  page=spread.getOddPage();
  assertNotNull("String_Node_Str",page);
  int spreadChildCount=spread.getChildren().size();
  spread.overrideMasterSpreadObjects();
  assertEquals("String_Node_Str",overrideableFrameCount,spread.getAllFrames().size());
  assertEquals("String_Node_Str",overrideableFrameCount + spreadChildCount,spread.getChildren().size());
  int originalChildCountAfterOverride=spread.getChildren().size();
  String targetLabel=INITIAL_FRAME_LABEL + (page.getPageSide().equals(PageSideOption.LEFT_HAND) ? "String_Node_Str" : "String_Node_Str");
  TextFrame frame=InxHelper.getFrameForLabel(spread,targetLabel);
  assertNotNull("String_Node_Str" + INITIAL_FRAME_LABEL + "String_Node_Str",frame);
  assertTrue("String_Node_Str",frame.getChildren().size() > 0);
  InDesignComponent wrapPrefs=null;
  for (  InDesignComponent child : frame.getChildren()) {
    if ("String_Node_Str".equals(child.getInxTagName())) {
      wrapPrefs=child;
      break;
    }
  }
  assertNotNull("String_Node_Str",wrapPrefs);
  assertNotNull("String_Node_Str",incopyArticle01);
  Story incxStory=InxHelper.getStoryForIncxDoc(inDesignDoc,incopyArticle01);
  int txsrCnt=0;
  Iterator<TextStyleRange> iter=incxStory.getTextStyleRangeIterator();
  while (iter.hasNext()) {
    iter.next();
    txsrCnt++;
  }
  assertTrue("String_Node_Str",txsrCnt > 0);
  assertNotNull("String_Node_Str",incxStory);
  frame.setParentStory(incxStory);
  assertEquals("String_Node_Str",incxStory,frame.getParentStory());
  File inxFile=File.createTempFile("String_Node_Str","String_Node_Str");
  System.err.println("String_Node_Str" + inxFile.getAbsolutePath());
  InxWriter writer=new InxWriter(inxFile);
  writer.write(inDesignDoc);
  assertTrue("String_Node_Str",inxFile.exists());
  assertTrue("String_Node_Str",inxFile.length() > 0);
  assertTrue("String_Node_Str",inxFile.length() > 1000);
  Document inxDom=DataUtil.constructNonValidatingDocumentBuilder().parse(inxFile);
  assertNotNull("String_Node_Str",inxDom);
  Element docElem=inxDom.getDocumentElement();
  assertNotNull("String_Node_Str",docElem);
  assertEquals("String_Node_Str","String_Node_Str",docElem.getNodeName());
  InDesignDocument newDoc=new InDesignDocument();
  newDoc.load(docElem);
  assertEquals("String_Node_Str",1,newDoc.getSpreads().size());
  spread=newDoc.getSpread(0);
  assertNotNull("String_Node_Str",spread);
  assertEquals("String_Node_Str",originalChildCountAfterOverride,spread.getChildren().size());
  assertEquals("String_Node_Str",overrideableFrameCount,spread.getAllFrames().size());
  page=spread.getOddPage();
  assertNotNull("String_Node_Str",page);
}

Fixed version (ground truth):
public void testCreateNewComplexPage() throws Exception {
  String masterSpreadName="String_Node_Str";
  String INITIAL_FRAME_LABEL="String_Node_Str";
  MasterSpread masterSpread=inDesignDoc.getMasterSpread(masterSpreadName);
  assertNotNull("String_Node_Str",masterSpread);
  int overrideableFrameCount=0;
  for (  TextFrame frame : masterSpread.getAllFrames()) {
    if (frame.isOverrideable())     overrideableFrameCount++;
  }
  Spread spread=null;
  Page page=null;
  spread=inDesignDoc.getSpread(0);
  spread.setMasterSpread(masterSpread);
  assertEquals(0,spread.getSpreadIndex());
  page=spread.getOddPage();
  assertNotNull("String_Node_Str",page);
  assertEquals("String_Node_Str",1,spread.getPages().size());
  spread.addPage(2);
  assertEquals("String_Node_Str",2,spread.getPages().size());
  page=spread.getEvenPage();
  assertNotNull("String_Node_Str",page);
  spread.removePage(page);
  assertEquals("String_Node_Str",1,spread.getPages().size());
  page=spread.getEvenPage();
  assertNull("String_Node_Str",page);
  page=spread.getOddPage();
  assertNotNull("String_Node_Str");
  int spreadChildCount=spread.getChildren().size();
  spread.overrideMasterSpreadObjects();
  assertEquals("String_Node_Str",overrideableFrameCount,spread.getAllFrames().size());
  assertEquals("String_Node_Str",overrideableFrameCount + spreadChildCount,spread.getChildren().size());
  int originalChildCountAfterOverride=spread.getChildren().size();
  String targetLabel=INITIAL_FRAME_LABEL + (page.getPageSide().equals(PageSideOption.LEFT_HAND) ? "String_Node_Str" : "String_Node_Str");
  TextFrame frame=InxHelper.getFrameForLabel(spread,targetLabel);
  assertNotNull("String_Node_Str" + INITIAL_FRAME_LABEL + "String_Node_Str",frame);
  assertTrue("String_Node_Str",frame.getChildren().size() > 0);
  InDesignComponent wrapPrefs=null;
  for (  InDesignComponent child : frame.getChildren()) {
    if ("String_Node_Str".equals(child.getInxTagName())) {
      wrapPrefs=child;
      break;
    }
  }
  assertNotNull("String_Node_Str",wrapPrefs);
  assertNotNull("String_Node_Str",incopyArticle01);
  Story incxStory=InxHelper.getStoryForIncxDoc(inDesignDoc,incopyArticle01);
  int txsrCnt=0;
  Iterator<TextStyleRange> iter=incxStory.getTextStyleRangeIterator();
  while (iter.hasNext()) {
    iter.next();
    txsrCnt++;
  }
  assertTrue("String_Node_Str",txsrCnt > 0);
  assertNotNull("String_Node_Str",incxStory);
  frame.setParentStory(incxStory);
  assertEquals("String_Node_Str",incxStory,frame.getParentStory());
  File inxFile=File.createTempFile("String_Node_Str","String_Node_Str");
  System.err.println("String_Node_Str" + inxFile.getAbsolutePath());
  InxWriter writer=new InxWriter(inxFile);
  writer.write(inDesignDoc);
  assertTrue("String_Node_Str",inxFile.exists());
  assertTrue("String_Node_Str",inxFile.length() > 0);
  assertTrue("String_Node_Str",inxFile.length() > 1000);
  Document inxDom=DataUtil.constructNonValidatingDocumentBuilder().parse(inxFile);
  assertNotNull("String_Node_Str",inxDom);
  Element docElem=inxDom.getDocumentElement();
  assertNotNull("String_Node_Str",docElem);
  assertEquals("String_Node_Str","String_Node_Str",docElem.getNodeName());
  InDesignDocument newDoc=new InDesignDocument();
  newDoc.load(docElem);
  assertEquals("String_Node_Str",1,newDoc.getSpreads().size());
  spread=newDoc.getSpread(0);
  assertNotNull("String_Node_Str",spread);
  assertEquals("String_Node_Str",originalChildCountAfterOverride,spread.getChildren().size());
  assertEquals("String_Node_Str",overrideableFrameCount,spread.getAllFrames().size());
  page=spread.getOddPage();
  assertNotNull("String_Node_Str",page);
}