}
public void testRemoveListenerErrors()
throws Exception
{
NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();
Listener listener = new Listener();
boolean caught = false;
try
{
broadcaster.removeNotificationListener(null);
}
catch (ListenerNotFoundException e)
{
caught = true;
}
assertTrue("Expected ListenerNotFoundException for null listener", caught);
caught = false;
try
{
broadcaster.removeNotificationListener(listener);
}
catch (ListenerNotFoundException e)
{
caught = true;
}
assertTrue("Expected ListenerNotFoundException for listener never added", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, null);
broadcaster.removeNotificationListener(listener);
broadcaster.removeNotificationListener(listener);
}
catch (ListenerNotFoundException e)
{
caught = true;
}