You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/07/11 22:24:52 UTC

svn commit: r1609805 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/event/EventListenerList.java test/java/org/apache/commons/configuration/event/TestEventListenerList.java

Author: oheger
Date: Fri Jul 11 20:24:52 2014
New Revision: 1609805

URL: http://svn.apache.org/r1609805
Log:
Added a clear() method to EventListenerList.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventListenerList.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventListenerList.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventListenerList.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventListenerList.java?rev=1609805&r1=1609804&r2=1609805&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventListenerList.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventListenerList.java Fri Jul 11 20:24:52 2014
@@ -206,6 +206,14 @@ public class EventListenerList
     }
 
     /**
+     * Removes all event listeners registered at this object.
+     */
+    public void clear()
+    {
+        listeners.clear();
+    }
+
+    /**
      * Helper method for calling an event listener with an event. We have to
      * operate on raw types to make this code compile. However, this is safe
      * because of the way the listeners have been registered and associated with

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventListenerList.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventListenerList.java?rev=1609805&r1=1609804&r2=1609805&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventListenerList.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventListenerList.java Fri Jul 11 20:24:52 2014
@@ -461,6 +461,19 @@ public class TestEventListenerList
     }
 
     /**
+     * Tests whether the list can be cleared.
+     */
+    @Test
+    public void testClear()
+    {
+        list.addEventListener(typeSub1, new ListenerTestImpl());
+        list.addEventListener(typeSub2, new ListenerTestImpl());
+
+        list.clear();
+        assertTrue("Got listeners", list.getRegistrations().isEmpty());
+    }
+
+    /**
      * Test event class. For testing purposes, a small hierarchy of test event
      * class is created. This way it can be checked whether event types are
      * correctly evaluated and take the event hierarchy into account.