}
public void testSingleSelection(TestHarness harness)
{
harness.checkPoint("SINGLE_SELECTION");
DefaultListSelectionModel m = new DefaultListSelectionModel();
m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// check 1 - the selected item is in the removed range
m.addSelectionInterval(6, 7);
harness.check(m.isSelectedIndex(6), false);
harness.check(m.isSelectedIndex(7), true);
harness.check(m.getAnchorSelectionIndex(), 7);
harness.check(m.getLeadSelectionIndex(), 7);
m.addListSelectionListener(this);
m.removeIndexInterval(5, 7);
harness.check(m.isSelectionEmpty(), true);
harness.check(m.getAnchorSelectionIndex(), 4);
harness.check(m.getLeadSelectionIndex(), 4);
harness.check(lastEvent.getSource(), m);
harness.check(lastEvent.getFirstIndex(), 4);
harness.check(lastEvent.getLastIndex(), 7);
// check 2 - the selected item is below the removed range
m.setSelectionInterval(1, 1);
lastEvent = null;
m.removeIndexInterval(2, 4);
harness.check(m.isSelectedIndex(1), true);
harness.check(m.getAnchorSelectionIndex(), 1);
harness.check(m.getLeadSelectionIndex(), 1);
harness.check(lastEvent, null); // no event, because nothing changed
// check 3 - the selected item is above the removed range
m.setSelectionInterval(5, 5);
lastEvent = null;
m.removeIndexInterval(2, 4);
harness.check(m.isSelectedIndex(2), true);
harness.check(m.getAnchorSelectionIndex(), 2);
harness.check(m.getLeadSelectionIndex(), 2);
harness.check(lastEvent.getFirstIndex(), 2);
harness.check(lastEvent.getLastIndex(), 5);
}