harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r394923 [11/16] - in /incubator/harmony/enhanced/classlib/trunk/modules/beans: make/common/ src/test/java.injected/ src/test/java.injected/java/ src/test/java.injected/java/beans/ src/test/java/tests/ src/test/java/tests/api/ src/test/java/...
Date Tue, 18 Apr 2006 12:11:45 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/bad_int.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/bad_int.xml?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/bad_int.xml (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/bad_int.xml Tue Apr 18 05:11:09 2006
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+
+<!-- Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+     
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+     
+         http://www.apache.org/licenses/LICENSE-2.0
+     
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+<java version="1.4.2_07" class="java.beans.XMLDecoder"> 
+ <int>3</inta> 
+</java> 

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/AllTests.java?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/AllTests.java Tue Apr 18 05:11:09 2006
@@ -0,0 +1,44 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.beans.beancontext;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test for java.beans.beancontext.
+ */
+public class AllTests {
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(suite());
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("Test for java.beans.beancontext");
+		// $JUnit-BEGIN$
+		suite.addTestSuite(BeanContextChildSupportTest.class);
+		suite.addTestSuite(BeanContextEventTest.class);
+		suite.addTestSuite(BeanContextMembershipEventTest.class);
+		suite.addTestSuite(BeanContextServiceAvailableEventTest.class);
+		suite.addTestSuite(BeanContextServiceRevokedEventTest.class);
+		suite.addTestSuite(BeanContextServicesSupportTest.class);
+		suite.addTestSuite(BeanContextSupportTest.class);
+		suite.addTestSuite(InterfacesTest.class);
+		// $JUnit-END$
+		return suite;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupport.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupport.ser?rev=394923&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupport.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupportTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupportTest.java?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupportTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextChildSupportTest.java Tue Apr 18 05:11:09 2006
@@ -0,0 +1,917 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.beans.beancontext;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+import java.beans.beancontext.BeanContext;
+import java.beans.beancontext.BeanContextChild;
+import java.beans.beancontext.BeanContextChildSupport;
+import java.beans.beancontext.BeanContextServicesListener;
+import java.io.IOException;
+import java.io.Serializable;
+
+import tests.api.java.beans.beancontext.mock.MockBeanContext;
+import tests.api.java.beans.beancontext.mock.MockBeanContextChild;
+import tests.api.java.beans.beancontext.mock.MockBeanContextChildDelegateS;
+import tests.api.java.beans.beancontext.mock.MockPropertyChangeListener;
+import tests.api.java.beans.beancontext.mock.MockPropertyChangeListenerS;
+import tests.api.java.beans.beancontext.mock.MockVetoChangeListener;
+import tests.api.java.beans.beancontext.mock.MockVetoableChangeListener;
+import tests.api.java.beans.beancontext.mock.MockVetoableChangeListenerS;
+import tests.util.SerializationTester;
+
+import junit.framework.TestCase;
+
+/**
+ * Test BeanContextChildSupport
+ */
+public class BeanContextChildSupportTest extends TestCase {
+
+	private static class MockBeanContextChildSupport extends
+			BeanContextChildSupport {
+
+		public BeanContext lastInitBeanContext = null;
+
+		public BeanContext lastReleaseBeanContext = null;
+
+		public boolean vetoBeanContext = false;
+
+		/**
+		 * 
+		 */
+		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;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see java.beans.beancontext.BeanContextChildSupport#initializeBeanContextResources()
+		 */
+		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;
+		}
+
+		/*
+		 * (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);
+	}
+
+	/*
+	 * Class under test for void BeanContextChildSupport()
+	 */
+	public void testBeanContextChildSupport() {
+		BeanContextChildSupport support = new MockBeanContextChildSupport();
+		assertTrue(support instanceof BeanContextChild);
+		assertTrue(support instanceof BeanContextServicesListener);
+		assertTrue(support instanceof Serializable);
+		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);
+		assertTrue(support instanceof BeanContextChild);
+		assertTrue(support instanceof BeanContextServicesListener);
+		assertTrue(support instanceof Serializable);
+		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 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 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 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,
+								"tests/api/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);
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextEventTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextEventTest.java?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextEventTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextEventTest.java Tue Apr 18 05:11:09 2006
@@ -0,0 +1,124 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.beans.beancontext;
+
+import java.beans.beancontext.BeanContext;
+import java.beans.beancontext.BeanContextEvent;
+import java.util.EventObject;
+
+import tests.api.java.beans.beancontext.mock.MockBeanContext;
+
+import junit.framework.TestCase;
+
+/**
+ * Test BeanContextEvent
+ */
+public class BeanContextEventTest extends TestCase {
+
+	private static class MockBeanContextEvent extends BeanContextEvent {
+
+		/**
+		 * @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 {
+			BeanContextEvent event = new MockBeanContextEvent(null);
+			fail();
+		} 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());
+
+		assertTrue(event instanceof EventObject);
+	}
+
+	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());
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEvent.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEvent.ser?rev=394923&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEvent.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEventTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEventTest.java?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEventTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextMembershipEventTest.java Tue Apr 18 05:11:09 2006
@@ -0,0 +1,289 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.beans.beancontext;
+
+import java.beans.beancontext.BeanContext;
+import java.beans.beancontext.BeanContextEvent;
+import java.beans.beancontext.BeanContextMembershipEvent;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+import tests.api.java.beans.beancontext.mock.MockBeanContext;
+import tests.api.java.beans.beancontext.mock.MockBeanContextDelegateS;
+import tests.util.SerializationTester;
+
+/**
+ * Test BeanContextMembershipEvent
+ */
+public class BeanContextMembershipEventTest extends TestCase {
+
+	private static class MockBeanContextMembershipEvent extends
+			BeanContextMembershipEvent {
+
+		/**
+		 * @param bc
+		 * @param changes
+		 */
+		public MockBeanContextMembershipEvent(BeanContext bc, Object[] changes) {
+			super(bc, changes);
+		}
+
+		/**
+		 * @param bc
+		 * @param changes
+		 */
+		public MockBeanContextMembershipEvent(BeanContext bc, Collection changes) {
+			super(bc, changes);
+		}
+
+		public Collection collection() {
+			return this.children;
+		}
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(BeanContextMembershipEventTest.class);
+	}
+
+	public void testBeanContextMembershipEvent_NullParam() {
+		BeanContext ctx = new MockBeanContext();
+		Collection c = new ArrayList();
+		c.add("1");
+		c.add("2");
+		c.add("3");
+		String array[] = new String[] { "1", "2", "3" };
+
+		try {
+			MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+					null, c);
+			fail();
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+					null, array);
+			fail();
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+					ctx, (Collection) null);
+			fail();
+		} catch (NullPointerException e) {
+			// expected
+		}
+
+		try {
+			MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+					ctx, (Object[]) null);
+			fail();
+		} catch (NullPointerException e) {
+			// expected
+		}
+	}
+
+	/*
+	 * Class under test for void
+	 * BeanContextMembershipEvent(java.beans.beancontext.BeanContext,
+	 * java.util.Collection)
+	 */
+	public void testBeanContextMembershipEventBeanContextCollection() {
+		BeanContext ctx = new MockBeanContext();
+		Collection c = new ArrayList();
+		c.add("1");
+		c.add("2");
+		c.add("3");
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, c);
+		assertSame(c, event.collection());
+
+		assertTrue(event instanceof BeanContextEvent);
+	}
+
+	/*
+	 * Class under test for void
+	 * BeanContextMembershipEvent(java.beans.beancontext.BeanContext,
+	 * java.lang.Object[])
+	 */
+	public void testBeanContextMembershipEventBeanContextObjectArray() {
+		BeanContext ctx = new MockBeanContext();
+		String array[] = new String[] { "1", "2", "3" };
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, array);
+
+		assertTrue(event instanceof BeanContextEvent);
+	}
+
+	public void testSize_Collection() {
+		BeanContext ctx = new MockBeanContext();
+		Collection c = new ArrayList();
+		c.add("1");
+		c.add("2");
+		c.add("3");
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, c);
+		assertEquals(3, event.size());
+	}
+
+	public void testSize_Array() {
+		BeanContext ctx = new MockBeanContext();
+		String array[] = new String[] { "1", "2", "3" };
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, array);
+		assertEquals(3, event.size());
+	}
+
+	public void testContains_Collection() {
+		BeanContext ctx = new MockBeanContext();
+		Collection c = new ArrayList();
+		c.add("1");
+		c.add("2");
+		c.add("3");
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, c);
+		assertTrue(event.contains("1"));
+		assertTrue(event.contains("2"));
+		assertTrue(event.contains("3"));
+		assertFalse(event.contains(null));
+		assertFalse(event.contains("4"));
+	}
+
+	public void testContains_Array() {
+		BeanContext ctx = new MockBeanContext();
+		String array[] = new String[] { "1", "2", "3" };
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, array);
+		assertTrue(event.contains("1"));
+		assertTrue(event.contains("2"));
+		assertTrue(event.contains("3"));
+		assertFalse(event.contains(null));
+		assertFalse(event.contains("4"));
+	}
+
+	public void testToArray_Collection() {
+		BeanContext ctx = new MockBeanContext();
+		Collection c = new ArrayList();
+		c.add("1");
+		c.add("2");
+		c.add("3");
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, c);
+		Object resultArray[] = event.toArray();
+		assertEquals(3, resultArray.length);
+		assertEquals("1", resultArray[0]);
+		assertEquals("2", resultArray[1]);
+		assertEquals("3", resultArray[2]);
+	}
+
+	public void testToArray_Array() {
+		BeanContext ctx = new MockBeanContext();
+		String array[] = new String[] { "1", "2", "3" };
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, array);
+		Object resultArray[] = event.toArray();
+		assertEquals(3, resultArray.length);
+		assertEquals("1", resultArray[0]);
+		assertEquals("2", resultArray[1]);
+		assertEquals("3", resultArray[2]);
+	}
+
+	public void testIterator_Collection() {
+		BeanContext ctx = new MockBeanContext();
+		Collection c = new ArrayList();
+		c.add("1");
+		c.add("2");
+		c.add("3");
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, c);
+		Iterator it = event.iterator();
+		assertEquals("1", it.next());
+		assertEquals("2", it.next());
+		assertEquals("3", it.next());
+		assertFalse(it.hasNext());
+	}
+
+	public void testIterator_Array() {
+		BeanContext ctx = new MockBeanContext();
+		String array[] = new String[] { "1", "2", "3" };
+		MockBeanContextMembershipEvent event = new MockBeanContextMembershipEvent(
+				ctx, array);
+		Iterator it = event.iterator();
+		assertEquals("1", it.next());
+		assertEquals("2", it.next());
+		assertEquals("3", it.next());
+		assertFalse(it.hasNext());
+	}
+
+	public void testSerialization() throws IOException, ClassNotFoundException {
+		ArrayList things = new ArrayList();
+		things.add("1");
+		things.add("2");
+		things.add("3");
+		BeanContextMembershipEvent event = new BeanContextMembershipEvent(
+				new MockBeanContext(), things);
+		event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
+
+		assertEqualsSerially(event,
+				(BeanContextMembershipEvent) SerializationTester
+						.getDeserilizedObject(event));
+	}
+
+	public void testSerialization_Compatibility() throws Exception {
+		ArrayList things = new ArrayList();
+		things.add("1");
+		things.add("2");
+		things.add("3");
+		BeanContextMembershipEvent event = new BeanContextMembershipEvent(
+				new MockBeanContext(), things);
+		event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
+
+		assertEqualsSerially(
+				event,
+				(BeanContextMembershipEvent) SerializationTester
+						.readObject(event,
+								"tests/api/java/beans/beancontext/BeanContextMembershipEvent.ser"));
+	}
+
+	private void assertEqualsSerially(BeanContextMembershipEvent orig,
+			BeanContextMembershipEvent ser) {
+		assertNull(ser.getSource());
+
+		// check propagatedFrom
+		if (orig.getPropagatedFrom() instanceof Serializable) {
+			BeanContext origFrom = orig.getPropagatedFrom();
+			BeanContext serFrom = ser.getPropagatedFrom();
+			assertEquals(origFrom.getClass(), serFrom.getClass());
+			if (origFrom instanceof MockBeanContextDelegateS) {
+				assertEquals(((MockBeanContextDelegateS) origFrom).id,
+						((MockBeanContextDelegateS) serFrom).id);
+			}
+		}
+
+		// check children
+		Collection origChildren = (Collection) Utils.getField(orig, "children");
+		Collection serChildren = (Collection) Utils.getField(ser, "children");
+		assertEquals(origChildren, serChildren);
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEvent.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEvent.ser?rev=394923&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEvent.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEventTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEventTest.java?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEventTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceAvailableEventTest.java Tue Apr 18 05:11:09 2006
@@ -0,0 +1,153 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.beans.beancontext;
+
+import java.beans.beancontext.BeanContext;
+import java.beans.beancontext.BeanContextEvent;
+import java.beans.beancontext.BeanContextServiceAvailableEvent;
+import java.beans.beancontext.BeanContextServices;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+import tests.api.java.beans.beancontext.mock.MockBeanContextDelegateS;
+import tests.api.java.beans.beancontext.mock.MockBeanContextServices;
+import tests.util.SerializationTester;
+
+/**
+ * Test BeanContextServiceAvailableEvent
+ */
+public class BeanContextServiceAvailableEventTest extends TestCase {
+
+	private static class MockBeanContextServiceAvailableEvent extends
+			BeanContextServiceAvailableEvent {
+
+		/**
+		 * @param bcs
+		 * @param sc
+		 */
+		public MockBeanContextServiceAvailableEvent(BeanContextServices bcs,
+				Class sc) {
+			super(bcs, sc);
+			assertSame(sc, this.serviceClass);
+		}
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(BeanContextServiceAvailableEventTest.class);
+	}
+
+	public void testBeanContextServiceAvailableEvent_NullParam() {
+		BeanContextServices services = new MockBeanContextServices();
+
+		try {
+			BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
+					null, BeanContext.class);
+			fail();
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
+				services, null);
+		assertNull(event.getServiceClass());
+		assertSame(services, event.getSource());
+		assertSame(services, event.getSourceAsBeanContextServices());
+	}
+
+	public void testBeanContextServiceAvailableEvent() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
+				services, BeanContext.class);
+		assertSame(BeanContext.class, event.getServiceClass());
+		assertSame(services, event.getSource());
+		assertSame(services, event.getSourceAsBeanContextServices());
+		assertTrue(event instanceof BeanContextEvent);
+	}
+
+	public void testGetSourceAsBeanContextServices() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
+				services, BeanContext.class);
+		assertSame(services, event.getSource());
+		assertSame(services, event.getSourceAsBeanContextServices());
+	}
+
+	public void testGetServiceClass() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
+				services, BeanContext.class);
+		assertSame(BeanContext.class, event.getServiceClass());
+	}
+
+	public void testGetCurrentServiceSelectors() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceAvailableEvent event = new MockBeanContextServiceAvailableEvent(
+				services, BeanContext.class);
+
+		Iterator expectedIt = services
+				.getCurrentServiceSelectors(BeanContext.class);
+		Iterator it = event.getCurrentServiceSelectors();
+		while (expectedIt.hasNext()) {
+			assertSame(expectedIt.next(), it.next());
+		}
+		assertFalse(expectedIt.hasNext());
+		assertFalse(it.hasNext());
+	}
+
+	public void testSerialization() throws IOException, ClassNotFoundException {
+		BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
+				new MockBeanContextServices(), ArrayList.class);
+		event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
+
+		assertEqualsSerially(event,
+				(BeanContextServiceAvailableEvent) SerializationTester
+						.getDeserilizedObject(event));
+	}
+
+	public void testSerialization_Compatibility() throws Exception {
+		BeanContextServiceAvailableEvent event = new BeanContextServiceAvailableEvent(
+				new MockBeanContextServices(), ArrayList.class);
+		event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
+
+		assertEqualsSerially(
+				event,
+				(BeanContextServiceAvailableEvent) SerializationTester
+						.readObject(event,
+								"tests/api/java/beans/beancontext/BeanContextServiceAvailableEvent.ser"));
+	}
+
+	private void assertEqualsSerially(BeanContextServiceAvailableEvent orig,
+			BeanContextServiceAvailableEvent ser) {
+		assertNull(ser.getSource());
+
+		// check propagatedFrom
+		if (orig.getPropagatedFrom() instanceof Serializable) {
+			BeanContext origFrom = orig.getPropagatedFrom();
+			BeanContext serFrom = ser.getPropagatedFrom();
+			assertEquals(origFrom.getClass(), serFrom.getClass());
+			if (origFrom instanceof MockBeanContextDelegateS) {
+				assertEquals(((MockBeanContextDelegateS) origFrom).id,
+						((MockBeanContextDelegateS) serFrom).id);
+			}
+		}
+
+		// check serviceClass
+		assertEquals(orig.getServiceClass(), ser.getServiceClass());
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEvent.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEvent.ser?rev=394923&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEvent.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEventTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEventTest.java?rev=394923&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEventTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServiceRevokedEventTest.java Tue Apr 18 05:11:09 2006
@@ -0,0 +1,169 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.beans.beancontext;
+
+import java.beans.beancontext.BeanContext;
+import java.beans.beancontext.BeanContextEvent;
+import java.beans.beancontext.BeanContextServiceRevokedEvent;
+import java.beans.beancontext.BeanContextServices;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+import tests.api.java.beans.beancontext.mock.MockBeanContextDelegateS;
+import tests.api.java.beans.beancontext.mock.MockBeanContextServices;
+import tests.util.SerializationTester;
+
+/**
+ * Test BeanContextServiceRevokedEvent
+ */
+public class BeanContextServiceRevokedEventTest extends TestCase {
+
+	private static class MockBeanContextServiceRevokedEvent extends
+			BeanContextServiceRevokedEvent {
+
+		/**
+		 * @param bcs
+		 * @param sc
+		 * @param invalidate
+		 */
+		public MockBeanContextServiceRevokedEvent(BeanContextServices bcs,
+				Class sc, boolean invalidate) {
+			super(bcs, sc, invalidate);
+			assertSame(sc, this.serviceClass);
+		}
+
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(BeanContextServiceRevokedEventTest.class);
+	}
+
+	public void testBeanContextServiceRevokedEvent_NullParam() {
+		BeanContextServices services = new MockBeanContextServices();
+
+		try {
+			BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+					null, BeanContext.class, true);
+			fail();
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+					services, null, true);
+			assertNull(event.getServiceClass());
+			assertSame(services, event.getSource());
+			assertSame(services, event.getSourceAsBeanContextServices());
+			assertEquals(true, event.isCurrentServiceInvalidNow());
+			event.isServiceClass(Integer.class);
+			fail();
+		} catch (NullPointerException e) {
+			// expected
+		}
+	}
+
+	public void testBeanContextServiceRevokedEvent() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+				services, BeanContext.class, true);
+		assertSame(BeanContext.class, event.getServiceClass());
+		assertSame(services, event.getSource());
+		assertSame(services, event.getSourceAsBeanContextServices());
+		assertEquals(true, event.isCurrentServiceInvalidNow());
+		assertTrue(event instanceof BeanContextEvent);
+	}
+
+	public void testGetSourceAsBeanContextServices() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+				services, BeanContext.class, true);
+		assertSame(services, event.getSource());
+		assertSame(services, event.getSourceAsBeanContextServices());
+	}
+
+	public void testGetServiceClass() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+				services, BeanContext.class, true);
+		assertSame(BeanContext.class, event.getServiceClass());
+	}
+
+	public void testIsServiceClass() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+				services, BeanContext.class, true);
+		assertTrue(event.isServiceClass(BeanContext.class));
+		assertFalse(event.isServiceClass(Integer.class));
+	}
+
+	public void testIsCurrentServiceInvalidNow() {
+		BeanContextServices services = new MockBeanContextServices();
+		BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+				services, BeanContext.class, true);
+		assertEquals(true, event.isCurrentServiceInvalidNow());
+		event = new MockBeanContextServiceRevokedEvent(services,
+				BeanContext.class, false);
+		assertEquals(false, event.isCurrentServiceInvalidNow());
+	}
+
+	public void testSerialization() throws IOException, ClassNotFoundException {
+		BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
+				new MockBeanContextServices(), ArrayList.class, true);
+		event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
+
+		assertEqualsSerially(event,
+				(BeanContextServiceRevokedEvent) SerializationTester
+						.getDeserilizedObject(event));
+	}
+
+	public void testSerialization_Compatibility() throws Exception {
+		BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
+				new MockBeanContextServices(), ArrayList.class, true);
+		event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
+
+		assertEqualsSerially(
+				event,
+				(BeanContextServiceRevokedEvent) SerializationTester
+						.readObject(event,
+								"tests/api/java/beans/beancontext/BeanContextServiceRevokedEvent.ser"));
+	}
+
+	private void assertEqualsSerially(BeanContextServiceRevokedEvent orig,
+			BeanContextServiceRevokedEvent ser) {
+		assertNull(ser.getSource());
+
+		// check propagatedFrom
+		if (orig.getPropagatedFrom() instanceof Serializable) {
+			BeanContext origFrom = orig.getPropagatedFrom();
+			BeanContext serFrom = ser.getPropagatedFrom();
+			assertEquals(origFrom.getClass(), serFrom.getClass());
+			if (origFrom instanceof MockBeanContextDelegateS) {
+				assertEquals(((MockBeanContextDelegateS) origFrom).id,
+						((MockBeanContextDelegateS) serFrom).id);
+			}
+		}
+
+		// check serviceClass
+		assertEquals(orig.getServiceClass(), ser.getServiceClass());
+
+		// check invalidateRefs
+		assertEquals(orig.isCurrentServiceInvalidNow(), ser
+				.isCurrentServiceInvalidNow());
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServicesSupport.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServicesSupport.ser?rev=394923&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/tests/api/java/beans/beancontext/BeanContextServicesSupport.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message