{
};
public void test(TestHarness harness)
{
EventListenerList ell = new EventListenerList();
EventListener l1 = new L();
L l2 = new L();
Object[] list;
Throwable caught;
// Check #1.
ell.add(EventListener.class, l1);
ell.add(L.class, l2);
ell.remove(EventListener.class, l1);
list = ell.getListenerList();
harness.check(list.length, 2);
// Check #2.
// Classpath bug #7105.
harness.check(list[0] == L.class);
// Check #3.
// Classpath bug #7105.
harness.check(list[1] == l2);
// Check #4: Remove something not in the list.
ell.remove(EventListener.class, l2);
list = ell.getListenerList();
harness.check(list.length, 2);
// Check #5: remove(null, foo)
// Classpath bug #7105.
caught = null;
try
{
ell.remove(null, l2);
}
catch (Exception ex)
{
caught = ex;
}
harness.check(caught instanceof NullPointerException);
// Check #6: remove(foo, null)
caught = null;
try
{
ell.remove(EventListener.class, null);
}
catch (Exception ex)
{
caught = ex;
}
harness.check(caught, null);
// Check #7: remove(null, null)
caught = null;
try
{
ell.remove(null, null);
}
catch (Exception ex)
{
caught = ex;
}
harness.check(caught, null);
/* Doesn't compile with 1.5
// Check #8: Removing non-instance.
// Classpath bug #7105.
caught = null;
try
{
ell.remove(L2.class, l2);
}
catch (Exception ex)
{
caught = ex;
}
harness.check(caught instanceof IllegalArgumentException);
*/
// Unsuccessful attempts should not change the list.
list = ell.getListenerList();
harness.check(list.length, 2); // Check #9.
harness.check(list[0], L.class); // Check #10. Classpath bug #7105.
harness.check(list[1] == l2); // Check #11. Classpath bug #7105.
// Check #12: Removal of doubly registered listener.
ell = new EventListenerList();
ell.add(L.class, l2);
ell.add(L.class, l2);
ell.remove(L.class, l2);
harness.check(ell.getListenerList().length, 2);
}