Program: 76776
Project: 76776
Buggy source:
/** 
 * Tested cases: <ul> <li>The getProperty() algorithm. If the structure member has no local value, uses values of the referred style. <li>The back reference must be right for undo/redo. <li>The back reference must be right if the style member is set to a new value. <li>Circular references must throw exceptions. </ul>
 * @throws Exception
 */
public void testStyle() throws Exception {
  openDesign(inputFile);
  StyleHandle style2=designHandle.findStyle("String_Node_Str");
  StyleHandle style3=designHandle.findStyle("String_Node_Str");
  Iterator highlightRules=style2.highlightRulesIterator();
  assert(highlightRules.hasNext());
  HighlightRuleHandle style2Highlight=(HighlightRuleHandle)highlightRules.next();
  assertEquals(DesignChoiceConstants.TEXT_ALIGN_RIGHT,style2Highlight.getTextAlign());
  assertEquals(ColorPropertyType.RED,style2Highlight.getColor().getStringValue());
  assertNull(style2Highlight.getProperty(IStyleModel.HIGHLIGHT_RULES_PROP));
  StyleHandle style1=designHandle.findStyle("String_Node_Str");
  List refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(1,refs.size());
  BackRef ref1=(BackRef)refs.get(0);
  assertEquals("String_Node_Str",ref1.getElement().getName());
  assertEquals("String_Node_Str",ref1.getPropertyName());
  style2Highlight.drop();
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(0,refs.size());
  designHandle.getCommandStack().undo();
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(1,refs.size());
  designHandle.getCommandStack().redo();
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(0,refs.size());
  designHandle.getCommandStack().undo();
  style2Highlight.setStyle(style3);
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(0,refs.size());
  refs=((ReferenceableElement)style3.getElement()).getClientList();
  assertEquals(1,refs.size());
  assertEquals("String_Node_Str",ref1.getElement().getName());
  assertEquals("String_Node_Str",ref1.getPropertyName());
  try {
    style2Highlight.setStyle(style2);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
  Iterator style3HighlightRules=style3.highlightRulesIterator();
  assertTrue(style3HighlightRules.hasNext());
  HighlightRuleHandle style3Highlight=(HighlightRuleHandle)style3HighlightRules.next();
  try {
    style3Highlight.setStyleName("String_Node_Str");
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
  HighlightRule newRule1=StructureFactory.createHighlightRule();
  newRule1.setProperty(HighlightRule.STYLE_MEMBER,"String_Node_Str");
  try {
    style3.getPropertyHandle(StyleHandle.HIGHLIGHT_RULES_PROP).addItem(newRule1);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
}

Fixed version (ground truth):
/** 
 * Tested cases: <ul> <li>The getProperty() algorithm. If the structure member has no local value, uses values of the referred style. <li>The back reference must be right for undo/redo. <li>The back reference must be right if the style member is set to a new value. <li>Circular references must throw exceptions. </ul>
 * @throws Exception
 */
public void testStyle() throws Exception {
  openDesign(inputFile);
  StyleHandle style2=designHandle.findStyle("String_Node_Str");
  StyleHandle style3=designHandle.findStyle("String_Node_Str");
  Iterator highlightRules=style2.highlightRulesIterator();
  assert(highlightRules.hasNext());
  HighlightRuleHandle style2Highlight=(HighlightRuleHandle)highlightRules.next();
  assertEquals(DesignChoiceConstants.TEXT_ALIGN_RIGHT,style2Highlight.getTextAlign());
  assertEquals(ColorPropertyType.RED,style2Highlight.getColor().getStringValue());
  assertNull(style2Highlight.getProperty(IStyleModel.HIGHLIGHT_RULES_PROP));
  StyleHandle style1=designHandle.findStyle("String_Node_Str");
  List refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(1,refs.size());
  BackRef ref1=(BackRef)refs.get(0);
  assertEquals("String_Node_Str",ref1.getElement().getName());
  assertEquals("String_Node_Str",ref1.getPropertyName());
  style2Highlight.drop();
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(0,refs.size());
  designHandle.getCommandStack().undo();
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(1,refs.size());
  designHandle.getCommandStack().redo();
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(0,refs.size());
  designHandle.getCommandStack().undo();
  style2Highlight.setStyle(style3);
  assertEquals(style3,style2Highlight.getStyle());
  refs=((ReferenceableElement)style1.getElement()).getClientList();
  assertEquals(0,refs.size());
  refs=((ReferenceableElement)style3.getElement()).getClientList();
  assertEquals(1,refs.size());
  assertEquals("String_Node_Str",ref1.getElement().getName());
  assertEquals("String_Node_Str",ref1.getPropertyName());
  try {
    style2Highlight.setStyle(style2);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
  Iterator style3HighlightRules=style3.highlightRulesIterator();
  assertTrue(style3HighlightRules.hasNext());
  HighlightRuleHandle style3Highlight=(HighlightRuleHandle)style3HighlightRules.next();
  try {
    style3Highlight.setStyleName("String_Node_Str");
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
  HighlightRule newRule1=StructureFactory.createHighlightRule();
  newRule1.setProperty(HighlightRule.STYLE_MEMBER,"String_Node_Str");
  try {
    style3.getPropertyHandle(StyleHandle.HIGHLIGHT_RULES_PROP).addItem(newRule1);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
}