/**
* Tests the EventManager's removeListener
* @throws Exception
*/
public void test2() throws Exception {
EventManager mgr = new EventManager();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String[] testObjects = new String[10];
for (int i = 0; i < testObjects.length; i++)
testObjects[i] = new String(Integer.toString(i));
EventListener[] listeners = new EventListener[testObjects.length];
for (int i = 0; i < listeners.length; i++)
listeners[i] = new MyEventListener(pw, i);
EventManager.addListener(testObjects[0], "myEvent0", listeners[0]);
EventManager.addListener(testObjects[0], "myEvent1", listeners[1]);
EventManager.addListener(testObjects[0], "myEvent2", listeners[2]);
EventManager.addListener(testObjects[0], "myEvent3", listeners[3]);
EventManager.addListener(testObjects[0], "myEvent4", listeners[4]);
EventManager.addListener(testObjects[0], "myEvent5", listeners[5]);
EventManager.removeListener(testObjects[0], "myEvent5", listeners[5]);
EventManager.removeListener(testObjects[0], "myEvent4", listeners[4]);
EventManager.removeListener(testObjects[0], "myEvent3", listeners[3]);
EventManager.removeListener(testObjects[0], "myEvent2", listeners[2]);
EventManager.removeListener(testObjects[0], "myEvent1", listeners[1]);
EventManager.removeListener(testObjects[0], "myEvent0", listeners[0]);
assertTrue(mgr.compact());
for (int i = 0; i < testObjects.length; i++)
for (int j = 1; j <= i; j++)
EventManager.addListener(testObjects[j], "helloWorldEvent" + i, listeners[j]);
for (int i = 0; i < testObjects.length; i++)
for (int j = 1; j <= i; j++)
assertTrue(EventManager.removeListener(testObjects[j], "helloWorldEvent" + i, listeners[j]));
assertTrue(mgr.compact());
}