harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r549135 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/beancontext/BeanContextSupport.java test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
Date Wed, 20 Jun 2007 15:28:59 GMT
Author: ayza
Date: Wed Jun 20 08:28:58 2007
New Revision: 549135

URL: http://svn.apache.org/viewvc?view=rev&rev=549135
Log:
Applying patch and unit test from HARMONY-4011 ([classlib][beans] compatibility: java.beans.beancontext.BeanContextSupport
allows registering the same listener several times)

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java?view=diff&rev=549135&r1=549134&r2=549135
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
Wed Jun 20 08:28:58 2007
@@ -319,7 +319,9 @@
             throw new NullPointerException();
         }
         synchronized (bcmListeners) {
-            bcmListeners.add(listener);
+            if (!bcmListeners.contains(listener)) {
+                bcmListeners.add(listener);
+            }
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java?view=diff&rev=549135&r1=549134&r2=549135
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupport2Test.java
Wed Jun 20 08:28:58 2007
@@ -20,6 +20,9 @@
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.beancontext.BeanContextSupport;
+import java.beans.beancontext.BeanContextMembershipListener;
+import java.beans.beancontext.BeanContextMembershipEvent;
+import java.beans.beancontext.BeanContextChildSupport;
 import java.util.Locale;
 
 import junit.framework.TestCase;
@@ -37,6 +40,33 @@
         beanContextSupport.setLocale(null);
         assertEquals(Locale.FRANCE, beanContextSupport.getLocale());
         assertFalse(myPropertyChangeListener.changed);        
+    }
+
+    /**
+     * Regression test for HARMONY-4011
+     */
+    public void test4011() {
+        BeanContextSupport context = new BeanContextSupport();
+        final int[] k = { 0 };
+        BeanContextMembershipListener listener =
+                new BeanContextMembershipListener() {
+                    
+            public void childrenAdded(BeanContextMembershipEvent bcme) {
+                k[0]++;
+            }
+
+            public void childrenRemoved(BeanContextMembershipEvent bcme) {}
+        };
+
+        // add listener
+        context.addBeanContextMembershipListener(listener);
+        context.add(new BeanContextChildSupport());
+        assertEquals(1, k[0]);
+        
+        // add the same listener onse again
+        context.addBeanContextMembershipListener(listener);
+        context.add(new BeanContextChildSupport());
+        assertEquals(2, k[0]);
     }
     
     private class MyPropertyChangeListener implements PropertyChangeListener {



Mime
View raw message