}
public void testRemoveTripletErrors()
throws Exception
{
NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();
Object handback = new Object();
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType(DEFAULT_TYPE);
Listener listener = new Listener();
boolean caught = false;
try
{
broadcaster.removeNotificationListener(null, null, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
}
assertTrue("Expected ListenerNotFoundException for null listener", caught);
caught = false;
try
{
broadcaster.removeNotificationListener(listener, null, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
}
assertTrue("Expected ListenerNotFoundException for listener never added", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, null);
broadcaster.removeNotificationListener(listener, null, null);
broadcaster.removeNotificationListener(listener, null, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
}
assertTrue("Expected ListenerNotFoundException for listener remove twice", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, null);
broadcaster.removeNotificationListener(listener, new NotificationFilterSupport(), null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, null);
}
assertTrue("Expected ListenerNotFoundException for wrong filter", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, handback);
broadcaster.removeNotificationListener(listener, null, new Object());
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, handback);
}
assertTrue("Expected ListenerNotFoundException for wrong handback", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, handback);
broadcaster.removeNotificationListener(listener, new NotificationFilterSupport(), new Object());
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, handback);
}
assertTrue("Expected ListenerNotFoundException for wrong filter and handback", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, handback);
broadcaster.removeNotificationListener(listener, null, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, handback);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 1", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, handback);
broadcaster.removeNotificationListener(listener, filter, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, handback);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 2", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, handback);
broadcaster.removeNotificationListener(listener, null, handback);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, handback);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 3", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, null);
broadcaster.removeNotificationListener(listener, null, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, null);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 4", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, null);
broadcaster.removeNotificationListener(listener, null, handback);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, null);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 5", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, filter, null);
broadcaster.removeNotificationListener(listener, filter, handback);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, filter, null);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 6", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, handback);
broadcaster.removeNotificationListener(listener, null, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, handback);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 7", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, handback);
broadcaster.removeNotificationListener(listener, filter, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, handback);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 8", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, handback);
broadcaster.removeNotificationListener(listener, filter, handback);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, handback);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 9", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, null);
broadcaster.removeNotificationListener(listener, filter, null);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, null);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 10", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, null);
broadcaster.removeNotificationListener(listener, null, handback);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, null);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 11", caught);
caught = false;
try
{
broadcaster.addNotificationListener(listener, null, null);
broadcaster.removeNotificationListener(listener, filter, handback);
}
catch (ListenerNotFoundException e)
{
caught = true;
broadcaster.removeNotificationListener(listener, null, null);
}
assertTrue("Expected ListenerNotFoundException for listener remove with wrong triplet 12", caught);
}