harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r417685 [11/15] - in /incubator/harmony/enhanced/classlib/trunk/modules/beans: ./ make/ src/test/java/org/apache/harmony/beans/tests/java/beans/ src/test/java/org/apache/harmony/beans/tests/java/beans/auxiliary/ src/test/java/org/apache/har...
Date Wed, 28 Jun 2006 07:22:23 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java Wed Jun 28 00:22:12 2006
@@ -28,317 +28,319 @@
 import junit.framework.TestSuite;
 import org.apache.harmony.beans.tests.java.beans.EncoderTest.SampleBean;
 import org.apache.harmony.beans.tests.java.beans.XMLEncoderTest.DependencyBean;
-import org.apache.harmony.beans.tests.java.beans.mock.MockBean4Codec;
-import org.apache.harmony.beans.tests.java.beans.mock.MockExceptionListener;
+import org.apache.harmony.beans.tests.support.mock.MockBean4Codec;
+import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Owner;
+import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target;
+import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField;
+import org.apache.harmony.beans.tests.support.mock.MockExceptionListener;
 
 /**
  * Tests XMLDecoder
  */
 public class XMLDecoderTest extends TestCase {
 
-	public static void main(String[] args) {
-		junit.textui.TestRunner.run(XMLDecoderTest.class);
-	}
-
-	static byte xml123bytes[] = null;
-
-	static {
-		ByteArrayOutputStream byteout = new ByteArrayOutputStream();
-		XMLEncoder enc = new XMLEncoder(byteout);
-		enc.writeObject(Integer.valueOf("1"));
-		enc.writeObject(Integer.valueOf("2"));
-		enc.writeObject(Integer.valueOf("3"));
-		enc.close();
-		xml123bytes = byteout.toByteArray();
-	}
-
-	public void testClose() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		assertEquals(Integer.valueOf("1"), dec.readObject());
-
-		dec.close();
-
-		assertEquals(Integer.valueOf("2"), dec.readObject());
-		assertEquals(Integer.valueOf("3"), dec.readObject());
-	}
-
-	public void testGetExceptionListener() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		assertNotNull(dec.getExceptionListener());
-	}
-
-	public void testGetOwner() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		assertNull(dec.getOwner());
-	}
-
-	public void testReadObject_ArrayOutOfBounds() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		assertEquals(Integer.valueOf("1"), dec.readObject());
-		assertEquals(Integer.valueOf("2"), dec.readObject());
-		assertEquals(Integer.valueOf("3"), dec.readObject());
-
-		try {
-			dec.readObject();
-			fail();
-		} catch (ArrayIndexOutOfBoundsException e) {
-			// expected
-		}
-	}
-
-	public void testReadObject_Null() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/null.xml"));
-		Object obj = dec.readObject();
-		assertNull(obj);
-	}
-
-	public void testReadObject_Integer() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/int.xml"));
-		Object obj = dec.readObject();
-		assertEquals(Integer.valueOf("3"), obj);
-	}
-
-	public void testReadObject_StringCodec() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/SampleBean_StringCodec.xml"));
-		SampleBean obj = (SampleBean) dec.readObject();
-		assertEquals("<Li Yang> & \"liyang'", obj.getMyid());
-		assertEquals("a child", obj.getRef().getMyid());
-	}
-
-	public void testReadObject_IntArray() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/IntArray.xml"));
-		int ints[] = (int[]) dec.readObject();
-		assertEquals(1, ints[0]);
-		assertEquals(2, ints[1]);
-		assertEquals(3, ints[2]);
-	}
-
-	public void testReadObject_PropertyDependency() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/DependencyBean.xml"));
-		DependencyBean b = (DependencyBean) dec.readObject();
-		assertEquals(888, b.getInts()[0]);
-		assertSame(b.getInts(), b.getRef());
-	}
-
-	public void testReadObject_NoChange() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4Codec_NoChange.xml"));
-		MockBean4Codec b = (MockBean4Codec) dec.readObject();
-	}
-
-	public void testReadObject_BornFriendChange() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4Codec_BornFriendChange.xml"));
-		MockBean4Codec b = (MockBean4Codec) dec.readObject();
-		assertEquals(888, b.getBornFriend().getZarr()[0]);
-		assertEquals(b.getBornFriend(), b.getNill());
-	}
-
-	public void testReadObject_ManyChanges() {
-		XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4Codec_ManyChanges.xml"));
-		MockBean4Codec b = (MockBean4Codec) dec.readObject();
-		assertEquals(127, b.getB());
-		assertSame(b, b.getBackRef());
-		assertEquals(new Byte((byte) 127), b.getBobj());
-		assertEquals(false, b.isBool());
-		assertEquals(Boolean.TRUE, b.getBoolobj());
-		assertEquals(Exception.class, b.getBornFriend().getClazz());
-		assertEquals(888, b.getBornFriend().getZarr()[0]);
-		assertEquals('Z', b.getC());
-		assertEquals(String.class, b.getClazz());
-		assertEquals(new Character('z'), b.getCobj());
-		assertEquals(123.456, b.getD(), 0);
-		assertEquals(new Double(123.456), b.getDobj());
-		assertEquals(12.34F, b.getF(), 0);
-		assertEquals(new Float(12.34F), b.getFobj());
-		assertEquals(MockBean4Codec.class, b.getFriend().getClazz());
-		assertEquals(999, b.getI());
-		assertEquals(new Integer(999), b.getIobj());
-		assertEquals(8888888, b.getL());
-		assertEquals(new Long(8888888), b.getLobj());
-		assertEquals("Li Yang", b.getName());
-		assertNull(b.getNill());
-		assertEquals(55, b.getS());
-		assertEquals(new Short((short) 55), b.getSobj());
-		assertEquals(3, b.getZarr().length);
-		assertEquals(3, b.getZarr()[0]);
-		assertEquals(2, b.getZarr()[1]);
-		assertEquals(1, b.getZarr()[2]);
-		assertEquals(1, b.getZarrarr().length);
-		assertEquals(3, b.getZarrarr()[0].length);
-		assertEquals("6", b.getZarrarr()[0][0]);
-		assertEquals("6", b.getZarrarr()[0][1]);
-		assertEquals("6", b.getZarrarr()[0][2]);
-	}
-
-	public void testReadObject_StaticField() {
-		XMLDecoder dec1 = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4StaticField_Original.xml"));
-		MockBean4StaticField o1 = (MockBean4StaticField) dec1.readObject();
-
-		XMLDecoder dec2 = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4StaticField.xml"));
-		MockBean4StaticField o2 = (MockBean4StaticField) dec2.readObject();
-
-		if (!o1.equals(o2)) {
-			System.out
-					.println("Loading object with static field, original xml: "
-							+ o1.getV());
-			System.out.println("Loading object with static field, field xml: "
-					+ o2.getV());
-		}
-
-		assertEquals(o1, o2);
-	}
-
-	public void testReadObject_Owner() {
-		MockBean4Owner_Owner o1 = new MockBean4Owner_Owner();
-		XMLDecoder dec1 = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4Owner_SetOwner.xml"), o1);
-		MockBean4Owner_Target t1 = (MockBean4Owner_Target) dec1.readObject();
-
-		assertEquals(o1.getV(), 1);
-		assertEquals(o1, t1.getV());
-	}
-
-	public void testReadObject_Owner_WithWriteStatement() {
-		MockBean4Owner_Owner o2 = new MockBean4Owner_Owner();
-		XMLDecoder dec2 = new XMLDecoder(this.getClass().getResourceAsStream(
-				"/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml"), o2);
-		MockBean4Owner_Target t2 = (MockBean4Owner_Target) dec2.readObject();
-
-		assertEquals(o2.getV(), 999);
-		assertEquals(o2, t2.getV());
-	}
-
-	public void testSetExceptionListener() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		Object defaultL = dec.getExceptionListener();
-
-		dec.setExceptionListener(null);
-		assertSame(defaultL, dec.getExceptionListener());
-
-		ExceptionListener newL = new MockExceptionListener();
-		dec.setExceptionListener(newL);
-		assertSame(newL, dec.getExceptionListener());
-	}
-
-	public void testSetExceptionListener_CatchException() {
-		MockExceptionListener l = new MockExceptionListener();
-		XMLDecoder dec = new XMLDecoder(XMLDecoderTest.class
-				.getResourceAsStream("/xml/bad_int.xml"), null, l);
-		assertTrue(l.size() > 0);
-	}
-
-	public void testSetOwner() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		assertNull(dec.getOwner());
-
-		String owner = "owner";
-		dec.setOwner(owner);
-		assertSame(owner, dec.getOwner());
-
-		dec.setOwner(null);
-		assertNull(dec.getOwner());
-	}
-
-	/*
-	 * Class under test for void XMLDecoder(java.io.InputStream)
-	 */
-	public void testXMLDecoderInputStream() {
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
-		assertNull(dec.getOwner());
-		assertNotNull(dec.getExceptionListener());
-	}
-
-	/*
-	 * Class under test for void XMLDecoder(java.io.InputStream,
-	 * java.lang.Object)
-	 */
-	public void testXMLDecoderInputStreamObject() {
-		String owner = "owner";
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
-				owner);
-		assertSame(owner, dec.getOwner());
-		assertNotNull(dec.getExceptionListener());
-	}
-
-	/*
-	 * Class under test for void XMLDecoder(java.io.InputStream,
-	 * java.lang.Object, java.beans.ExceptionListener)
-	 */
-	public void testXMLDecoderInputStreamObjectExceptionListener() {
-		String owner = "owner";
-		MockExceptionListener l = new MockExceptionListener();
-		XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
-				owner, l);
-		assertSame(owner, dec.getOwner());
-		assertSame(l, dec.getExceptionListener());
-	}
-    
-    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(XMLDecoderTest.class);
+    }
+
+    static byte xml123bytes[] = null;
+
+    static {
+        ByteArrayOutputStream byteout = new ByteArrayOutputStream();
+        XMLEncoder enc = new XMLEncoder(byteout);
+        enc.writeObject(Integer.valueOf("1"));
+        enc.writeObject(Integer.valueOf("2"));
+        enc.writeObject(Integer.valueOf("3"));
+        enc.close();
+        xml123bytes = byteout.toByteArray();
+    }
+
+    public void testClose() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        assertEquals(Integer.valueOf("1"), dec.readObject());
+
+        dec.close();
+
+        assertEquals(Integer.valueOf("2"), dec.readObject());
+        assertEquals(Integer.valueOf("3"), dec.readObject());
+    }
+
+    public void testGetExceptionListener() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        assertNotNull(dec.getExceptionListener());
+    }
+
+    public void testGetOwner() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        assertNull(dec.getOwner());
+    }
+
+    public void testReadObject_ArrayOutOfBounds() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        assertEquals(Integer.valueOf("1"), dec.readObject());
+        assertEquals(Integer.valueOf("2"), dec.readObject());
+        assertEquals(Integer.valueOf("3"), dec.readObject());
+
+        try {
+            dec.readObject();
+            fail();
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // expected
+        }
+    }
+
+    public void testReadObject_Null() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/null.xml"));
+        Object obj = dec.readObject();
+        assertNull(obj);
+    }
+
+    public void testReadObject_Integer() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/int.xml"));
+        Object obj = dec.readObject();
+        assertEquals(Integer.valueOf("3"), obj);
+    }
+
+    public void testReadObject_StringCodec() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/SampleBean_StringCodec.xml"));
+        SampleBean obj = (SampleBean) dec.readObject();
+        assertEquals("<Li Yang> & \"liyang'", obj.getMyid());
+        assertEquals("a child", obj.getRef().getMyid());
+    }
+
+    public void testReadObject_IntArray() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/IntArray.xml"));
+        int ints[] = (int[]) dec.readObject();
+        assertEquals(1, ints[0]);
+        assertEquals(2, ints[1]);
+        assertEquals(3, ints[2]);
+    }
+
+    public void testReadObject_PropertyDependency() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/DependencyBean.xml"));
+        DependencyBean b = (DependencyBean) dec.readObject();
+        assertEquals(888, b.getInts()[0]);
+        assertSame(b.getInts(), b.getRef());
+    }
+
+    public void testReadObject_NoChange() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4Codec_NoChange.xml"));
+        dec.readObject();
+    }
+
+    public void testReadObject_BornFriendChange() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4Codec_BornFriendChange.xml"));
+        MockBean4Codec b = (MockBean4Codec) dec.readObject();
+        assertEquals(888, b.getBornFriend().getZarr()[0]);
+        assertEquals(b.getBornFriend(), b.getNill());
+    }
+
+    public void testReadObject_ManyChanges() {
+        XMLDecoder dec = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4Codec_ManyChanges.xml"));
+        MockBean4Codec b = (MockBean4Codec) dec.readObject();
+        assertEquals(127, b.getB());
+        assertSame(b, b.getBackRef());
+        assertEquals(new Byte((byte) 127), b.getBobj());
+        assertEquals(false, b.isBool());
+        assertEquals(Boolean.TRUE, b.getBoolobj());
+        assertEquals(Exception.class, b.getBornFriend().getClazz());
+        assertEquals(888, b.getBornFriend().getZarr()[0]);
+        assertEquals('Z', b.getC());
+        assertEquals(String.class, b.getClazz());
+        assertEquals(new Character('z'), b.getCobj());
+        assertEquals(123.456, b.getD(), 0);
+        assertEquals(new Double(123.456), b.getDobj());
+        assertEquals(12.34F, b.getF(), 0);
+        assertEquals(new Float(12.34F), b.getFobj());
+        assertEquals(MockBean4Codec.class, b.getFriend().getClazz());
+        assertEquals(999, b.getI());
+        assertEquals(new Integer(999), b.getIobj());
+        assertEquals(8888888, b.getL());
+        assertEquals(new Long(8888888), b.getLobj());
+        assertEquals("Li Yang", b.getName());
+        assertNull(b.getNill());
+        assertEquals(55, b.getS());
+        assertEquals(new Short((short) 55), b.getSobj());
+        assertEquals(3, b.getZarr().length);
+        assertEquals(3, b.getZarr()[0]);
+        assertEquals(2, b.getZarr()[1]);
+        assertEquals(1, b.getZarr()[2]);
+        assertEquals(1, b.getZarrarr().length);
+        assertEquals(3, b.getZarrarr()[0].length);
+        assertEquals("6", b.getZarrarr()[0][0]);
+        assertEquals("6", b.getZarrarr()[0][1]);
+        assertEquals("6", b.getZarrarr()[0][2]);
+    }
+
+    public void testReadObject_StaticField() {
+        XMLDecoder dec1 = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4StaticField_Original.xml"));
+        MockBean4StaticField o1 = (MockBean4StaticField) dec1.readObject();
+
+        XMLDecoder dec2 = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4StaticField.xml"));
+        MockBean4StaticField o2 = (MockBean4StaticField) dec2.readObject();
+
+        if (!o1.equals(o2)) {
+            System.out
+                    .println("Loading object with static field, original xml: "
+                            + o1.getV());
+            System.out.println("Loading object with static field, field xml: "
+                    + o2.getV());
+        }
+
+        assertEquals(o1, o2);
+    }
+
+    public void testReadObject_Owner() {
+        MockBean4Owner_Owner o1 = new MockBean4Owner_Owner();
+        XMLDecoder dec1 = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4Owner_SetOwner.xml"), o1);
+        MockBean4Owner_Target t1 = (MockBean4Owner_Target) dec1.readObject();
+
+        assertEquals(o1.getV(), 1);
+        assertEquals(o1, t1.getV());
+    }
+
+    public void testReadObject_Owner_WithWriteStatement() {
+        MockBean4Owner_Owner o2 = new MockBean4Owner_Owner();
+        XMLDecoder dec2 = new XMLDecoder(this.getClass().getResourceAsStream(
+                "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml"), o2);
+        MockBean4Owner_Target t2 = (MockBean4Owner_Target) dec2.readObject();
+
+        assertEquals(o2.getV(), 999);
+        assertEquals(o2, t2.getV());
+    }
+
+    public void testSetExceptionListener() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        Object defaultL = dec.getExceptionListener();
+
+        dec.setExceptionListener(null);
+        assertSame(defaultL, dec.getExceptionListener());
+
+        ExceptionListener newL = new MockExceptionListener();
+        dec.setExceptionListener(newL);
+        assertSame(newL, dec.getExceptionListener());
+    }
+
+    public void testSetExceptionListener_CatchException() {
+        MockExceptionListener l = new MockExceptionListener();
+        new XMLDecoder(XMLDecoderTest.class
+                .getResourceAsStream("/xml/bad_int.xml"), null, l);
+        assertTrue(l.size() > 0);
+    }
+
+    public void testSetOwner() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        assertNull(dec.getOwner());
+
+        String owner = "owner";
+        dec.setOwner(owner);
+        assertSame(owner, dec.getOwner());
+
+        dec.setOwner(null);
+        assertNull(dec.getOwner());
+    }
+
+    /*
+     * Class under test for void XMLDecoder(java.io.InputStream)
+     */
+    public void testXMLDecoderInputStream() {
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
+        assertNull(dec.getOwner());
+        assertNotNull(dec.getExceptionListener());
+    }
+
+    /*
+     * Class under test for void XMLDecoder(java.io.InputStream,
+     * java.lang.Object)
+     */
+    public void testXMLDecoderInputStreamObject() {
+        String owner = "owner";
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
+                owner);
+        assertSame(owner, dec.getOwner());
+        assertNotNull(dec.getExceptionListener());
+    }
+
+    /*
+     * Class under test for void XMLDecoder(java.io.InputStream,
+     * java.lang.Object, java.beans.ExceptionListener)
+     */
+    public void testXMLDecoderInputStreamObjectExceptionListener() {
+        String owner = "owner";
+        MockExceptionListener l = new MockExceptionListener();
+        XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
+                owner, l);
+        assertSame(owner, dec.getOwner());
+        assertSame(l, dec.getExceptionListener());
+    }
+
     /**
      * The test checks the code generation for XML from Test1.xml
      */
-    public void testDecodeLinkedList() {
+    public void testDecodeLinkedList() throws Exception {
         decode("xml/Test1.xml");
     }
 
     /**
      * The test checks the code generation for XML from Test2.xml
      */
-    public void testDecodePrimitiveArrayByLength() {
+    public void testDecodePrimitiveArrayByLength() throws Exception {
         decode("xml/Test2.xml");
     }
-    
+
     /**
      * The test checks the code generation for XML from Test3.xml
      */
-    public void testDecodePrimitiveArrayByElements() {
+    public void testDecodePrimitiveArrayByElements() throws Exception {
         decode("xml/Test3.xml");
     }
-    
+
     /**
      * The test checks the code generation for XML from Test4.xml
      */
-    public void testDecodeObjectArrayByLength() {
+    public void testDecodeObjectArrayByLength() throws Exception {
         decode("xml/Test4.xml");
     }
-    
+
     /**
      * The test checks the code generation for XML from Test5.xml
      */
-    public void testDecodeObjectArrayByElements() {
+    public void testDecodeObjectArrayByElements() throws Exception {
         decode("xml/Test5.xml");
     }
-    
+
     /**
      * The test checks the code generation for XML from Test6.xml
      */
-    public void testDecodeReference() {
+    public void testDecodeReference() throws Exception {
         decode("xml/Test6.xml");
     }
-    
+
     /**
      * The test checks the code generation for XML from Test7.xml
      */
-    public void testDecodeStringArray() {
+    public void testDecodeStringArray() throws Exception {
         decode("xml/Test7.xml");
     }
 
     /*
      * The test checks the code generation for XML from MainTest.xml
      * 
-    public void testMain() {
-        decode("xml/MainTest.xml");
-    }
-    */
+     public void testMain() {
+     decode("xml/MainTest.xml");
+     }
+     */
 
     /**
      * 
@@ -346,26 +348,23 @@
     public static Test suite() {
         return new TestSuite(XMLDecoderTest.class);
     }
-    
+
     /**
      * 
      */
-    private void decode(String resourceName) {
+    private void decode(String resourceName) throws Exception {
         XMLDecoder d = null;
         try {
             Introspector.setBeanInfoSearchPath(new String[] {});
-            d = new XMLDecoder(new BufferedInputStream(
-                                                       ClassLoader.getSystemClassLoader().getResourceAsStream(resourceName)));
-            while(true) {
-                Object obj = d.readObject();
+            d = new XMLDecoder(new BufferedInputStream(ClassLoader
+                    .getSystemClassLoader().getResourceAsStream(resourceName)));
+            while (true) {
+                d.readObject();
             }
         } catch (ArrayIndexOutOfBoundsException aibe) {
             assertTrue(true);
-        } catch (Exception e) {
-            System.out.println(e.getClass() + " :" + e.getMessage());
-            fail("Exception " + e.getClass() + " is thrown");
         } finally {
-            if(d != null) {
+            if (d != null) {
                 d.close();
             }
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java Wed Jun 28 00:22:12 2006
@@ -32,11 +32,15 @@
 import junit.framework.TestCase;
 //import junit.framework.TestSuite;
 import org.apache.harmony.beans.tests.java.beans.EncoderTest.SampleBean;
-import org.apache.harmony.beans.tests.java.beans.mock.MockBean4Codec;
 
-import org.apache.harmony.beans.tests.java.beans.auxiliary.StandardBean;
-import org.apache.harmony.beans.tests.java.beans.auxiliary.AType;
-import org.apache.harmony.beans.tests.java.beans.auxiliary.TestEventHandler;
+import org.apache.harmony.beans.tests.support.AType;
+import org.apache.harmony.beans.tests.support.StandardBean;
+import org.apache.harmony.beans.tests.support.TestEventHandler;
+import org.apache.harmony.beans.tests.support.mock.MockBean4Codec;
+import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Owner;
+import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target;
+import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField;
+import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField_PD;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
@@ -326,7 +330,7 @@
 
 	public void testXMLEncoder_Null() {
 		try {
-			XMLEncoder enc = new XMLEncoder(null);
+			new XMLEncoder(null);
 		} catch (NullPointerException e) {
 			// expected
 		}
@@ -504,7 +508,7 @@
         });
         
         try {
-            e.writeObject(new Double((double) 0.01));
+            e.writeObject(new Double(0.01));
         } catch (Exception excp) {
             fail("Exception " + excp.getClass() +" is thrown: "
                     + excp.getMessage());

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/AllTests.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/AllTests.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/AllTests.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/AllTests.java Wed Jun 28 00:22:12 2006
@@ -38,7 +38,6 @@
 		suite.addTestSuite(BeanContextServiceRevokedEventTest.class);
 		suite.addTestSuite(BeanContextServicesSupportTest.class);
 		suite.addTestSuite(BeanContextSupportTest.class);
-		suite.addTestSuite(InterfacesTest.class);
 		// $JUnit-END$
 		return suite;
 	}

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?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- 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 Wed Jun 28 00:22:12 2006
@@ -23,19 +23,20 @@
 import java.beans.beancontext.BeanContext;
 import java.beans.beancontext.BeanContextChild;
 import java.beans.beancontext.BeanContextChildSupport;
-import java.beans.beancontext.BeanContextServicesListener;
 import java.beans.beancontext.BeanContextSupport;
 import java.io.IOException;
 import java.io.Serializable;
 
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContext;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextChild;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextChildDelegateS;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockPropertyChangeListener;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockPropertyChangeListenerS;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockVetoChangeListener;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockVetoableChangeListener;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockVetoableChangeListenerS;
+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;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextChildDelegateS;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockPropertyChangeListener;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockPropertyChangeListenerS;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoChangeListener;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListener;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockVetoableChangeListenerS;
+
 import tests.util.SerializationTester;
 
 import junit.framework.Test;
@@ -57,8 +58,8 @@
 		public boolean vetoBeanContext = false;
 
 		/**
-		 * 
-		 */
+         * 
+         */
 		public MockBeanContextChildSupport() {
 			super();
 			assertNull(this.beanContext);
@@ -67,8 +68,8 @@
 		}
 
 		/**
-		 * @param bcc
-		 */
+         * @param bcc
+         */
 		public MockBeanContextChildSupport(BeanContextChild bcc) {
 			super(bcc);
 			assertNull(this.beanContext);
@@ -81,19 +82,19 @@
 		}
 
 		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.beancontext.BeanContextChildSupport#initializeBeanContextResources()
-		 */
+         * (non-Javadoc)
+         * 
+         * @see java.beans.beancontext.BeanContextChildSupport#initializeBeanContextResources()
+         */
 		protected void initializeBeanContextResources() {
 			lastInitBeanContext = this.beanContext;
 		}
 
 		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.beancontext.BeanContextChildSupport#releaseBeanContextResources()
-		 */
+         * (non-Javadoc)
+         * 
+         * @see java.beans.beancontext.BeanContextChildSupport#releaseBeanContextResources()
+         */
 		protected void releaseBeanContextResources() {
 			lastReleaseBeanContext = this.beanContext;
 		}
@@ -104,10 +105,10 @@
 		}
 
 		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.beancontext.BeanContextChildSupport#validatePendingSetBeanContext(java.beans.beancontext.BeanContext)
-		 */
+         * (non-Javadoc)
+         * 
+         * @see java.beans.beancontext.BeanContextChildSupport#validatePendingSetBeanContext(java.beans.beancontext.BeanContext)
+         */
 		public boolean validatePendingSetBeanContext(BeanContext newValue) {
 			if (vetoBeanContext) {
 				return false;
@@ -252,27 +253,21 @@
 	}
 
 	/*
-	 * Class under test for void BeanContextChildSupport()
-	 */
+     * 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)
-	 */
+     * 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);
 	}
@@ -647,7 +642,7 @@
 		BeanContextChildSupport support = new MockBeanContextChildSupport();
 		support.serviceAvailable(null);
         
-        //Regression for HARMONY-372
+        // Regression for HARMONY-372
         (new java.beans.beancontext.BeanContextChildSupport()).serviceAvailable(null);
         (new java.beans.beancontext.BeanContextChildSupport()).serviceRevoked(null); 
 	}
@@ -943,59 +938,49 @@
     
     
     
-    /** TEST CONSTRUCTORS **/
+    /** TEST CONSTRUCTORS * */
 
-    /** * Test constructor with BeanContextChild parameter.<p>
-     *
+    /**
+     * * Test constructor with BeanContextChild parameter.
+     * <p>
+     * 
      * @see BeanContextChildSupport#BeanContextChildSupport(BeanContextChild)
      */
-    public void testConstructorBeanContextChild() {
-        try {
-            BeanContextChildSupport sup = new BeanContextChildSupport(null);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    public void testConstructorBeanContextChild() throws Exception {
+        new BeanContextChildSupport(null);
     }
 
-    /** * Test constructor with no parameters.<p>
-     *
+    /**
+     * * Test constructor with no parameters.
+     * <p>
+     * 
      * @see BeanContextChildSupport#BeanContextChildSupport()
      */
-    public void testConstructor() {
-        try {
-            BeanContextChildSupport sup = new BeanContextChildSupport();
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    public void testConstructor() throws Exception {
+        new BeanContextChildSupport();
     }
 
-    /** TEST METHODS **/
+    /** TEST METHODS * */
 
     /**
-     * Test method setBeanContext() with BeanContext parameter.<p>
+     * Test method setBeanContext() with BeanContext parameter.
+     * <p>
      */
-    public void testSetBeanContextBeanContext() {
-        try {
-            BeanContextChildSupport sup = new BeanContextChildSupport();
-            sup.setBeanContext(new BeanContextSupport());
-            
-            if (sup.getBeanContext() == null) {
-                fail("BeanContext should not be null");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    public void testSetBeanContextBeanContext() throws Exception {
+        BeanContextChildSupport sup = new BeanContextChildSupport();
+        sup.setBeanContext(new BeanContextSupport());
+
+        assertNotNull("BeanContext should not be null", sup.getBeanContext());
     }
+    
 
-    /** UTILITY METHODS **/
+    /** UTILITY METHODS * */
 
-    /** STANDARD ENDING **/
+    /** STANDARD ENDING * */
 
     /**
-     * Start testing from the command line.<p>
+     * Start testing from the command line.
+     * <p>
      */
     public static Test suite() {
         return new TestSuite(BeanContextChildSupportTest.class);

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?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- 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 Wed Jun 28 00:22:12 2006
@@ -17,9 +17,8 @@
 
 import java.beans.beancontext.BeanContext;
 import java.beans.beancontext.BeanContextEvent;
-import java.util.EventObject;
 
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContext;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContext;
 
 import junit.framework.TestCase;
 
@@ -49,8 +48,8 @@
 
 	public void testBeanContextEvent_NullParam() {
 		try {
-			BeanContextEvent event = new MockBeanContextEvent(null);
-			fail();
+			new MockBeanContextEvent(null);
+			fail("IAE expected");
 		} catch (IllegalArgumentException e) {
 			// expected
 		}
@@ -63,8 +62,6 @@
 		assertSame(ctx, event.getBeanContext());
 		assertNull(event.getPropagatedFrom());
 		assertFalse(event.isPropagated());
-
-		assertTrue(event instanceof EventObject);
 	}
 
 	public void testGetBeanContext() {
@@ -120,5 +117,4 @@
 		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?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- 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 Wed Jun 28 00:22:12 2006
@@ -16,7 +16,6 @@
 package org.apache.harmony.beans.tests.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;
@@ -25,8 +24,11 @@
 import java.util.Iterator;
 
 import junit.framework.TestCase;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContext;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextDelegateS;
+
+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.MockBeanContextDelegateS;
+
 import tests.util.SerializationTester;
 
 /**
@@ -34,256 +36,247 @@
  */
 public class BeanContextMembershipEventTest extends TestCase {
 
-	private static class MockBeanContextMembershipEvent extends
-			BeanContextMembershipEvent {
+    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,
-								"serialization/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);
-	}
+        /**
+         * @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 {
+            new MockBeanContextMembershipEvent(null, c);
+            fail("IAE expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            new MockBeanContextMembershipEvent(null, array);
+            fail("IAE expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            new MockBeanContextMembershipEvent(ctx, (Collection) null);
+            fail("NPE expected");
+        } catch (NullPointerException e) {
+            // expected
+        }
+
+        try {
+            new MockBeanContextMembershipEvent(ctx, (Object[]) null);
+            fail("NPE expected");
+        } 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());
+    }
+
+    /*
+     * 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" };
+        new MockBeanContextMembershipEvent(ctx, array);
+    }
+
+    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,
+                                "serialization/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);
+    }
 
 }

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?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- 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 Wed Jun 28 00:22:12 2006
@@ -16,7 +16,6 @@
 package org.apache.harmony.beans.tests.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;
@@ -25,8 +24,10 @@
 import java.util.Iterator;
 
 import junit.framework.TestCase;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextServices;
+
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServices;
+
 import tests.util.SerializationTester;
 
 /**
@@ -34,120 +35,118 @@
  */
 public class BeanContextServiceAvailableEventTest extends TestCase {
 
-	private static class MockBeanContextServiceAvailableEvent extends
-			BeanContextServiceAvailableEvent {
+    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,
-								"serialization/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());
-	}
+        /**
+         * @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 {
+            new MockBeanContextServiceAvailableEvent(null, BeanContext.class);
+            fail("IAE expected");
+        } 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());
+    }
+
+    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,
+                                "serialization/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());
+    }
 }

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?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- 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 Wed Jun 28 00:22:12 2006
@@ -16,7 +16,6 @@
 package org.apache.harmony.beans.tests.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;
@@ -24,8 +23,10 @@
 import java.util.ArrayList;
 
 import junit.framework.TestCase;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextDelegateS;
-import org.apache.harmony.beans.tests.java.beans.beancontext.mock.MockBeanContextServices;
+
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextDelegateS;
+import org.apache.harmony.beans.tests.support.beancontext.mock.MockBeanContextServices;
+
 import tests.util.SerializationTester;
 
 /**
@@ -33,137 +34,136 @@
  */
 public class BeanContextServiceRevokedEventTest extends TestCase {
 
-	private static class MockBeanContextServiceRevokedEvent extends
-			BeanContextServiceRevokedEvent {
+    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,
-								"serialization/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());
-	}
+        /**
+         * @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 {
+            new MockBeanContextServiceRevokedEvent(null, BeanContext.class,
+                    true);
+            fail("IAE expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
+                services, null, true);
+        assertNull(event.getServiceClass());
+        assertSame(services, event.getSource());
+        assertSame(services, event.getSourceAsBeanContextServices());
+        assertEquals(true, event.isCurrentServiceInvalidNow());
+        try {
+            event.isServiceClass(Integer.class);
+            fail("NPE expected");
+        } 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());
+    }
+
+    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,
+                                "serialization/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());
+    }
 }



Mime
View raw message