mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-11 20:45:05 +00:00
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:
parent
6967edc80c
commit
ef2a37a3ba
@ -29,6 +29,34 @@
|
||||
*/
|
||||
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 void testCreateWithNonInterfaceParameter()
|
||||
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 void testCreateWithNullParameter()
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user