From ef2a37a3bae30b8bb7c11e81452aace8814cd3c1 Mon Sep 17 00:00:00 2001 From: "James W. Carman" Date: Thu, 22 Jul 2010 19:40:20 +0000 Subject: [PATCH] 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 --- .../lang3/event/EventListenerSupportTest.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java index 94d400afa..7216a29eb 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java @@ -29,6 +29,34 @@ import java.util.List; */ public class EventListenerSupportTest extends TestCase { + public void testAddNullListener() + { + EventListenerSupport 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 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 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 listenerSupport = EventListenerSupport.create(ActionListener.class);