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
}