harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r398819 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/PropertyChangeSupport.java test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
Date Tue, 02 May 2006 06:01:42 GMT
Author: mloenko
Date: Mon May  1 23:01:36 2006
New Revision: 398819

URL: http://svn.apache.org/viewcvs?rev=398819&view=rev
Log:
fixes for HARMONY-386
java.beans.PropertyChangeSupport.removePropertyChangeListener does not remove a PropertyChangeListener.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java?rev=398819&r1=398818&r2=398819&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyChangeSupport.java
Mon May  1 23:01:36 2006
@@ -179,7 +179,16 @@
     public synchronized void addPropertyChangeListener(
             PropertyChangeListener listener) {
         if (listener != null) {
-            allPropertiesChangeListeners.add(listener);
+            if (listener instanceof PropertyChangeListenerProxy) {
+                String name = ((PropertyChangeListenerProxy) listener)
+                        .getPropertyName();
+                PropertyChangeListener lst = (PropertyChangeListener) ((PropertyChangeListenerProxy)
listener)
+                        .getListener();
+                addPropertyChangeListener(name, lst);
+            } else {
+                allPropertiesChangeListeners.add(listener);
+            }
+
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java?rev=398819&r1=398818&r2=398819&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/PropertyChangeSupportTest.java
Mon May  1 23:01:36 2006
@@ -20,7 +20,9 @@
  */
 package org.apache.harmony.tests.java.beans;
 
+import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeListenerProxy;
 import java.beans.PropertyChangeSupport;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -72,6 +74,31 @@
         }
     }
 
+    /**
+     * @tests java.beans.PropertyChangeSupport#removePropertyChangeListener(
+     *        java.lang.String, java.beans.PropertyChangeListener)
+     */
+    public void testRemovePropertyChangeListener() {
+        // Regerssion for HARMONY-386
+        PropertyChangeSupport prop = new PropertyChangeSupport(new Object());
+
+        PropertyChangeListener lis1 = new PropertyChangeListener() {
+            public void propertyChange(PropertyChangeEvent event) {}
+        };
+
+        PropertyChangeListener lis2 = new PropertyChangeListenerProxy("name",
+                lis1);
+
+        assertEquals(0, prop.getPropertyChangeListeners().length);
+
+        prop.addPropertyChangeListener(lis2);
+        assertEquals(1, prop.getPropertyChangeListeners().length);
+
+        prop.removePropertyChangeListener("name", lis1);
+        assertEquals(0, prop.getPropertyChangeListeners().length);
+    } 
+    
+    
     /**
      * The test checks the serialization for listeners supporting serialization
      */



Mime
View raw message