harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r548915 - in /harmony/enhanced/classlib/trunk/modules/beans: make/exclude.common src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
Date Wed, 20 Jun 2007 03:44:21 GMT
Author: leoli
Date: Tue Jun 19 20:44:19 2007
New Revision: 548915

URL: http://svn.apache.org/viewvc?view=rev&rev=548915
Log:
1. Add testcase for java.beans.beancontext.BeanContextChildSupport, which ensures that addVetoableChangeListener
and removeVetoableChangeListener will reevaluate whether setBeanContext is allowed.
2.org.apache.harmony.beans.tests.java.beans.beancontext.BeanContextChildSupport is removed
from the exclude tests list.

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common?view=diff&rev=548915&r1=548914&r2=548915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common Tue Jun 19 20:44:19
2007
@@ -3,7 +3,6 @@
 org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
 org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
 org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
-org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
 org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
 org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
 org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java?view=diff&rev=548915&r1=548914&r2=548915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java
Tue Jun 19 20:44:19 2007
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.beans.tests.java.beans.beancontext;
 
+import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.beans.PropertyVetoException;
@@ -482,8 +483,7 @@
 
         BeanContextChildSupport sup = new BeanContextChildSupport();
 
-        assertFalse("Child is not supposed to be delegated",
-                sup.isDelegated());
+        assertFalse("Child is not supposed to be delegated", sup.isDelegated());
     }
 
     public void testReleaseBeanContextResources() throws PropertyVetoException {
@@ -945,6 +945,55 @@
 
         assertNotNull("BeanContext should not be null", sup.getBeanContext());
     }
+    
+    public void testSetBeanContextBeanContextWithPropertyVetoException()
+            throws Exception {
+        MyBeanContextChildSupport myBeanContextChildSupport = new MyBeanContextChildSupport();
+        VetoableChangeListener vcl = new MyVetoableChangeListener();
+        myBeanContextChildSupport.addVetoableChangeListener("beanContext", vcl);
+        BeanContext beanContext = new BeanContextSupport();
+        try {
+            myBeanContextChildSupport.setBeanContext(beanContext);
+            fail("should throw PropertyVetoException");
+        } catch (PropertyVetoException e) {           
+            // expected
+        }
+        assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
+        assertNull(myBeanContextChildSupport.getBeanContext());
+        
+        myBeanContextChildSupport.setBeanContext(beanContext);
+        assertFalse(myBeanContextChildSupport.getRejectedSetBCOnce());
+        assertNotNull(myBeanContextChildSupport.getBeanContext());
+        
+        try {
+            myBeanContextChildSupport.setBeanContext(new BeanContextSupport());
+            fail("should throw PropertyVetoException");
+        } catch (PropertyVetoException e) {
+            // expected
+        }
+        
+        myBeanContextChildSupport
+                .removeVetoableChangeListener("beanContext", vcl);
+        myBeanContextChildSupport.setBeanContext(beanContext);
+        assertTrue(myBeanContextChildSupport.getRejectedSetBCOnce());
+        assertSame(beanContext, myBeanContextChildSupport.getBeanContext());
+    }
+    
+    
+    class MyVetoableChangeListener implements VetoableChangeListener 
+    { 
+
+        public void vetoableChange(PropertyChangeEvent arg0) throws PropertyVetoException
{ 
+            throw new PropertyVetoException("TESTSTRING", null); 
+        } 
+    }
+    
+    class MyBeanContextChildSupport extends BeanContextChildSupport {
+        public boolean getRejectedSetBCOnce() {
+            return rejectedSetBCOnce;
+        }
+    }
+
 
     /** UTILITY METHODS * */
 



Mime
View raw message