Program: 32534
Project: 32534
Buggy source:
/** 
 * Tests that selection survives a sorting.
 */
public void guiTestSort(){
  EventList<Comparable> list=new BasicEventList<Comparable>();
  SortedList<Comparable> sorted=new SortedList<Comparable>(list,null);
  EventSelectionModel<Comparable> eventSelectionModel=new EventSelectionModel<Comparable>(sorted);
  list.addAll(GlazedListsTests.delimitedStringToList("String_Node_Str"));
  assertEquals(Collections.EMPTY_LIST,eventSelectionModel.getSelected());
  eventSelectionModel.addSelectionInterval(0,0);
  eventSelectionModel.addSelectionInterval(4,4);
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getSelected());
  sorted.setComparator(GlazedLists.comparableComparator());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getSelected());
  sorted.setComparator(GlazedLists.reverseComparator());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getSelected());
}

Fixed version (ground truth):
/** 
 * Tests that selection survives a sorting.
 */
public void guiTestSort(){
  EventList<Comparable> list=new BasicEventList<Comparable>();
  SortedList<Comparable> sorted=new SortedList<Comparable>(list,null);
  EventSelectionModel<Comparable> eventSelectionModel=new EventSelectionModel<Comparable>(sorted);
  list.addAll(GlazedListsTests.delimitedStringToList("String_Node_Str"));
  assertEquals(Collections.EMPTY_LIST,eventSelectionModel.getSelected());
  assertEquals(Collections.EMPTY_LIST,eventSelectionModel.getTogglingSelected());
  assertEquals(list,eventSelectionModel.getDeselected());
  assertEquals(list,eventSelectionModel.getTogglingDeselected());
  eventSelectionModel.addSelectionInterval(0,0);
  eventSelectionModel.addSelectionInterval(4,4);
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getDeselected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingDeselected());
  sorted.setComparator(GlazedLists.comparableComparator());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getDeselected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingDeselected());
  sorted.setComparator(GlazedLists.reverseComparator());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingSelected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getDeselected());
  assertEquals(GlazedListsTests.delimitedStringToList("String_Node_Str"),eventSelectionModel.getTogglingDeselected());
}