Program: 64985
Project: 64985
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));
  assertNull(style2Highlight.getProperty(HighlightRule.VALUE2_MEMBER));
  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(HighlightRule.STYLE_MEMBER,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(HighlightRule.STYLE_MEMBER,ref1.getPropertyName());
  style2Highlight.setStyle(null);
  assertNull(style2Highlight.getStyle());
  assertNull(style2Highlight.getProperty(HighlightRule.STYLE_MEMBER));
  try {
    style2Highlight.setStyle(style2);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
  style2Highlight.setStyle(style3);
  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");
  StyleHandle style4=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));
  assertNull(style2Highlight.getProperty(HighlightRule.VALUE2_MEMBER));
  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(HighlightRule.STYLE_MEMBER,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(HighlightRule.STYLE_MEMBER,ref1.getPropertyName());
  style2Highlight.setStyle(null);
  assertNull(style2Highlight.getStyle());
  assertNull(style2Highlight.getProperty(HighlightRule.STYLE_MEMBER));
  try {
    style2Highlight.setStyle(style2);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(SemanticError.DESIGN_EXCEPTION_CIRCULAR_ELEMENT_REFERNECE,e.getErrorCode());
  }
  style2Highlight.setStyle(style3);
  Iterator style3HighlightRules=style3.highlightRulesIterator();
  assertTrue(style3HighlightRules.hasNext());
  HighlightRuleHandle style3Highlight=(HighlightRuleHandle)style3HighlightRules.next();
  Iterator style4HighlightRules=style4.highlightRulesIterator();
  assertTrue(style4HighlightRules.hasNext());
  HighlightRuleHandle style4Highlight=(HighlightRuleHandle)style4HighlightRules.next();
  DimensionValue dv=(DimensionValue)style4Highlight.getLineHeight().getValue();
  assertEquals(10.0,dv.getMeasure());
  assertEquals("String_Node_Str",dv.getUnits());
  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());
  }
}