You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/10/03 13:06:03 UTC
svn commit: r452415 [8/12] - in
/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test:
java-internal/java/beans/beancontext/ java-internal/org/apache/harmony/beans/
java/org/apache/harmony/beans/tests/
java/org/apache/harmony/beans/tests/ja...
Modified: incubator/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/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java?view=diff&rev=452415&r1=452414&r2=452415
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextChildSupportTest.java Tue Oct 3 04:05:57 2006
@@ -29,6 +29,10 @@
import java.io.IOException;
import java.io.Serializable;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
import org.apache.harmony.beans.tests.support.beancontext.Utils;
import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChild;
@@ -41,420 +45,419 @@
import tests.util.SerializationTester;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* Test BeanContextChildSupport
*/
public class BeanContextChildSupportTest extends TestCase {
- private static class MockBeanContextChildSupport extends
- BeanContextChildSupport {
+ private static class MockBeanContextChildSupport extends
+ BeanContextChildSupport {
static final long serialVersionUID = -8602521752077435319L;
-
- public BeanContext lastInitBeanContext = null;
- public BeanContext lastReleaseBeanContext = null;
+ public BeanContext lastInitBeanContext = null;
- public boolean vetoBeanContext = false;
+ public BeanContext lastReleaseBeanContext = null;
- /**
+ public boolean vetoBeanContext = false;
+
+ /**
*
*/
- public MockBeanContextChildSupport() {
- super();
- assertNull(this.beanContext);
- assertSame(this, this.beanContextChildPeer);
- assertFalse(this.rejectedSetBCOnce);
- }
+ public MockBeanContextChildSupport() {
+ super();
+ assertNull(this.beanContext);
+ assertSame(this, this.beanContextChildPeer);
+ assertFalse(this.rejectedSetBCOnce);
+ }
- /**
+ /**
* @param bcc
*/
- public MockBeanContextChildSupport(BeanContextChild bcc) {
- super(bcc);
- assertNull(this.beanContext);
- assertSame(bcc, this.beanContextChildPeer);
- assertFalse(this.rejectedSetBCOnce);
- }
-
- public boolean rejectedSetBCOnce() {
- return rejectedSetBCOnce;
- }
+ public MockBeanContextChildSupport(BeanContextChild bcc) {
+ super(bcc);
+ assertNull(this.beanContext);
+ assertSame(bcc, this.beanContextChildPeer);
+ assertFalse(this.rejectedSetBCOnce);
+ }
+
+ public boolean rejectedSetBCOnce() {
+ return rejectedSetBCOnce;
+ }
- /*
+ /*
* (non-Javadoc)
*
* @see java.beans.beancontext.BeanContextChildSupport#initializeBeanContextResources()
*/
- protected void initializeBeanContextResources() {
- lastInitBeanContext = this.beanContext;
- }
+ @Override
+ protected void initializeBeanContextResources() {
+ lastInitBeanContext = this.beanContext;
+ }
- /*
+ /*
* (non-Javadoc)
*
* @see java.beans.beancontext.BeanContextChildSupport#releaseBeanContextResources()
*/
- protected void releaseBeanContextResources() {
- lastReleaseBeanContext = this.beanContext;
- }
-
- public void clearLastRecords() {
- lastInitBeanContext = null;
- lastReleaseBeanContext = null;
- }
+ @Override
+ protected void releaseBeanContextResources() {
+ lastReleaseBeanContext = this.beanContext;
+ }
- /*
+ public void clearLastRecords() {
+ lastInitBeanContext = null;
+ lastReleaseBeanContext = null;
+ }
+
+ /*
* (non-Javadoc)
*
* @see java.beans.beancontext.BeanContextChildSupport#validatePendingSetBeanContext(java.beans.beancontext.BeanContext)
*/
- public boolean validatePendingSetBeanContext(BeanContext newValue) {
- if (vetoBeanContext) {
- return false;
- }
- return super.validatePendingSetBeanContext(newValue);
- }
- }
-
- public static void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(BeanContextChildSupportTest.class);
- }
-
- public void testAddPropertyChangeListener_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
-
- try {
- support.addPropertyChangeListener(null,
- new MockPropertyChangeListener());
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.addPropertyChangeListener("property name", null);
- support.firePropertyChange("property name", "old value",
- "new value");
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testAddPropertyChangeListener() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.addPropertyChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertNull(l2.lastEvent);
-
- support.addPropertyChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange("xxx", oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testAddVetoableChangeListener_NullParam()
- throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
-
- try {
- support.addVetoableChangeListener(null,
- new MockVetoableChangeListener());
- fail();
- } catch (NullPointerException e) {
- // expected
- }
-
- try {
- support.addVetoableChangeListener("property name", null);
- support.fireVetoableChange("property name", "old value",
- "new value");
- fail();
- } catch (NullPointerException e) {
- // expected
- }
- }
-
- public void testAddVetoableChangeListener() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.addVetoableChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertNull(l2.lastEvent);
-
- support.addVetoableChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange("xxx", oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
+ @Override
+ public boolean validatePendingSetBeanContext(BeanContext newValue) {
+ if (vetoBeanContext) {
+ return false;
+ }
+ return super.validatePendingSetBeanContext(newValue);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ junit.textui.TestRunner.run(BeanContextChildSupportTest.class);
+ }
+
+ public void testAddPropertyChangeListener_NullParam() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+
+ try {
+ support.addPropertyChangeListener(null,
+ new MockPropertyChangeListener());
+ fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ support.addPropertyChangeListener("property name", null);
+ support.firePropertyChange("property name", "old value",
+ "new value");
+ fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+ }
+
+ public void testAddPropertyChangeListener() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockPropertyChangeListener l2 = new MockPropertyChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+
+ support.addPropertyChangeListener(propName, l1);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertNull(l2.lastEvent);
+
+ support.addPropertyChangeListener(propName, l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), oldValue);
+ assertSame(l2.lastEvent.getNewValue(), newValue);
+ assertSame(l2.lastEvent.getSource(), support);
+
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange("xxx", oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testAddVetoableChangeListener_NullParam()
+ throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+
+ try {
+ support.addVetoableChangeListener(null,
+ new MockVetoableChangeListener());
+ fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ try {
+ support.addVetoableChangeListener("property name", null);
+ support.fireVetoableChange("property name", "old value",
+ "new value");
+ fail();
+ } catch (NullPointerException e) {
+ // expected
+ }
+ }
+
+ public void testAddVetoableChangeListener() throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockVetoableChangeListener l1 = new MockVetoableChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+
+ support.addVetoableChangeListener(propName, l1);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertNull(l2.lastEvent);
+
+ support.addVetoableChangeListener(propName, l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), oldValue);
+ assertSame(l2.lastEvent.getNewValue(), newValue);
+ assertSame(l2.lastEvent.getSource(), support);
+
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange("xxx", oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+ }
- /*
+ /*
* Class under test for void BeanContextChildSupport()
*/
- public void testBeanContextChildSupport() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertSame(support, support.getBeanContextChildPeer());
- assertSame(support, support.beanContextChildPeer);
- }
+ public void testBeanContextChildSupport() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ assertSame(support, support.getBeanContextChildPeer());
+ assertSame(support, support.beanContextChildPeer);
+ }
- /*
+ /*
* Class under test for void
* BeanContextChildSupport(java.beans.beancontext.BeanContextChild)
*/
- public void testBeanContextChildSupportBeanContextChild() {
- BeanContextChild c = new MockBeanContextChild();
- BeanContextChildSupport support = new MockBeanContextChildSupport(c);
- assertSame(c, support.getBeanContextChildPeer());
- assertSame(c, support.beanContextChildPeer);
- }
-
- public void testFirePropertyChange_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.firePropertyChange(null, "a", "b");
- }
-
- public void testFirePropertyChange() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertNull(l2.lastEvent);
- }
-
- public void testFirePropertyChange_OldEqualsNew() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(1);
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testFirePropertyChange_OldEqualsNew_IsNull() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = null;
- Object newValue = null;
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertNull(l1.lastEvent.getOldValue());
- assertNull(l1.lastEvent.getNewValue());
- assertSame(l1.lastEvent.getSource(), support);
- assertNull(l2.lastEvent);
- }
-
- public void testFireVetoableChange_NullParam() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.fireVetoableChange(null, "a", "b");
- }
-
- public void testFireVetoableChange() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertNull(l2.lastEvent);
- }
-
- public void testFireVetoableChange_Vetoed() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- MockVetoChangeListener l3 = new MockVetoChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener(propName, l2);
- support.addVetoableChangeListener(propName, l3);
- l1.clearLastEvent();
- l2.clearLastEvent();
- l3.clearLastEvent();
- try {
- support.fireVetoableChange(propName, oldValue, newValue);
- fail();
- } catch (PropertyVetoException e) {
- // expected
- }
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), newValue);
- assertSame(l1.lastEvent.getNewValue(), oldValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), newValue);
- assertSame(l2.lastEvent.getNewValue(), oldValue);
- assertSame(l2.lastEvent.getSource(), support);
- assertEquals(l3.lastEvent.getPropertyName(), propName);
- assertSame(l3.lastEvent.getOldValue(), newValue);
- assertSame(l3.lastEvent.getNewValue(), oldValue);
- assertSame(l3.lastEvent.getSource(), support);
- }
-
- public void testFireVetoableChange_OldEqualsNew()
- throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(1);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- }
-
- public void testFireVetoableChange_OldEqualsNew_IsNull()
- throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = null;
- Object newValue = null;
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener("xxx", l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertNull(l1.lastEvent.getOldValue());
- assertNull(l1.lastEvent.getNewValue());
- assertSame(l1.lastEvent.getSource(), support);
- assertNull(l2.lastEvent);
- }
-
- public void testGetBeanContext() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockBeanContext mockBeanContext = new MockBeanContext();
- assertNull(support.getBeanContext());
- support.setBeanContext(mockBeanContext);
- assertSame(mockBeanContext, support.getBeanContext());
- }
-
- public void testGetBeanContextChildPeer() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertSame(support, support.beanContextChildPeer);
- assertSame(support, support.getBeanContextChildPeer());
-
- BeanContextChild mockChild = new MockBeanContextChild();
- support = new MockBeanContextChildSupport(mockChild);
- assertSame(mockChild, support.beanContextChildPeer);
- assertSame(mockChild, support.getBeanContextChildPeer());
-
+ public void testBeanContextChildSupportBeanContextChild() {
+ BeanContextChild c = new MockBeanContextChild();
+ BeanContextChildSupport support = new MockBeanContextChildSupport(c);
+ assertSame(c, support.getBeanContextChildPeer());
+ assertSame(c, support.beanContextChildPeer);
+ }
+
+ public void testFirePropertyChange_NullParam() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.firePropertyChange(null, "a", "b");
+ }
+
+ public void testFirePropertyChange() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockPropertyChangeListener l2 = new MockPropertyChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ support.addPropertyChangeListener(propName, l1);
+ support.addPropertyChangeListener("xxx", l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testFirePropertyChange_OldEqualsNew() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockPropertyChangeListener l2 = new MockPropertyChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(1);
+
+ support.addPropertyChangeListener(propName, l1);
+ support.addPropertyChangeListener("xxx", l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testFirePropertyChange_OldEqualsNew_IsNull() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockPropertyChangeListener l2 = new MockPropertyChangeListener();
+ String propName = "property name";
+ Object oldValue = null;
+ Object newValue = null;
+
+ support.addPropertyChangeListener(propName, l1);
+ support.addPropertyChangeListener("xxx", l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertNull(l1.lastEvent.getOldValue());
+ assertNull(l1.lastEvent.getNewValue());
+ assertSame(l1.lastEvent.getSource(), support);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testFireVetoableChange_NullParam() throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.fireVetoableChange(null, "a", "b");
+ }
+
+ public void testFireVetoableChange() throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockVetoableChangeListener l1 = new MockVetoableChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ support.addVetoableChangeListener(propName, l1);
+ support.addVetoableChangeListener("xxx", l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testFireVetoableChange_Vetoed() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockVetoableChangeListener l1 = new MockVetoableChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ MockVetoChangeListener l3 = new MockVetoChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ support.addVetoableChangeListener(propName, l1);
+ support.addVetoableChangeListener(propName, l2);
+ support.addVetoableChangeListener(propName, l3);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ l3.clearLastEvent();
+ try {
+ support.fireVetoableChange(propName, oldValue, newValue);
+ fail();
+ } catch (PropertyVetoException e) {
+ // expected
+ }
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), newValue);
+ assertSame(l1.lastEvent.getNewValue(), oldValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), newValue);
+ assertSame(l2.lastEvent.getNewValue(), oldValue);
+ assertSame(l2.lastEvent.getSource(), support);
+ assertEquals(l3.lastEvent.getPropertyName(), propName);
+ assertSame(l3.lastEvent.getOldValue(), newValue);
+ assertSame(l3.lastEvent.getNewValue(), oldValue);
+ assertSame(l3.lastEvent.getSource(), support);
+ }
+
+ public void testFireVetoableChange_OldEqualsNew()
+ throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockVetoableChangeListener l1 = new MockVetoableChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(1);
+
+ support.addVetoableChangeListener(propName, l1);
+ support.addVetoableChangeListener("xxx", l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testFireVetoableChange_OldEqualsNew_IsNull()
+ throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockVetoableChangeListener l1 = new MockVetoableChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ String propName = "property name";
+ Object oldValue = null;
+ Object newValue = null;
+
+ support.addVetoableChangeListener(propName, l1);
+ support.addVetoableChangeListener("xxx", l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertNull(l1.lastEvent.getOldValue());
+ assertNull(l1.lastEvent.getNewValue());
+ assertSame(l1.lastEvent.getSource(), support);
+ assertNull(l2.lastEvent);
+ }
+
+ public void testGetBeanContext() throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockBeanContext mockBeanContext = new MockBeanContext();
+ assertNull(support.getBeanContext());
+ support.setBeanContext(mockBeanContext);
+ assertSame(mockBeanContext, support.getBeanContext());
+ }
+
+ public void testGetBeanContextChildPeer() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ assertSame(support, support.beanContextChildPeer);
+ assertSame(support, support.getBeanContextChildPeer());
+
+ BeanContextChild mockChild = new MockBeanContextChild();
+ support = new MockBeanContextChildSupport(mockChild);
+ assertSame(mockChild, support.beanContextChildPeer);
+ assertSame(mockChild, support.getBeanContextChildPeer());
+
try {
BeanContextChildSupport sup = new BeanContextChildSupport();
@@ -464,48 +467,48 @@
} catch (Exception e) {
fail("Unexpected exception: " + e + " caused by: " + e.getCause());
}
- }
+ }
+
+ public void testInitializeBeanContextResources()
+ throws PropertyVetoException {
+ MockBeanContextChildSupport support = new MockBeanContextChildSupport();
+ assertNull(support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+ MockBeanContext ctx1 = new MockBeanContext();
+ MockBeanContext ctx2 = new MockBeanContext();
+
+ support.clearLastRecords();
+ support.setBeanContext(ctx1);
+ assertSame(ctx1, support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+
+ support.clearLastRecords();
+ support.setBeanContext(ctx1);
+ assertNull(support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+
+ support.clearLastRecords();
+ support.setBeanContext(ctx2);
+ assertSame(ctx2, support.lastInitBeanContext);
+ assertSame(ctx1, support.lastReleaseBeanContext);
+
+ support.clearLastRecords();
+ support.setBeanContext(null);
+ assertNull(support.lastInitBeanContext);
+ assertSame(ctx2, support.lastReleaseBeanContext);
+ }
+
+ public void testIsDelegated() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ assertFalse(support.isDelegated());
+
+ BeanContextChild mockChild = new MockBeanContextChild();
+ support = new MockBeanContextChildSupport(mockChild);
+ assertTrue(support.isDelegated());
+
+ support.beanContextChildPeer = support;
+ assertFalse(support.isDelegated());
- public void testInitializeBeanContextResources()
- throws PropertyVetoException {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
- MockBeanContext ctx1 = new MockBeanContext();
- MockBeanContext ctx2 = new MockBeanContext();
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertSame(ctx1, support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx2);
- assertSame(ctx2, support.lastInitBeanContext);
- assertSame(ctx1, support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(null);
- assertNull(support.lastInitBeanContext);
- assertSame(ctx2, support.lastReleaseBeanContext);
- }
-
- public void testIsDelegated() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertFalse(support.isDelegated());
-
- BeanContextChild mockChild = new MockBeanContextChild();
- support = new MockBeanContextChildSupport(mockChild);
- assertTrue(support.isDelegated());
-
- support.beanContextChildPeer = support;
- assertFalse(support.isDelegated());
-
try {
BeanContextChildSupport sup = new BeanContextChildSupport();
@@ -515,433 +518,433 @@
} catch (Exception e) {
fail("Unexpected exception: " + e + " caused by: " + e.getCause());
}
- }
+ }
+
+ public void testReleaseBeanContextResources() throws PropertyVetoException {
+ MockBeanContextChildSupport support = new MockBeanContextChildSupport();
+ assertNull(support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+ MockBeanContext ctx1 = new MockBeanContext();
+ MockBeanContext ctx2 = new MockBeanContext();
+
+ support.clearLastRecords();
+ support.setBeanContext(ctx1);
+ assertSame(ctx1, support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+
+ support.clearLastRecords();
+ support.setBeanContext(ctx1);
+ assertNull(support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+
+ support.clearLastRecords();
+ support.setBeanContext(ctx2);
+ assertSame(ctx2, support.lastInitBeanContext);
+ assertSame(ctx1, support.lastReleaseBeanContext);
+
+ support.clearLastRecords();
+ support.setBeanContext(null);
+ assertNull(support.lastInitBeanContext);
+ assertSame(ctx2, support.lastReleaseBeanContext);
+ }
+
+ public void testRemovePropertyChangeListener_NullParam() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.removePropertyChangeListener("property name", null);
+ }
+
+ public void testRemovePropertyChangeListener() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockPropertyChangeListener l2 = new MockPropertyChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ support.addPropertyChangeListener(propName, l1);
+ support.addPropertyChangeListener(propName, l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), oldValue);
+ assertSame(l2.lastEvent.getNewValue(), newValue);
+ assertSame(l2.lastEvent.getSource(), support);
+
+ support.removePropertyChangeListener(propName, l1);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), oldValue);
+ assertSame(l2.lastEvent.getNewValue(), newValue);
+ assertSame(l2.lastEvent.getSource(), support);
+
+ support.removePropertyChangeListener(propName, l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.firePropertyChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+
+ // remove not-registered listener
+ support.removePropertyChangeListener(propName, l1);
+ }
+
+ public void testRemoveVetoableChangeListener_NullParam() {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.removeVetoableChangeListener("property name", null);
+ }
+
+ public void testRemoveVetoableChangeListener() throws PropertyVetoException {
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockVetoableChangeListener l1 = new MockVetoableChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ String propName = "property name";
+ Object oldValue = new Integer(1);
+ Object newValue = new Integer(5);
+
+ support.addVetoableChangeListener(propName, l1);
+ support.addVetoableChangeListener(propName, l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertEquals(l1.lastEvent.getPropertyName(), propName);
+ assertSame(l1.lastEvent.getOldValue(), oldValue);
+ assertSame(l1.lastEvent.getNewValue(), newValue);
+ assertSame(l1.lastEvent.getSource(), support);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), oldValue);
+ assertSame(l2.lastEvent.getNewValue(), newValue);
+ assertSame(l2.lastEvent.getSource(), support);
+
+ support.removeVetoableChangeListener(propName, l1);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertEquals(l2.lastEvent.getPropertyName(), propName);
+ assertSame(l2.lastEvent.getOldValue(), oldValue);
+ assertSame(l2.lastEvent.getNewValue(), newValue);
+ assertSame(l2.lastEvent.getSource(), support);
+
+ support.removeVetoableChangeListener(propName, l2);
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.fireVetoableChange(propName, oldValue, newValue);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+
+ // remove not-registered listener
+ support.removeVetoableChangeListener(propName, l1);
+ }
+
+ public void testServiceAvailable() {
+ // guess the impl is empty
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.serviceAvailable(null);
- public void testReleaseBeanContextResources() throws PropertyVetoException {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
- MockBeanContext ctx1 = new MockBeanContext();
- MockBeanContext ctx2 = new MockBeanContext();
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertSame(ctx1, support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx1);
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(ctx2);
- assertSame(ctx2, support.lastInitBeanContext);
- assertSame(ctx1, support.lastReleaseBeanContext);
-
- support.clearLastRecords();
- support.setBeanContext(null);
- assertNull(support.lastInitBeanContext);
- assertSame(ctx2, support.lastReleaseBeanContext);
- }
-
- public void testRemovePropertyChangeListener_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.removePropertyChangeListener("property name", null);
- }
-
- public void testRemovePropertyChangeListener() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockPropertyChangeListener l2 = new MockPropertyChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addPropertyChangeListener(propName, l1);
- support.addPropertyChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- support.removePropertyChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- support.removePropertyChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.firePropertyChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- // remove not-registered listener
- support.removePropertyChangeListener(propName, l1);
- }
-
- public void testRemoveVetoableChangeListener_NullParam() {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.removeVetoableChangeListener("property name", null);
- }
-
- public void testRemoveVetoableChangeListener() throws PropertyVetoException {
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- MockVetoableChangeListener l1 = new MockVetoableChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- String propName = "property name";
- Object oldValue = new Integer(1);
- Object newValue = new Integer(5);
-
- support.addVetoableChangeListener(propName, l1);
- support.addVetoableChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertEquals(l1.lastEvent.getPropertyName(), propName);
- assertSame(l1.lastEvent.getOldValue(), oldValue);
- assertSame(l1.lastEvent.getNewValue(), newValue);
- assertSame(l1.lastEvent.getSource(), support);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- support.removeVetoableChangeListener(propName, l1);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertEquals(l2.lastEvent.getPropertyName(), propName);
- assertSame(l2.lastEvent.getOldValue(), oldValue);
- assertSame(l2.lastEvent.getNewValue(), newValue);
- assertSame(l2.lastEvent.getSource(), support);
-
- support.removeVetoableChangeListener(propName, l2);
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.fireVetoableChange(propName, oldValue, newValue);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- // remove not-registered listener
- support.removeVetoableChangeListener(propName, l1);
- }
-
- public void testServiceAvailable() {
- // guess the impl is empty
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.serviceAvailable(null);
-
// Regression for HARMONY-372
- (new java.beans.beancontext.BeanContextChildSupport()).serviceAvailable(null);
- (new java.beans.beancontext.BeanContextChildSupport()).serviceRevoked(null);
- }
-
- public void testServiceRevoked() {
- // guess the impl is empty
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- support.serviceRevoked(null);
- }
-
- public void testSetBeanContext() throws PropertyVetoException {
- BeanContextChild peer = new MockBeanContextChild();
- MockBeanContextChildSupport support = new MockBeanContextChildSupport(
- peer);
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- support.addPropertyChangeListener("beanContext", l1);
- support.addVetoableChangeListener("beanContext", l2);
-
- MockBeanContext ctx = new MockBeanContext();
- assertNull(support.getBeanContext());
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(null);
- assertNull(support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(ctx);
- assertSame(ctx, support.getBeanContext());
- assertSame(ctx, support.lastInitBeanContext);
- assertEquals(l1.lastEvent.getPropertyName(), "beanContext");
- assertNull(l1.lastEvent.getOldValue());
- assertSame(l1.lastEvent.getNewValue(), ctx);
- assertSame(l1.lastEvent.getSource(), peer);
- assertEquals(l2.lastEvent.getPropertyName(), "beanContext");
- assertNull(l2.lastEvent.getOldValue());
- assertSame(l2.lastEvent.getNewValue(), ctx);
- assertSame(l2.lastEvent.getSource(), peer);
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(ctx);
- assertSame(ctx, support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- support.setBeanContext(null);
- assertNull(support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertSame(ctx, support.lastReleaseBeanContext);
- assertEquals(l1.lastEvent.getPropertyName(), "beanContext");
- assertNull(l1.lastEvent.getNewValue());
- assertSame(l1.lastEvent.getOldValue(), ctx);
- assertSame(l1.lastEvent.getSource(), peer);
- assertEquals(l2.lastEvent.getPropertyName(), "beanContext");
- assertNull(l2.lastEvent.getNewValue());
- assertSame(l2.lastEvent.getOldValue(), ctx);
- assertSame(l2.lastEvent.getSource(), peer);
- }
-
- public void testSetBeanContext_VetoedByListener()
- throws PropertyVetoException {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- MockBeanContext oldCtx = new MockBeanContext();
- support.setBeanContext(oldCtx);
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoChangeListener l2 = new MockVetoChangeListener();
- support.addPropertyChangeListener("beanContext", l1);
- support.addVetoableChangeListener("beanContext", l2);
-
- MockBeanContext ctx = new MockBeanContext();
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- try {
- support.setBeanContext(ctx);
- fail();
- } catch (PropertyVetoException e) {
- // expected
- }
- assertSame(oldCtx, support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(support.lastReleaseBeanContext);
- assertNull(l1.lastEvent);
- assertEquals(l2.lastEvent.getPropertyName(), "beanContext");
- assertSame(l2.lastEvent.getNewValue(), oldCtx);
- assertSame(l2.lastEvent.getOldValue(), ctx);
- assertSame(l2.lastEvent.getSource(), support);
- assertTrue(support.rejectedSetBCOnce());
- }
-
- public void testSetBeanContext_VetoedByValidateMethod() {
- MockBeanContextChildSupport support = new MockBeanContextChildSupport();
- support.vetoBeanContext = true;
- MockPropertyChangeListener l1 = new MockPropertyChangeListener();
- MockVetoableChangeListener l2 = new MockVetoableChangeListener();
- support.addPropertyChangeListener("beanContext", l1);
- support.addVetoableChangeListener("beanContext", l2);
-
- MockBeanContext ctx = new MockBeanContext();
- assertNull(support.getBeanContext());
-
- support.clearLastRecords();
- l1.clearLastEvent();
- l2.clearLastEvent();
- try {
- support.setBeanContext(ctx);
- fail();
- } catch (PropertyVetoException e) {
- // expected
- }
- assertNull(support.getBeanContext());
- assertNull(support.lastInitBeanContext);
- assertNull(l1.lastEvent);
- assertNull(l2.lastEvent);
- assertTrue(support.rejectedSetBCOnce());
- }
-
- public void testValidatePendingSetBeanContext() {
- // guess the impl always returns true
- BeanContextChildSupport support = new MockBeanContextChildSupport();
- assertTrue(support.validatePendingSetBeanContext(new MockBeanContext()));
- assertTrue(support.validatePendingSetBeanContext(null));
- }
-
- public void testSerialization_NoPeer() throws IOException,
- ClassNotFoundException {
- BeanContextChildSupport support = new BeanContextChildSupport();
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- assertEqualsSerially(support,
- (BeanContextChildSupport) SerializationTester
- .getDeserilizedObject(support));
- }
-
- public void testSerialization_WithNonSerializablePeer() throws IOException,
- ClassNotFoundException {
- MockBeanContextChild peer = new MockBeanContextChild();
- BeanContextChildSupport support = new BeanContextChildSupport(peer);
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- try {
- SerializationTester.getDeserilizedObject(support);
- fail();
- } catch (IOException e) {
- // expected
- }
- }
-
- public void testSerialization_WithPeer() throws IOException,
- ClassNotFoundException {
- MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
- "id of peer");
- BeanContextChildSupport support = peer.support;
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- assertEqualsSerially(support,
- (BeanContextChildSupport) SerializationTester
- .getDeserilizedObject(support));
- }
-
- public void testSerialization_Compatibility() throws IOException,
- ClassNotFoundException, Exception {
- MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
- "id of peer");
- BeanContextChildSupport support = peer.support;
- MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
- MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
- "id of pcl2");
- MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
- MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
- "id of vcl2");
- support.addPropertyChangeListener("beanContext", pcl1);
- support.addPropertyChangeListener("beanContext", pcl2);
- support.addVetoableChangeListener("beanContext", vcl1);
- support.addVetoableChangeListener("beanContext", vcl2);
-
- assertEqualsSerially(
- support,
- (BeanContextChildSupport) SerializationTester
- .readObject(support,
- "serialization/java/beans/beancontext/BeanContextChildSupport.ser"));
- }
-
- public static void assertEqualsSerially(BeanContextChildSupport orig,
- BeanContextChildSupport ser) {
- // check peer
- if (orig == orig.getBeanContextChildPeer()) {
- assertSame(ser, ser.getBeanContextChildPeer());
- } else {
- assertSame(orig.getBeanContextChildPeer().getClass(), ser
- .getBeanContextChildPeer().getClass());
- if (orig.getBeanContextChildPeer() instanceof MockBeanContextChildDelegateS) {
- MockBeanContextChildDelegateS origPeer = (MockBeanContextChildDelegateS) orig
- .getBeanContextChildPeer();
- MockBeanContextChildDelegateS serPeer = (MockBeanContextChildDelegateS) ser
- .getBeanContextChildPeer();
- assertEquals(origPeer.id, serPeer.id);
- }
- }
-
- // check property change listeners
- PropertyChangeSupport origPCS = (PropertyChangeSupport) Utils.getField(
- orig, "pcSupport");
- PropertyChangeSupport serPCS = (PropertyChangeSupport) Utils.getField(
- ser, "pcSupport");
- PropertyChangeListener origPCL[] = origPCS
- .getPropertyChangeListeners("beanContext");
- PropertyChangeListener serPCL[] = serPCS
- .getPropertyChangeListeners("beanContext");
- int i = 0, j = 0;
- while (i < origPCL.length) {
- if (origPCL[i] instanceof Serializable) {
- assertSame(origPCL[i].getClass(), serPCL[j].getClass());
- if (origPCL[i] instanceof MockPropertyChangeListenerS) {
- assertEquals(((MockPropertyChangeListenerS) origPCL[i]).id,
- ((MockPropertyChangeListenerS) serPCL[j]).id);
- }
- i++;
- j++;
- } else {
- i++;
- }
- }
- assertEquals(serPCL.length, j);
-
- // check vetoable change listeners
- VetoableChangeSupport origVCS = (VetoableChangeSupport) Utils.getField(
- orig, "vcSupport");
- VetoableChangeSupport serVCS = (VetoableChangeSupport) Utils.getField(
- ser, "vcSupport");
- VetoableChangeListener origVCL[] = origVCS
- .getVetoableChangeListeners("beanContext");
- VetoableChangeListener serVCL[] = serVCS
- .getVetoableChangeListeners("beanContext");
- i = 0;
- j = 0;
- while (i < origVCL.length) {
- if (origVCL[i] instanceof Serializable) {
- assertSame(origVCL[i].getClass(), serVCL[j].getClass());
- if (origVCL[i] instanceof MockVetoableChangeListenerS) {
- assertEquals(((MockVetoableChangeListenerS) origVCL[i]).id,
- ((MockVetoableChangeListenerS) serVCL[j]).id);
- }
- i++;
- j++;
- } else {
- i++;
- }
- }
- assertEquals(serVCL.length, j);
- }
-
-
-
+ (new java.beans.beancontext.BeanContextChildSupport())
+ .serviceAvailable(null);
+ (new java.beans.beancontext.BeanContextChildSupport())
+ .serviceRevoked(null);
+ }
+
+ public void testServiceRevoked() {
+ // guess the impl is empty
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.serviceRevoked(null);
+ }
+
+ public void testSetBeanContext() throws PropertyVetoException {
+ BeanContextChild peer = new MockBeanContextChild();
+ MockBeanContextChildSupport support = new MockBeanContextChildSupport(
+ peer);
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ support.addPropertyChangeListener("beanContext", l1);
+ support.addVetoableChangeListener("beanContext", l2);
+
+ MockBeanContext ctx = new MockBeanContext();
+ assertNull(support.getBeanContext());
+
+ support.clearLastRecords();
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.setBeanContext(null);
+ assertNull(support.getBeanContext());
+ assertNull(support.lastInitBeanContext);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+
+ support.clearLastRecords();
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.setBeanContext(ctx);
+ assertSame(ctx, support.getBeanContext());
+ assertSame(ctx, support.lastInitBeanContext);
+ assertEquals(l1.lastEvent.getPropertyName(), "beanContext");
+ assertNull(l1.lastEvent.getOldValue());
+ assertSame(l1.lastEvent.getNewValue(), ctx);
+ assertSame(l1.lastEvent.getSource(), peer);
+ assertEquals(l2.lastEvent.getPropertyName(), "beanContext");
+ assertNull(l2.lastEvent.getOldValue());
+ assertSame(l2.lastEvent.getNewValue(), ctx);
+ assertSame(l2.lastEvent.getSource(), peer);
+
+ support.clearLastRecords();
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.setBeanContext(ctx);
+ assertSame(ctx, support.getBeanContext());
+ assertNull(support.lastInitBeanContext);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+
+ support.clearLastRecords();
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ support.setBeanContext(null);
+ assertNull(support.getBeanContext());
+ assertNull(support.lastInitBeanContext);
+ assertSame(ctx, support.lastReleaseBeanContext);
+ assertEquals(l1.lastEvent.getPropertyName(), "beanContext");
+ assertNull(l1.lastEvent.getNewValue());
+ assertSame(l1.lastEvent.getOldValue(), ctx);
+ assertSame(l1.lastEvent.getSource(), peer);
+ assertEquals(l2.lastEvent.getPropertyName(), "beanContext");
+ assertNull(l2.lastEvent.getNewValue());
+ assertSame(l2.lastEvent.getOldValue(), ctx);
+ assertSame(l2.lastEvent.getSource(), peer);
+ }
+
+ public void testSetBeanContext_VetoedByListener()
+ throws PropertyVetoException {
+ MockBeanContextChildSupport support = new MockBeanContextChildSupport();
+ MockBeanContext oldCtx = new MockBeanContext();
+ support.setBeanContext(oldCtx);
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockVetoChangeListener l2 = new MockVetoChangeListener();
+ support.addPropertyChangeListener("beanContext", l1);
+ support.addVetoableChangeListener("beanContext", l2);
+
+ MockBeanContext ctx = new MockBeanContext();
+
+ support.clearLastRecords();
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ try {
+ support.setBeanContext(ctx);
+ fail();
+ } catch (PropertyVetoException e) {
+ // expected
+ }
+ assertSame(oldCtx, support.getBeanContext());
+ assertNull(support.lastInitBeanContext);
+ assertNull(support.lastReleaseBeanContext);
+ assertNull(l1.lastEvent);
+ assertEquals(l2.lastEvent.getPropertyName(), "beanContext");
+ assertSame(l2.lastEvent.getNewValue(), oldCtx);
+ assertSame(l2.lastEvent.getOldValue(), ctx);
+ assertSame(l2.lastEvent.getSource(), support);
+ assertTrue(support.rejectedSetBCOnce());
+ }
+
+ public void testSetBeanContext_VetoedByValidateMethod() {
+ MockBeanContextChildSupport support = new MockBeanContextChildSupport();
+ support.vetoBeanContext = true;
+ MockPropertyChangeListener l1 = new MockPropertyChangeListener();
+ MockVetoableChangeListener l2 = new MockVetoableChangeListener();
+ support.addPropertyChangeListener("beanContext", l1);
+ support.addVetoableChangeListener("beanContext", l2);
+
+ MockBeanContext ctx = new MockBeanContext();
+ assertNull(support.getBeanContext());
+
+ support.clearLastRecords();
+ l1.clearLastEvent();
+ l2.clearLastEvent();
+ try {
+ support.setBeanContext(ctx);
+ fail();
+ } catch (PropertyVetoException e) {
+ // expected
+ }
+ assertNull(support.getBeanContext());
+ assertNull(support.lastInitBeanContext);
+ assertNull(l1.lastEvent);
+ assertNull(l2.lastEvent);
+ assertTrue(support.rejectedSetBCOnce());
+ }
+
+ public void testValidatePendingSetBeanContext() {
+ // guess the impl always returns true
+ BeanContextChildSupport support = new MockBeanContextChildSupport();
+ assertTrue(support.validatePendingSetBeanContext(new MockBeanContext()));
+ assertTrue(support.validatePendingSetBeanContext(null));
+ }
+
+ public void testSerialization_NoPeer() throws IOException,
+ ClassNotFoundException {
+ BeanContextChildSupport support = new BeanContextChildSupport();
+ MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
+ MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
+ "id of pcl2");
+ MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
+ MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
+ "id of vcl2");
+ support.addPropertyChangeListener("beanContext", pcl1);
+ support.addPropertyChangeListener("beanContext", pcl2);
+ support.addVetoableChangeListener("beanContext", vcl1);
+ support.addVetoableChangeListener("beanContext", vcl2);
+
+ assertEqualsSerially(support,
+ (BeanContextChildSupport) SerializationTester
+ .getDeserilizedObject(support));
+ }
+
+ public void testSerialization_WithNonSerializablePeer() throws IOException,
+ ClassNotFoundException {
+ MockBeanContextChild peer = new MockBeanContextChild();
+ BeanContextChildSupport support = new BeanContextChildSupport(peer);
+ MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
+ MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
+ "id of pcl2");
+ MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
+ MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
+ "id of vcl2");
+ support.addPropertyChangeListener("beanContext", pcl1);
+ support.addPropertyChangeListener("beanContext", pcl2);
+ support.addVetoableChangeListener("beanContext", vcl1);
+ support.addVetoableChangeListener("beanContext", vcl2);
+
+ try {
+ SerializationTester.getDeserilizedObject(support);
+ fail();
+ } catch (IOException e) {
+ // expected
+ }
+ }
+
+ public void testSerialization_WithPeer() throws IOException,
+ ClassNotFoundException {
+ MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
+ "id of peer");
+ BeanContextChildSupport support = peer.support;
+ MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
+ MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
+ "id of pcl2");
+ MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
+ MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
+ "id of vcl2");
+ support.addPropertyChangeListener("beanContext", pcl1);
+ support.addPropertyChangeListener("beanContext", pcl2);
+ support.addVetoableChangeListener("beanContext", vcl1);
+ support.addVetoableChangeListener("beanContext", vcl2);
+
+ assertEqualsSerially(support,
+ (BeanContextChildSupport) SerializationTester
+ .getDeserilizedObject(support));
+ }
+
+ public void testSerialization_Compatibility() throws IOException,
+ ClassNotFoundException, Exception {
+ MockBeanContextChildDelegateS peer = new MockBeanContextChildDelegateS(
+ "id of peer");
+ BeanContextChildSupport support = peer.support;
+ MockPropertyChangeListener pcl1 = new MockPropertyChangeListener();
+ MockPropertyChangeListenerS pcl2 = new MockPropertyChangeListenerS(
+ "id of pcl2");
+ MockVetoableChangeListener vcl1 = new MockVetoableChangeListener();
+ MockVetoableChangeListenerS vcl2 = new MockVetoableChangeListenerS(
+ "id of vcl2");
+ support.addPropertyChangeListener("beanContext", pcl1);
+ support.addPropertyChangeListener("beanContext", pcl2);
+ support.addVetoableChangeListener("beanContext", vcl1);
+ support.addVetoableChangeListener("beanContext", vcl2);
+
+ assertEqualsSerially(
+ support,
+ (BeanContextChildSupport) SerializationTester
+ .readObject(support,
+ "serialization/java/beans/beancontext/BeanContextChildSupport.ser"));
+ }
+
+ public static void assertEqualsSerially(BeanContextChildSupport orig,
+ BeanContextChildSupport ser) {
+ // check peer
+ if (orig == orig.getBeanContextChildPeer()) {
+ assertSame(ser, ser.getBeanContextChildPeer());
+ } else {
+ assertSame(orig.getBeanContextChildPeer().getClass(), ser
+ .getBeanContextChildPeer().getClass());
+ if (orig.getBeanContextChildPeer() instanceof MockBeanContextChildDelegateS) {
+ MockBeanContextChildDelegateS origPeer = (MockBeanContextChildDelegateS) orig
+ .getBeanContextChildPeer();
+ MockBeanContextChildDelegateS serPeer = (MockBeanContextChildDelegateS) ser
+ .getBeanContextChildPeer();
+ assertEquals(origPeer.id, serPeer.id);
+ }
+ }
+
+ // check property change listeners
+ PropertyChangeSupport origPCS = (PropertyChangeSupport) Utils.getField(
+ orig, "pcSupport");
+ PropertyChangeSupport serPCS = (PropertyChangeSupport) Utils.getField(
+ ser, "pcSupport");
+ PropertyChangeListener origPCL[] = origPCS
+ .getPropertyChangeListeners("beanContext");
+ PropertyChangeListener serPCL[] = serPCS
+ .getPropertyChangeListeners("beanContext");
+ int i = 0, j = 0;
+ while (i < origPCL.length) {
+ if (origPCL[i] instanceof Serializable) {
+ assertSame(origPCL[i].getClass(), serPCL[j].getClass());
+ if (origPCL[i] instanceof MockPropertyChangeListenerS) {
+ assertEquals(((MockPropertyChangeListenerS) origPCL[i]).id,
+ ((MockPropertyChangeListenerS) serPCL[j]).id);
+ }
+ i++;
+ j++;
+ } else {
+ i++;
+ }
+ }
+ assertEquals(serPCL.length, j);
+
+ // check vetoable change listeners
+ VetoableChangeSupport origVCS = (VetoableChangeSupport) Utils.getField(
+ orig, "vcSupport");
+ VetoableChangeSupport serVCS = (VetoableChangeSupport) Utils.getField(
+ ser, "vcSupport");
+ VetoableChangeListener origVCL[] = origVCS
+ .getVetoableChangeListeners("beanContext");
+ VetoableChangeListener serVCL[] = serVCS
+ .getVetoableChangeListeners("beanContext");
+ i = 0;
+ j = 0;
+ while (i < origVCL.length) {
+ if (origVCL[i] instanceof Serializable) {
+ assertSame(origVCL[i].getClass(), serVCL[j].getClass());
+ if (origVCL[i] instanceof MockVetoableChangeListenerS) {
+ assertEquals(((MockVetoableChangeListenerS) origVCL[i]).id,
+ ((MockVetoableChangeListenerS) serVCL[j]).id);
+ }
+ i++;
+ j++;
+ } else {
+ i++;
+ }
+ }
+ assertEquals(serVCL.length, j);
+ }
+
/** TEST CONSTRUCTORS * */
/**
@@ -976,7 +979,6 @@
assertNotNull("BeanContext should not be null", sup.getBeanContext());
}
-
/** UTILITY METHODS * */
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java?view=diff&rev=452415&r1=452414&r2=452415
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextEventTest.java Tue Oct 3 04:05:57 2006
@@ -20,105 +20,105 @@
import java.beans.beancontext.BeanContext;
import java.beans.beancontext.BeanContextEvent;
-import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
-
import junit.framework.TestCase;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
+
/**
* Test BeanContextEvent
*/
public class BeanContextEventTest extends TestCase {
- private static class MockBeanContextEvent extends BeanContextEvent {
-
+ private static class MockBeanContextEvent extends BeanContextEvent {
+
static final long serialVersionUID = -5990761357871915928L;
- /**
- * @param bc
- */
- protected MockBeanContextEvent(BeanContext bc) {
- super(bc);
-
- assertSame(bc, getSource());
- assertSame(bc, getBeanContext());
- assertNull(this.propagatedFrom);
- }
-
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(BeanContextEventTest.class);
- }
-
- public void testBeanContextEvent_NullParam() {
- try {
- new MockBeanContextEvent(null);
- fail("IAE expected");
- } catch (IllegalArgumentException e) {
- // expected
- }
- }
-
- public void testBeanContextEvent() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertSame(ctx, event.getSource());
- assertSame(ctx, event.getBeanContext());
- assertNull(event.getPropagatedFrom());
- assertFalse(event.isPropagated());
- }
-
- public void testGetBeanContext() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertSame(ctx, event.getBeanContext());
- }
-
- public void testGetPropagatedFrom() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertNull(event.getPropagatedFrom());
-
- BeanContext ctx2 = new MockBeanContext();
- event.setPropagatedFrom(ctx2);
- assertSame(ctx2, event.getPropagatedFrom());
-
- event.setPropagatedFrom(ctx);
- assertSame(ctx, event.getPropagatedFrom());
-
- event.setPropagatedFrom(null);
- assertNull(event.getPropagatedFrom());
- }
-
- public void testIsPropagated() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertFalse(event.isPropagated());
-
- BeanContext ctx2 = new MockBeanContext();
- event.setPropagatedFrom(ctx2);
- assertTrue(event.isPropagated());
-
- event.setPropagatedFrom(ctx);
- assertTrue(event.isPropagated());
-
- event.setPropagatedFrom(null);
- assertFalse(event.isPropagated());
- }
-
- public void testSetPropagatedFrom() {
- BeanContext ctx = new MockBeanContext();
- BeanContextEvent event = new MockBeanContextEvent(ctx);
- assertNull(event.getPropagatedFrom());
-
- BeanContext ctx2 = new MockBeanContext();
- event.setPropagatedFrom(ctx2);
- assertSame(ctx2, event.getPropagatedFrom());
-
- event.setPropagatedFrom(ctx);
- assertSame(ctx, event.getPropagatedFrom());
-
- event.setPropagatedFrom(null);
- assertNull(event.getPropagatedFrom());
- }
+ /**
+ * @param bc
+ */
+ protected MockBeanContextEvent(BeanContext bc) {
+ super(bc);
+
+ assertSame(bc, getSource());
+ assertSame(bc, getBeanContext());
+ assertNull(this.propagatedFrom);
+ }
+
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(BeanContextEventTest.class);
+ }
+
+ public void testBeanContextEvent_NullParam() {
+ try {
+ new MockBeanContextEvent(null);
+ fail("IAE expected");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ public void testBeanContextEvent() {
+ BeanContext ctx = new MockBeanContext();
+ BeanContextEvent event = new MockBeanContextEvent(ctx);
+ assertSame(ctx, event.getSource());
+ assertSame(ctx, event.getBeanContext());
+ assertNull(event.getPropagatedFrom());
+ assertFalse(event.isPropagated());
+ }
+
+ public void testGetBeanContext() {
+ BeanContext ctx = new MockBeanContext();
+ BeanContextEvent event = new MockBeanContextEvent(ctx);
+ assertSame(ctx, event.getBeanContext());
+ }
+
+ public void testGetPropagatedFrom() {
+ BeanContext ctx = new MockBeanContext();
+ BeanContextEvent event = new MockBeanContextEvent(ctx);
+ assertNull(event.getPropagatedFrom());
+
+ BeanContext ctx2 = new MockBeanContext();
+ event.setPropagatedFrom(ctx2);
+ assertSame(ctx2, event.getPropagatedFrom());
+
+ event.setPropagatedFrom(ctx);
+ assertSame(ctx, event.getPropagatedFrom());
+
+ event.setPropagatedFrom(null);
+ assertNull(event.getPropagatedFrom());
+ }
+
+ public void testIsPropagated() {
+ BeanContext ctx = new MockBeanContext();
+ BeanContextEvent event = new MockBeanContextEvent(ctx);
+ assertFalse(event.isPropagated());
+
+ BeanContext ctx2 = new MockBeanContext();
+ event.setPropagatedFrom(ctx2);
+ assertTrue(event.isPropagated());
+
+ event.setPropagatedFrom(ctx);
+ assertTrue(event.isPropagated());
+
+ event.setPropagatedFrom(null);
+ assertFalse(event.isPropagated());
+ }
+
+ public void testSetPropagatedFrom() {
+ BeanContext ctx = new MockBeanContext();
+ BeanContextEvent event = new MockBeanContextEvent(ctx);
+ assertNull(event.getPropagatedFrom());
+
+ BeanContext ctx2 = new MockBeanContext();
+ event.setPropagatedFrom(ctx2);
+ assertSame(ctx2, event.getPropagatedFrom());
+
+ event.setPropagatedFrom(ctx);
+ assertSame(ctx, event.getPropagatedFrom());
+
+ event.setPropagatedFrom(null);
+ assertNull(event.getPropagatedFrom());
+ }
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java?view=diff&rev=452415&r1=452414&r2=452415
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextMembershipEventTest.java Tue Oct 3 04:05:57 2006
@@ -42,7 +42,7 @@
BeanContextMembershipEvent {
static final long serialVersionUID = -4761911723636245515L;
-
+
/**
* @param bc
* @param changes
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java?view=diff&rev=452415&r1=452414&r2=452415
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceAvailableEventTest.java Tue Oct 3 04:05:57 2006
@@ -39,7 +39,7 @@
private static class MockBeanContextServiceAvailableEvent extends
BeanContextServiceAvailableEvent {
-
+
static final long serialVersionUID = 796722290390289532L;
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java?view=diff&rev=452415&r1=452414&r2=452415
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java Tue Oct 3 04:05:57 2006
@@ -38,7 +38,7 @@
private static class MockBeanContextServiceRevokedEvent extends
BeanContextServiceRevokedEvent {
-
+
static final long serialVersionUID = -705194281645674622L;
/**
@@ -115,7 +115,7 @@
assertTrue(event.isServiceClass(BeanContext.class));
assertFalse(event.isServiceClass(Integer.class));
- //Regression for HARMONY-1516
+ // Regression for HARMONY-1516
assertFalse(event.isServiceClass(null));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java?view=diff&rev=452415&r1=452414&r2=452415
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServicesSupportTest.java Tue Oct 3 04:05:57 2006
@@ -60,7 +60,7 @@
BeanContextServicesSupport {
static final long serialVersionUID = -5521269152428572350L;
-
+
public MethodInvocationRecords records;
public MockBeanContextServicesSupport() {
@@ -107,6 +107,7 @@
*
* @see java.beans.beancontext.BeanContextSupport#initialize()
*/
+ @Override
public void initialize() {
super.initialize();
if (records == null) {
@@ -121,6 +122,7 @@
* @see java.beans.beancontext.BeanContextServicesSupport#addService(java.lang.Class,
* java.beans.beancontext.BeanContextServiceProvider, boolean)
*/
+ @Override
public boolean addService(Class serviceClass,
BeanContextServiceProvider bcsp, boolean fireEvent) {
return super.addService(serviceClass, bcsp, fireEvent);
@@ -132,6 +134,7 @@
* @see java.beans.beancontext.BeanContextSupport#childJustRemovedHook(java.lang.Object,
* java.beans.beancontext.BeanContextSupport.BCSChild)
*/
+ @Override
protected void childJustRemovedHook(Object child, BCSChild bcsc) {
super.childJustRemovedHook(child, bcsc);
records.add("childJustRemovedHook", child, bcsc, null);
@@ -143,6 +146,7 @@
* @see java.beans.beancontext.BeanContextServicesSupport#createBCSSServiceProvider(java.lang.Class,
* java.beans.beancontext.BeanContextServiceProvider)
*/
+ @Override
protected BCSSServiceProvider createBCSSServiceProvider(Class sc,
BeanContextServiceProvider bcsp) {
BCSSServiceProvider result = super.createBCSSServiceProvider(sc,
@@ -177,6 +181,7 @@
*
* @see java.beans.beancontext.BeanContextServicesListener#serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent)
*/
+ @Override
public void serviceAvailable(BeanContextServiceAvailableEvent bcssae) {
super.serviceAvailable(bcssae);
records.add("serviceAvailable", bcssae, null);
@@ -187,6 +192,7 @@
*
* @see java.beans.beancontext.BeanContextServiceRevokedListener#serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent)
*/
+ @Override
public void serviceRevoked(BeanContextServiceRevokedEvent bcssre) {
super.serviceRevoked(bcssre);
records.add("serviceRevoked", bcssre, null);
@@ -387,11 +393,11 @@
}
public void testBcsPreDeserializationHook() {
- // covered by serialization test
+ // covered by serialization test
}
public void testBcsPreSerializationHook() {
- // covered by serialization test
+ // covered by serialization test
}
/*
@@ -505,11 +511,11 @@
}
public void testCreateBCSChild() {
- // coverd in super's testcase
+ // coverd in super's testcase
}
public void testCreateBCSSServiceProvider() {
- // coverd by addService
+ // coverd by addService
}
/*
@@ -672,14 +678,26 @@
MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
Iterator iter = support.getCurrentServiceSelectors(Collection.class);
assertNull(iter);
- //Regression for HARMONY-1397
+ // Regression for HARMONY-1397
class TestServiceProvider implements BeanContextServiceProvider {
- public Object getService(BeanContextServices p0, Object p1, Class p2, Object p3) {return null;}
- public void releaseService(BeanContextServices p0, Object p1, Object p2) {}
- public Iterator getCurrentServiceSelectors(BeanContextServices p0, Class p1) {return null;}
+ public Object getService(BeanContextServices p0, Object p1,
+ Class p2, Object p3) {
+ return null;
+ }
+
+ public void releaseService(BeanContextServices p0, Object p1,
+ Object p2) {
+ }
+
+ public Iterator getCurrentServiceSelectors(BeanContextServices p0,
+ Class p1) {
+ return null;
+ }
}
- support.addService(BeanContextServicesSupportTest.class, new TestServiceProvider());
- assertNotNull(support.getCurrentServiceSelectors(BeanContextServicesSupportTest.class));
+ support.addService(BeanContextServicesSupportTest.class,
+ new TestServiceProvider());
+ assertNotNull(support
+ .getCurrentServiceSelectors(BeanContextServicesSupportTest.class));
}
public void testGetCurrentServiceSelectors() {
@@ -872,11 +890,11 @@
}
public void testInitialize() {
- // covered by other testcases
+ // covered by other testcases
}
public void testInitializeBeanContextResources() {
- // covered by super testcases, nothing more to test here
+ // covered by super testcases, nothing more to test here
}
public void testReleaseBeanContextResources()
@@ -1242,11 +1260,11 @@
}
public void testServiceAvailable() {
- // covered by testAddService
+ // covered by testAddService
}
public void testServiceRevoked() {
- // covered by testRemoveService
+ // covered by testRemoveService
}
public void testSerialization() throws IOException, ClassNotFoundException {