for(int i = 0; i < 50; i++) {
eventList.add(new Integer(i + 100));
}
// get the sublist
EventList subListBefore = (EventList)eventList.subList(25, 75);
ListConsistencyListener.install(subListBefore);
// change the source list to be 0,1,2,3,...49,50,51,..99,100,101...149
for(int i = 0; i < 50; i++) {
eventList.add(50+i, new Integer(50+i));
}
// ensure the sublist took the change
EventList subListAfter = (EventList)eventList.subList(25, 125);
assertEquals(subListBefore, subListAfter);
// change the lists again, deleting all odd numbered entries
for(Iterator i = eventList.iterator(); i.hasNext(); ) {
Integer current = (Integer)i.next();
if(current.intValue() % 2 == 1) i.remove();
}
// ensure the sublists took the change
subListAfter = (EventList)eventList.subList(13, 63);
assertEquals(subListBefore, subListAfter);
// make some set calls
eventList.set(15, "Fifteen");
eventList.set(18, "Eighteen");
eventList.set(21, "Twenty-One");
eventList.set(24, "Twenty-Four");
assertEquals("Fifteen", subListAfter.get(2));
assertEquals("Eighteen", subListAfter.get(5));
subListBefore.set(14, "Twenty-Seven");
assertEquals("Twenty-Seven", eventList.get(27));
assertEquals(subListAfter, subListBefore);
}