Adding test cases for null checks.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@966821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James W. Carman 2010-07-22 19:40:20 +00:00
parent 6967edc80c
commit ef2a37a3ba
1 changed files with 32 additions and 4 deletions

View File

@ -29,6 +29,34 @@ import java.util.List;
*/
public class EventListenerSupportTest extends TestCase
{
public void testAddNullListener()
{
EventListenerSupport<ActionListener> listenerSupport = EventListenerSupport.create(ActionListener.class);
try
{
listenerSupport.addListener(null);
fail("Should not be able to add a null listener.");
}
catch (NullPointerException e)
{
}
}
public void testRemoveNullListener()
{
EventListenerSupport<ActionListener> listenerSupport = EventListenerSupport.create(ActionListener.class);
try
{
listenerSupport.removeListener(null);
fail("Should not be able to remove a null listener.");
}
catch (NullPointerException e)
{
}
}
public void testEventDispatchOrder()
{
EventListenerSupport<ActionListener> listenerSupport = EventListenerSupport.create(ActionListener.class);
@ -51,9 +79,9 @@ public class EventListenerSupportTest extends TestCase
EventListenerSupport.create(String.class);
fail("Should not be able to create using non-interface class.");
}
catch(IllegalArgumentException e)
catch (IllegalArgumentException e)
{
}
}
@ -64,12 +92,12 @@ public class EventListenerSupportTest extends TestCase
EventListenerSupport.create(null);
fail("Should not be able to create using null class.");
}
catch(NullPointerException e)
catch (NullPointerException e)
{
}
}
public void testRemoveListenerDuringEvent()
{
final EventListenerSupport<ActionListener> listenerSupport = EventListenerSupport.create(ActionListener.class);