Program: 74301
Project: 74301
Buggy source:
/** 
 * test if count of clients of <code>DataSet</code> is right or not 
 * @throws Exception
 */
public void testReference() throws Exception {
  openDesign(fileNameForRelation);
  JointDataSetHandle jdsHandle=(JointDataSetHandle)designHandle.findJointDataSet("String_Node_Str");
  assertEquals(0,countNum(jdsHandle));
  DataSetHandle dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  jdsHandle.addDataSet("String_Node_Str");
  assertEquals(0,countNum(jdsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().redo();
  assertEquals(1,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(0,countNum(dsHandle));
  jdsHandle.removeDataSet("String_Node_Str");
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(1,countNum(dsHandle));
  designHandle.getCommandStack().redo();
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(1,countNum(dsHandle));
  jdsHandle.drop();
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  dsHandle.drop();
  assertNull(design.findDataSet("String_Node_Str"));
  designHandle.getCommandStack().undo();
  assertNotNull(design.findDataSet("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * test if count of clients of <code>DataSet</code> is right or not
 * @throws Exception
 */
public void testReference() throws Exception {
  openDesign(fileNameForRelation);
  JointDataSetHandle jdsHandle=designHandle.findJointDataSet("String_Node_Str");
  assertEquals(0,countNum(jdsHandle));
  DataSetHandle dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  jdsHandle.addDataSet("String_Node_Str");
  assertEquals(0,countNum(jdsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().redo();
  assertEquals(1,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(0,countNum(dsHandle));
  jdsHandle.removeDataSet("String_Node_Str");
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(1,countNum(dsHandle));
  designHandle.getCommandStack().redo();
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  assertEquals(1,countNum(dsHandle));
  jdsHandle.drop();
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(0,countNum(dsHandle));
  designHandle.getCommandStack().undo();
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  assertEquals(1,countNum(dsHandle));
  dsHandle=(DataSetHandle)design.findDataSet("String_Node_Str").getHandle(design.getRoot());
  dsHandle.drop();
  assertNull(design.findDataSet("String_Node_Str"));
  designHandle.getCommandStack().undo();
  assertNotNull(design.findDataSet("String_Node_Str"));
}