harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r412641 [5/32] - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ main/java/java/beans/beancontext/ test/java-internal/java/beans/beancontext/ test/java/org/apache/harmony/beans/tests/ test/java/org/apa...
Date Thu, 08 Jun 2006 03:40:30 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AppletInitializerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AppletInitializerTest.java?rev=412641&r1=412640&r2=412641&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AppletInitializerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AppletInitializerTest.java Wed Jun  7 20:40:24 2006
@@ -1,42 +1,42 @@
-/* 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 org.apache.harmony.beans.tests.java.beans;
-
-import java.applet.Applet;
-import java.beans.AppletInitializer;
-import java.beans.beancontext.BeanContext;
-
-import junit.framework.TestCase;
-
-/**
- * Test the signature of the interface AppletInitializer.
- */
-public class AppletInitializerTest extends TestCase {
-
-    public void testSignature() {
-        DummyAppletInitializer o = new DummyAppletInitializer();
-        assertTrue(o instanceof AppletInitializer);
-    }
-    
-    static class DummyAppletInitializer implements AppletInitializer {
-
-        public void activate(Applet newApplet) {
-        }
-
-        public void initialize(Applet appletBean, BeanContext context) {
-        }
-    }
-}
+/* 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 org.apache.harmony.beans.tests.java.beans;
+
+import java.applet.Applet;
+import java.beans.AppletInitializer;
+import java.beans.beancontext.BeanContext;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the signature of the interface AppletInitializer.
+ */
+public class AppletInitializerTest extends TestCase {
+
+    public void testSignature() {
+        DummyAppletInitializer o = new DummyAppletInitializer();
+        assertTrue(o instanceof AppletInitializer);
+    }
+    
+    static class DummyAppletInitializer implements AppletInitializer {
+
+        public void activate(Applet newApplet) {
+        }
+
+        public void initialize(Applet appletBean, BeanContext context) {
+        }
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java?rev=412641&r1=412640&r2=412641&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java Wed Jun  7 20:40:24 2006
@@ -1,205 +1,205 @@
-/* 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 org.apache.harmony.beans.tests.java.beans;
-
-import java.awt.Component;
-import java.beans.BeanDescriptor;
-import java.beans.Customizer;
-import java.beans.PropertyChangeListener;
-import java.util.HashSet;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for BeanDescriptor.
- */
-public class BeanDescriptorTest extends TestCase {
-
-	/*
-	 * @see TestCase#setUp()
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
-
-	/*
-	 * @see TestCase#tearDown()
-	 */
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	/*
-	 * Class under test for void BeanDescriptor(Class)
-	 */
-	public void testBeanDescriptorClass() {
-		String beanName = "BeanDescriptorTest.bean";
-		MockJavaBean bean = new MockJavaBean(beanName);
-		Class beanClass = bean.getClass();
-		BeanDescriptor bd = new BeanDescriptor(beanClass);
-
-		assertSame(beanClass, bd.getBeanClass());
-		String displayName = beanClass.getName().substring(
-				beanClass.getName().lastIndexOf('.') + 1);
-		assertEquals(displayName, bd.getDisplayName());
-		assertEquals(displayName, bd.getName());
-		assertEquals(displayName, bd.getShortDescription());
-
-		assertNotNull(bd.attributeNames());
-		assertFalse(bd.isExpert());
-		assertFalse(bd.isHidden());
-		assertFalse(bd.isPreferred());
-	}
-
-	public void testBeanDescriptorClass_Null() {
-		try {
-			BeanDescriptor bd = new BeanDescriptor(null);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-		}
-	}
-
-	/*
-	 * Class under test for void BeanDescriptor(Class, Class)
-	 */
-	public void testBeanDescriptorClassClass() {
-		/*
-		 * String beanName = "BeanDescriptorTest.bean"; MockJavaBean bean = new
-		 * MockJavaBean(beanName); Class beanClass = bean.getClass(); Customizer
-		 * customizer = new MyCustomizer(); Class cusClass =
-		 * customizer.getClass(); BeanDescriptor bd = new
-		 * BeanDescriptor(beanClass, cusClass);
-		 * 
-		 * assertSame(beanClass, bd.getBeanClass()); assertSame(cusClass,
-		 * bd.getCustomizerClass());
-		 * 
-		 * String displayName = beanClass.getName().substring(
-		 * beanClass.getName().lastIndexOf('.') + 1); assertEquals(displayName,
-		 * bd.getDisplayName()); assertEquals(displayName, bd.getName());
-		 * assertEquals(displayName, bd.getShortDescription());
-		 * 
-		 * assertNotNull(bd.attributeNames()); assertFalse(bd.isExpert());
-		 * assertFalse(bd.isHidden()); assertFalse(bd.isPreferred());
-		 */
-	}
-
-	public void testBeanDescriptorClassClass_BeanClassNull() {
-		/*
-		 * Class beanClass = null; Customizer customizer = new MyCustomizer();
-		 * Class cusClass = customizer.getClass(); try { BeanDescriptor bd = new
-		 * BeanDescriptor(beanClass, cusClass); fail("Should throw
-		 * NullPointerException"); } catch (NullPointerException e) { }
-		 */
-	}
-
-	public void testBeanDescriptorClassClass_CustomizerClassNull() {
-		String beanName = "BeanDescriptorTest.bean";
-		MockJavaBean bean = new MockJavaBean(beanName);
-		Class beanClass = bean.getClass();
-		Class cusClass = null;
-		BeanDescriptor bd = new BeanDescriptor(beanClass, cusClass);
-
-		assertSame(beanClass, bd.getBeanClass());
-		assertNull(bd.getCustomizerClass());
-
-		String displayName = beanClass.getName().substring(
-				beanClass.getName().lastIndexOf('.') + 1);
-		assertEquals(displayName, bd.getDisplayName());
-		assertEquals(displayName, bd.getName());
-		assertEquals(displayName, bd.getShortDescription());
-
-		assertNotNull(bd.attributeNames());
-		assertFalse(bd.isExpert());
-		assertFalse(bd.isHidden());
-		assertFalse(bd.isPreferred());
-	}
-
-    class MyCustomizer extends Component implements Customizer {
-
-		HashSet listeners;
-
-		Object bean;
-
-		public MyCustomizer() {
-			this.listeners = new HashSet();
-			this.bean = null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.Customizer#addPropertyChangeListener(java.beans.PropertyChangeListener)
-		 */
-		public void addPropertyChangeListener(PropertyChangeListener listener) {
-			this.listeners.add(listener);
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.Customizer#removePropertyChangeListener(java.beans.PropertyChangeListener)
-		 */
-		public void removePropertyChangeListener(PropertyChangeListener listener) {
-			this.listeners.remove(listener);
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.Customizer#setObject(java.lang.Object)
-		 */
-		public void setObject(Object bean) {
-			this.bean = bean;
-		}
-	}
-    
-    
-    
-    /**
-     * @tests java.beans.BeanDescriptor#BeanDescriptor(
-     *        java.lang.Class)
-     */
-    public void test_Ctor1_NullPointerExpection() {
-        try {
-            // Regression for HARMONY-225
-            new BeanDescriptor(null);
-            fail("No expected NullPointerException");
-        } catch (NullPointerException e) {
-        }
-    }
-
-    /**
-     * @tests java.beans.BeanDescriptor#BeanDescriptor(
-     *        java.lang.Class,
-     *        java.lang.Class)
-     */
-    public void test_Ctor2_NullPointerExpection() {
-        try {
-            // Regression for HARMONY-225
-            new BeanDescriptor(null, String.class);
-            fail("No expected NullPointerException");
-        } catch (NullPointerException e) {
-        }
-    }
-    
-    /**
-     * The test checks the method testNullaryConstructor()
-     */
-    public void testNullaryConstructor() {
-        BeanDescriptor bd= new BeanDescriptor(String.class);
-        assertEquals(bd.getName(), "String");
-    }
-}
+/* 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 org.apache.harmony.beans.tests.java.beans;
+
+import java.awt.Component;
+import java.beans.BeanDescriptor;
+import java.beans.Customizer;
+import java.beans.PropertyChangeListener;
+import java.util.HashSet;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for BeanDescriptor.
+ */
+public class BeanDescriptorTest extends TestCase {
+
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+	}
+
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	/*
+	 * Class under test for void BeanDescriptor(Class)
+	 */
+	public void testBeanDescriptorClass() {
+		String beanName = "BeanDescriptorTest.bean";
+		MockJavaBean bean = new MockJavaBean(beanName);
+		Class beanClass = bean.getClass();
+		BeanDescriptor bd = new BeanDescriptor(beanClass);
+
+		assertSame(beanClass, bd.getBeanClass());
+		String displayName = beanClass.getName().substring(
+				beanClass.getName().lastIndexOf('.') + 1);
+		assertEquals(displayName, bd.getDisplayName());
+		assertEquals(displayName, bd.getName());
+		assertEquals(displayName, bd.getShortDescription());
+
+		assertNotNull(bd.attributeNames());
+		assertFalse(bd.isExpert());
+		assertFalse(bd.isHidden());
+		assertFalse(bd.isPreferred());
+	}
+
+	public void testBeanDescriptorClass_Null() {
+		try {
+			BeanDescriptor bd = new BeanDescriptor(null);
+			fail("Should throw NullPointerException.");
+		} catch (NullPointerException e) {
+		}
+	}
+
+	/*
+	 * Class under test for void BeanDescriptor(Class, Class)
+	 */
+	public void testBeanDescriptorClassClass() {
+		/*
+		 * String beanName = "BeanDescriptorTest.bean"; MockJavaBean bean = new
+		 * MockJavaBean(beanName); Class beanClass = bean.getClass(); Customizer
+		 * customizer = new MyCustomizer(); Class cusClass =
+		 * customizer.getClass(); BeanDescriptor bd = new
+		 * BeanDescriptor(beanClass, cusClass);
+		 * 
+		 * assertSame(beanClass, bd.getBeanClass()); assertSame(cusClass,
+		 * bd.getCustomizerClass());
+		 * 
+		 * String displayName = beanClass.getName().substring(
+		 * beanClass.getName().lastIndexOf('.') + 1); assertEquals(displayName,
+		 * bd.getDisplayName()); assertEquals(displayName, bd.getName());
+		 * assertEquals(displayName, bd.getShortDescription());
+		 * 
+		 * assertNotNull(bd.attributeNames()); assertFalse(bd.isExpert());
+		 * assertFalse(bd.isHidden()); assertFalse(bd.isPreferred());
+		 */
+	}
+
+	public void testBeanDescriptorClassClass_BeanClassNull() {
+		/*
+		 * Class beanClass = null; Customizer customizer = new MyCustomizer();
+		 * Class cusClass = customizer.getClass(); try { BeanDescriptor bd = new
+		 * BeanDescriptor(beanClass, cusClass); fail("Should throw
+		 * NullPointerException"); } catch (NullPointerException e) { }
+		 */
+	}
+
+	public void testBeanDescriptorClassClass_CustomizerClassNull() {
+		String beanName = "BeanDescriptorTest.bean";
+		MockJavaBean bean = new MockJavaBean(beanName);
+		Class beanClass = bean.getClass();
+		Class cusClass = null;
+		BeanDescriptor bd = new BeanDescriptor(beanClass, cusClass);
+
+		assertSame(beanClass, bd.getBeanClass());
+		assertNull(bd.getCustomizerClass());
+
+		String displayName = beanClass.getName().substring(
+				beanClass.getName().lastIndexOf('.') + 1);
+		assertEquals(displayName, bd.getDisplayName());
+		assertEquals(displayName, bd.getName());
+		assertEquals(displayName, bd.getShortDescription());
+
+		assertNotNull(bd.attributeNames());
+		assertFalse(bd.isExpert());
+		assertFalse(bd.isHidden());
+		assertFalse(bd.isPreferred());
+	}
+
+    class MyCustomizer extends Component implements Customizer {
+
+		HashSet listeners;
+
+		Object bean;
+
+		public MyCustomizer() {
+			this.listeners = new HashSet();
+			this.bean = null;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see java.beans.Customizer#addPropertyChangeListener(java.beans.PropertyChangeListener)
+		 */
+		public void addPropertyChangeListener(PropertyChangeListener listener) {
+			this.listeners.add(listener);
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see java.beans.Customizer#removePropertyChangeListener(java.beans.PropertyChangeListener)
+		 */
+		public void removePropertyChangeListener(PropertyChangeListener listener) {
+			this.listeners.remove(listener);
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see java.beans.Customizer#setObject(java.lang.Object)
+		 */
+		public void setObject(Object bean) {
+			this.bean = bean;
+		}
+	}
+    
+    
+    
+    /**
+     * @tests java.beans.BeanDescriptor#BeanDescriptor(
+     *        java.lang.Class)
+     */
+    public void test_Ctor1_NullPointerExpection() {
+        try {
+            // Regression for HARMONY-225
+            new BeanDescriptor(null);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    /**
+     * @tests java.beans.BeanDescriptor#BeanDescriptor(
+     *        java.lang.Class,
+     *        java.lang.Class)
+     */
+    public void test_Ctor2_NullPointerExpection() {
+        try {
+            // Regression for HARMONY-225
+            new BeanDescriptor(null, String.class);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
+        }
+    }
+    
+    /**
+     * The test checks the method testNullaryConstructor()
+     */
+    public void testNullaryConstructor() {
+        BeanDescriptor bd= new BeanDescriptor(String.class);
+        assertEquals(bd.getName(), "String");
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanInfoTest.java?rev=412641&r1=412640&r2=412641&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanInfoTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanInfoTest.java Wed Jun  7 20:40:24 2006
@@ -1,95 +1,95 @@
-/* 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 org.apache.harmony.beans.tests.java.beans;
-
-import java.awt.Image;
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.MethodDescriptor;
-import java.beans.PropertyDescriptor;
-
-import junit.framework.TestCase;
-
-/**
- * Test the signature of the interface BeanInfo.
- */
-public class BeanInfoTest extends TestCase {
-
-    public void testSignature() {
-        DummyBeanInfo o = new DummyBeanInfo();
-        assertTrue(o instanceof BeanInfo);
-    }
-    
-    static class DummyBeanInfo implements BeanInfo {
-        
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getAdditionalBeanInfo()
-         */
-        public BeanInfo[] getAdditionalBeanInfo() {
-            return null;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getBeanDescriptor()
-         */
-        public BeanDescriptor getBeanDescriptor() {
-            return null;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getDefaultEventIndex()
-         */
-        public int getDefaultEventIndex() {
-            return 0;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getDefaultPropertyIndex()
-         */
-        public int getDefaultPropertyIndex() {
-            return 0;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getEventSetDescriptors()
-         */
-        public EventSetDescriptor[] getEventSetDescriptors() {
-            return null;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getIcon(int)
-         */
-        public Image getIcon(int iconKind) {
-            return null;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getMethodDescriptors()
-         */
-        public MethodDescriptor[] getMethodDescriptors() {
-            return null;
-        }
-
-        /* (non-Javadoc)
-         * @see java.beans.BeanInfo#getPropertyDescriptors()
-         */
-        public PropertyDescriptor[] getPropertyDescriptors() {
-            return null;
-        }
-    }
-}
+/* 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 org.apache.harmony.beans.tests.java.beans;
+
+import java.awt.Image;
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the signature of the interface BeanInfo.
+ */
+public class BeanInfoTest extends TestCase {
+
+    public void testSignature() {
+        DummyBeanInfo o = new DummyBeanInfo();
+        assertTrue(o instanceof BeanInfo);
+    }
+    
+    static class DummyBeanInfo implements BeanInfo {
+        
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getAdditionalBeanInfo()
+         */
+        public BeanInfo[] getAdditionalBeanInfo() {
+            return null;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getBeanDescriptor()
+         */
+        public BeanDescriptor getBeanDescriptor() {
+            return null;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getDefaultEventIndex()
+         */
+        public int getDefaultEventIndex() {
+            return 0;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getDefaultPropertyIndex()
+         */
+        public int getDefaultPropertyIndex() {
+            return 0;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getEventSetDescriptors()
+         */
+        public EventSetDescriptor[] getEventSetDescriptors() {
+            return null;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getIcon(int)
+         */
+        public Image getIcon(int iconKind) {
+            return null;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getMethodDescriptors()
+         */
+        public MethodDescriptor[] getMethodDescriptors() {
+            return null;
+        }
+
+        /* (non-Javadoc)
+         * @see java.beans.BeanInfo#getPropertyDescriptors()
+         */
+        public PropertyDescriptor[] getPropertyDescriptors() {
+            return null;
+        }
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java?rev=412641&r1=412640&r2=412641&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java Wed Jun  7 20:40:24 2006
@@ -1,548 +1,548 @@
-/* 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 org.apache.harmony.beans.tests.java.beans;
-
-import java.awt.Component;
-import java.beans.AppletInitializer;
-import java.beans.Beans;
-import java.beans.beancontext.BeanContext;
-import java.beans.beancontext.BeanContextSupport;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.io.Externalizable;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.textui.TestRunner;
-import junit.framework.TestSuite;
-import org.apache.harmony.beans.tests.java.beans.mock.MockAppletInitializer;
-import org.apache.harmony.beans.tests.java.beans.auxiliary.SampleBean;
-
-/**
- * Unit test for java.beans.Beans
- */
-public class BeansTest extends TestCase {
-	private File fileURLCP = new File(System.getProperty("user.home"), "urlcp");
-
-	private File fileSer;
-
-	private File fileRes;
-
-	private File fileClass;
-
-	public BeansTest() {
-		File path = new File(fileURLCP, "serialization/java/beans/mock");
-		path.mkdirs();
-		fileSer = new File(path, "MockJavaBean2.ser");
-		fileClass = new File(path, "MockJavaBean2.class");
-	}
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-		if (fileSer.exists()) {
-			fileSer.delete();
-		}
-
-		if (fileClass.exists()) {
-			fileClass.delete();
-		}
-		fileURLCP.delete();
-	}
-
-	/*
-	 * public Beans()
-	 */
-	public void testBeans() {
-		Beans beans = new Beans();
-	}
-
-	/*
-	 * public static Object getInstanceOf(Object bean, Class targetType)
-	 */
-	public void testGetInstanceOf() {
-		MockJavaBean bean = new MockJavaBean();
-		Class type = Component.class;
-		Object obj = Beans.getInstanceOf(bean, type);
-		assertSame(bean, obj);
-	}
-
-	public void testGetInstanceOf_BeanNull() {
-		Class type = Component.class;
-		Object obj = Beans.getInstanceOf(null, type);
-		assertNull(obj);
-	}
-
-	public void testGetInstanceOf_TargetTypeNull() {
-		MockJavaBean bean = new MockJavaBean();
-		Object obj = Beans.getInstanceOf(bean, null);
-		assertSame(bean, obj);
-	}
-
-	/*
-	 * Class under test for Object instantiate(ClassLoader, String)
-	 */
-	public void testInstantiateClassLoaderString_Class() throws IOException,
-			ClassNotFoundException, NoSuchMethodException, SecurityException,
-			IllegalAccessException, InvocationTargetException {
-		// copy class
-		InputStream bin = getClass().getResourceAsStream(
-				"/binary/java/beans/mock/MockJavaBean2.bin");
-		copyFile(bin, fileClass);
-
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		Object bean = Beans.instantiate(loader,
-				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2");
-		assertEquals("as_class", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-	}
-
-	public void testInstantiateClassLoaderString_Ser() throws IOException,
-			ClassNotFoundException, IllegalAccessException,
-			InvocationTargetException, NoSuchMethodException {
-		// copy class
-		InputStream bin = getClass().getResourceAsStream(
-				"/binary/java/beans/mock/MockJavaBean2.bin");
-		copyFile(bin, fileClass);
-
-		// copy ser
-		InputStream res = getClass().getResourceAsStream(
-				"/serialization/java/beans/mock/MockJavaBean2.ser");
-		copyFile(res, fileSer);
-
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		Object bean = Beans.instantiate(loader,
-				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2");
-		assertEquals("as_object", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-	}
-
-	public void testInstantiateClassLoaderString_ClassLoaderNull()
-			throws IOException, ClassNotFoundException {
-		Object bean = Beans.instantiate(null, MockJavaBean.class.getName());
-		assertEquals(bean.getClass(), MockJavaBean.class);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-	}
-
-	public void testInstantiateClassLoaderString_BeanNameNull()
-			throws IOException, ClassNotFoundException {
-		try {
-			Object bean = Beans.instantiate(null, null);
-			fail("Should throw NullPointerException");
-		} catch (NullPointerException e) {
-		}
-	}
-
-	/*
-	 * Class under test for Object instantiate(ClassLoader, String, BeanContext)
-	 */
-	public void testInstantiateClassLoaderStringBeanContext_Class()
-			throws ClassNotFoundException, ClassNotFoundException, IOException,
-			IllegalAccessException, InvocationTargetException,
-			NoSuchMethodException {
-		// copy class
-		InputStream bin = getClass().getResourceAsStream(
-				"/binary/java/beans/mock/MockJavaBean2.bin");
-		copyFile(bin, fileClass);
-
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		BeanContext context = new BeanContextSupport();
-		Object bean = Beans.instantiate(loader,
-				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2", context);
-		assertEquals("as_class", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-		assertTrue(context.contains(bean));
-	}
-
-	public void testInstantiateClassLoaderStringBeanContext_Ser()
-			throws IOException, ClassNotFoundException, IllegalAccessException,
-			InvocationTargetException, NoSuchMethodException {
-		// copy class
-		InputStream bin = getClass().getResourceAsStream(
-				"/binary/java/beans/mock/MockJavaBean2.bin");
-		copyFile(bin, fileClass);
-
-		// copy ser
-		InputStream res = getClass().getResourceAsStream(
-				"/serialization/java/beans/mock/MockJavaBean2.ser");
-		copyFile(res, fileSer);
-
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		BeanContext context = new BeanContextSupport();
-		Object bean = Beans.instantiate(loader,
-				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2", context);
-		assertEquals("as_object", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-		assertTrue(context.contains(bean));
-	}
-
-	public void testInstantiateClassLoaderStringBeanContext_ClassLoaderNull()
-			throws IOException, ClassNotFoundException {
-		BeanContext context = new BeanContextSupport();
-		Object bean = Beans.instantiate(null, MockJavaBean.class.getName(),
-				context);
-		assertEquals(bean.getClass(), MockJavaBean.class);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-		assertTrue(context.contains(bean));
-	}
-
-	public void testInstantiateClassLoaderStringBeanContext_BeanNameNull()
-			throws IOException, ClassNotFoundException {
-		BeanContext context = new BeanContextSupport();
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		try {
-			Object bean = Beans.instantiate(loader, null, context);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-		}
-	}
-
-	public void testInstantiateClassLoaderStringBeanContext_ContextNull()
-			throws IOException, ClassNotFoundException {
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		Object bean = Beans.instantiate(loader, MockJavaBean.class.getName(),
-				null);
-		assertEquals(bean.getClass(), MockJavaBean.class);
-	}
-
-	/*
-	 * Class under test for Object instantiate(ClassLoader, String, BeanContext,
-	 * AppletInitializer)
-	 */
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Class()
-			throws IOException, ClassNotFoundException, IllegalAccessException,
-			InvocationTargetException, NoSuchMethodException {
-		// copy class
-		InputStream bin = getClass().getResourceAsStream(
-				"/binary/java/beans/mock/MockJavaBean2.bin");
-		copyFile(bin, fileClass);
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		String beanName = "org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2";
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(loader, beanName, context, appInit);
-
-		assertEquals("as_class", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-		assertTrue(context.contains(bean));
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Ser()
-			throws ClassNotFoundException, IOException,
-			InvocationTargetException, NoSuchMethodException,
-			IllegalAccessException {
-		// copy class
-		InputStream bin = getClass().getResourceAsStream(
-				"/binary/java/beans/mock/MockJavaBean2.bin");
-		copyFile(bin, fileClass);
-
-		// copy ser
-		InputStream res = getClass().getResourceAsStream(
-				"/serialization/java/beans/mock/MockJavaBean2.ser");
-		copyFile(res, fileSer);
-
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		String beanName = "org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2";
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(loader, beanName, context, appInit);
-
-		assertEquals("as_object", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-		assertTrue(context.contains(bean));
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_LoaderNull()
-			throws IOException, ClassNotFoundException {
-		String beanName = "org.apache.harmony.beans.tests.java.beans.MockJavaBean";
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(null, beanName, context, appInit);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-		assertEquals(beanName, bean.getClass().getName());
-		assertTrue(context.contains(bean));
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_BeanNull()
-			throws IOException, ClassNotFoundException {
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		try {
-			Object bean = Beans.instantiate(loader, null, context, appInit);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-		}
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_ContextNull()
-			throws IOException, ClassNotFoundException {
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		String beanName = "org.apache.harmony.beans.tests.java.beans.MockJavaBean";
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(loader, beanName, null, appInit);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-		assertEquals(beanName, bean.getClass().getName());
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_InitializerNull()
-			throws IOException, ClassNotFoundException {
-		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
-				.toURL() });
-		String beanName = "org.apache.harmony.beans.tests.java.beans.MockJavaBean";
-		BeanContext context = new BeanContextSupport();
-		Object bean = Beans.instantiate(loader, beanName, context, null);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-		assertEquals(beanName, bean.getClass().getName());
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean()
-			throws IOException, ClassNotFoundException {
-		/*
-		 * String beanName = MockAppletBean.class.getName(); BeanContext context =
-		 * new BeanContextSupport(); MockAppletInitializer appInit = new
-		 * MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
-		 * Beans.instantiate(null, beanName, context, appInit);
-		 * assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-		 * .getClassLoader()); assertEquals(beanName,
-		 * bean.getClass().getName()); assertTrue(context.contains(bean));
-		 * assertTrue(appInit.activateHasBeenCalled());
-		 * assertTrue(appInit.initializeHasBeenCalled());
-		 * assertTrue(bean.initHasBeenCalled());
-		 */
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_SER()
-			throws IOException, ClassNotFoundException {
-		/*
-		 * String beanName = MockAppletBean2.class.getName(); BeanContext
-		 * context = new BeanContextSupport(); MockAppletInitializer appInit =
-		 * new MockAppletInitializer(); MockAppletBean2 bean = (MockAppletBean2)
-		 * Beans.instantiate(null, beanName, context, appInit);
-		 * assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-		 * .getClassLoader()); assertEquals(beanName,
-		 * bean.getClass().getName()); assertTrue(context.contains(bean));
-		 * assertTrue(appInit.activateHasBeenCalled());
-		 * assertTrue(appInit.initializeHasBeenCalled());
-		 * assertFalse(bean.initHasBeenCalled());
-		 */
-	}
-
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_2()
-			throws IOException, ClassNotFoundException {
-		/*
-		 * String beanName = MockAppletBean.class.getName(); BeanContext context =
-		 * new BeanContextSupport(); MockAppletInitializer appInit = new
-		 * MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
-		 * Beans.instantiate(null, beanName, context, null);
-		 */
-	}
-
-	/*
-	 * public static boolean isInstanceOf(Object bean, Class targetType)
-	 */
-	public void testIsInstanceOf() {
-		MockJavaBean bean = new MockJavaBean();
-		assertTrue(Beans.isInstanceOf(bean, Serializable.class));
-	}
-
-	public void testIsInstanceOf_BeanNull() {
-		try {
-			boolean is = Beans.isInstanceOf(null, Serializable.class);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-		}
-	}
-
-	public void testIsInstanceOf_TypeNull() {
-		MockJavaBean bean = new MockJavaBean();
-		assertFalse(Beans.isInstanceOf(bean, null));
-	}
-
-	public void testIsInstanceOf_TypeInvalid() {
-		MockJavaBean bean = new MockJavaBean();
-		assertFalse(Beans.isInstanceOf(bean, String.class));
-	}
-
-	public void testSetDesignTime_true() {
-		Beans.setDesignTime(true);
-		assertTrue(Beans.isDesignTime());
-	}
-
-	public void testSetDesignTime_false() {
-		Beans.setDesignTime(false);
-		assertFalse(Beans.isDesignTime());
-	}
-
-	public void testSetGuiAvailable_true() {
-		Beans.setGuiAvailable(true);
-		assertTrue(Beans.isGuiAvailable());
-	}
-
-	public void testSetGuiAvailable_false() {
-		Beans.setGuiAvailable(false);
-		assertFalse(Beans.isGuiAvailable());
-	}
-
-	private void serialize(Object obj, File file) throws FileNotFoundException,
-			IOException {
-		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(
-				file));
-		oos.writeObject(obj);
-		oos.close();
-	}
-
-	private void copyFile(InputStream src, File dest) throws IOException {
-		FileOutputStream fos = new FileOutputStream(dest);
-		int length = 0;
-		byte[] bytes = new byte[1024];
-		while ((length = src.read(bytes)) != -1) {
-			fos.write(bytes, 0, length);
-		}
-		fos.close();
-		src.close();
-	}
-    
-    
-    /**
-     * The test checks the method instantiate()
-     * using specific classloader for class loading
-     */
-    public void testLoadBySpecificClassLoader() {
-        String beanName = "org.apache.harmony.beans.tests.java.beans.auxiliary.SampleBean";
-        
-        try {
-            ClassLoader cls = createSpecificClassLoader();
-            Object bean = Beans.instantiate(cls, beanName);
-            
-            assertNotNull(bean);
-            assertEquals(bean.getClass(), SampleBean.class);
-            
-            SampleBean sampleBean = (SampleBean) bean;
-            checkValues(sampleBean);
-        } catch (ClassNotFoundException cnfe) {
-            fail("Class with name " + beanName + " is not found");
-        } catch (IOException ioe) {
-            fail("IOException is thrown while loading " + beanName + " class");
-        }
-    }
-    
-    /**
-     * The test checks the method instantiate()
-     * using default classloader for class loading
-     */
-    public void testLoadByDefaultClassLoader() {
-        String beanName = "org.apache.harmony.beans.tests.java.beans.auxiliary.SampleBean";
-        
-        try {
-            Object bean = Beans.instantiate(null, beanName);
-            
-            assertNotNull(bean);
-            assertEquals(bean.getClass(), SampleBean.class);
-            
-            SampleBean sampleBean = (SampleBean) bean;
-            checkValues(sampleBean);
-        } catch (ClassNotFoundException cnfe) {
-            fail("Class with name " + beanName + " is not found");
-        } catch (IOException ioe) {
-            fail("IOException is thrown while loading " + beanName + " class");
-        }
-    }
-
-    //regression test for HARMONY-358
-    public void testInstantiate() throws Exception {
-        try {
-            Class.forName(this.getClass().getName(), true, null);
-            fail("This test is designed to run from classpath rather then from bootclasspath");
-        } catch (ClassNotFoundException ok) {
-        }
-        assertNotNull(Beans.instantiate(null, this.getClass().getName()));
-    } 
-
-    //regression test for HARMONY-402
-    public void test_isInstanceOf_Object_Class() {
-        ObjectBean bean = new ObjectBean();
-        // correct non-null targetType
-        Class targetType = Externalizable.class;
-        assertTrue(Beans.isInstanceOf(bean, targetType));
-
-        // null targetType
-        targetType = null;
-        assertFalse(Beans.isInstanceOf(bean, targetType));
-    } 
-    
-    /**
-     * 
-     */
-    public static Test suite() {
-        return new TestSuite(BeansTest.class);
-    }
-    
-    /**
-     * 
-     */
-    public static void main(String[] args) {
-        TestRunner.run(suite());
-    }
-    
-    private ClassLoader createSpecificClassLoader() {
-        return new ClassLoader() {
-            public Class loadClass(String name) throws ClassNotFoundException {
-                Class result = super.loadClass(name);
-                return result;
-            }
-        };        
-    }
-    
-    private void checkValues(SampleBean sampleBean) {
-        assertEquals(null, sampleBean.getText());
-    }
-
-    private class ObjectBean implements Externalizable { 
-        public void writeExternal(ObjectOutput out) {}; 
-        public void readExternal(ObjectInput in){}; 
-    } 
-}
+/* 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 org.apache.harmony.beans.tests.java.beans;
+
+import java.awt.Component;
+import java.beans.AppletInitializer;
+import java.beans.Beans;
+import java.beans.beancontext.BeanContext;
+import java.beans.beancontext.BeanContextSupport;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+import junit.framework.TestSuite;
+import org.apache.harmony.beans.tests.java.beans.mock.MockAppletInitializer;
+import org.apache.harmony.beans.tests.java.beans.auxiliary.SampleBean;
+
+/**
+ * Unit test for java.beans.Beans
+ */
+public class BeansTest extends TestCase {
+	private File fileURLCP = new File(System.getProperty("user.home"), "urlcp");
+
+	private File fileSer;
+
+	private File fileRes;
+
+	private File fileClass;
+
+	public BeansTest() {
+		File path = new File(fileURLCP, "serialization/java/beans/mock");
+		path.mkdirs();
+		fileSer = new File(path, "MockJavaBean2.ser");
+		fileClass = new File(path, "MockJavaBean2.class");
+	}
+
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		if (fileSer.exists()) {
+			fileSer.delete();
+		}
+
+		if (fileClass.exists()) {
+			fileClass.delete();
+		}
+		fileURLCP.delete();
+	}
+
+	/*
+	 * public Beans()
+	 */
+	public void testBeans() {
+		Beans beans = new Beans();
+	}
+
+	/*
+	 * public static Object getInstanceOf(Object bean, Class targetType)
+	 */
+	public void testGetInstanceOf() {
+		MockJavaBean bean = new MockJavaBean();
+		Class type = Component.class;
+		Object obj = Beans.getInstanceOf(bean, type);
+		assertSame(bean, obj);
+	}
+
+	public void testGetInstanceOf_BeanNull() {
+		Class type = Component.class;
+		Object obj = Beans.getInstanceOf(null, type);
+		assertNull(obj);
+	}
+
+	public void testGetInstanceOf_TargetTypeNull() {
+		MockJavaBean bean = new MockJavaBean();
+		Object obj = Beans.getInstanceOf(bean, null);
+		assertSame(bean, obj);
+	}
+
+	/*
+	 * Class under test for Object instantiate(ClassLoader, String)
+	 */
+	public void testInstantiateClassLoaderString_Class() throws IOException,
+			ClassNotFoundException, NoSuchMethodException, SecurityException,
+			IllegalAccessException, InvocationTargetException {
+		// copy class
+		InputStream bin = getClass().getResourceAsStream(
+				"/binary/java/beans/mock/MockJavaBean2.bin");
+		copyFile(bin, fileClass);
+
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		Object bean = Beans.instantiate(loader,
+				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2");
+		assertEquals("as_class", (String) bean.getClass().getMethod(
+				"getPropertyOne", (Class[])null).invoke(bean, null));
+		assertSame(loader, bean.getClass().getClassLoader());
+	}
+
+	public void testInstantiateClassLoaderString_Ser() throws IOException,
+			ClassNotFoundException, IllegalAccessException,
+			InvocationTargetException, NoSuchMethodException {
+		// copy class
+		InputStream bin = getClass().getResourceAsStream(
+				"/binary/java/beans/mock/MockJavaBean2.bin");
+		copyFile(bin, fileClass);
+
+		// copy ser
+		InputStream res = getClass().getResourceAsStream(
+				"/serialization/java/beans/mock/MockJavaBean2.ser");
+		copyFile(res, fileSer);
+
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		Object bean = Beans.instantiate(loader,
+				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2");
+		assertEquals("as_object", (String) bean.getClass().getMethod(
+				"getPropertyOne", (Class[])null).invoke(bean, null));
+		assertSame(loader, bean.getClass().getClassLoader());
+	}
+
+	public void testInstantiateClassLoaderString_ClassLoaderNull()
+			throws IOException, ClassNotFoundException {
+		Object bean = Beans.instantiate(null, MockJavaBean.class.getName());
+		assertEquals(bean.getClass(), MockJavaBean.class);
+		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+				.getClassLoader());
+	}
+
+	public void testInstantiateClassLoaderString_BeanNameNull()
+			throws IOException, ClassNotFoundException {
+		try {
+			Object bean = Beans.instantiate(null, null);
+			fail("Should throw NullPointerException");
+		} catch (NullPointerException e) {
+		}
+	}
+
+	/*
+	 * Class under test for Object instantiate(ClassLoader, String, BeanContext)
+	 */
+	public void testInstantiateClassLoaderStringBeanContext_Class()
+			throws ClassNotFoundException, ClassNotFoundException, IOException,
+			IllegalAccessException, InvocationTargetException,
+			NoSuchMethodException {
+		// copy class
+		InputStream bin = getClass().getResourceAsStream(
+				"/binary/java/beans/mock/MockJavaBean2.bin");
+		copyFile(bin, fileClass);
+
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		BeanContext context = new BeanContextSupport();
+		Object bean = Beans.instantiate(loader,
+				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2", context);
+		assertEquals("as_class", (String) bean.getClass().getMethod(
+				"getPropertyOne", (Class[])null).invoke(bean, null));
+		assertSame(loader, bean.getClass().getClassLoader());
+		assertTrue(context.contains(bean));
+	}
+
+	public void testInstantiateClassLoaderStringBeanContext_Ser()
+			throws IOException, ClassNotFoundException, IllegalAccessException,
+			InvocationTargetException, NoSuchMethodException {
+		// copy class
+		InputStream bin = getClass().getResourceAsStream(
+				"/binary/java/beans/mock/MockJavaBean2.bin");
+		copyFile(bin, fileClass);
+
+		// copy ser
+		InputStream res = getClass().getResourceAsStream(
+				"/serialization/java/beans/mock/MockJavaBean2.ser");
+		copyFile(res, fileSer);
+
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		BeanContext context = new BeanContextSupport();
+		Object bean = Beans.instantiate(loader,
+				"org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2", context);
+		assertEquals("as_object", (String) bean.getClass().getMethod(
+				"getPropertyOne", (Class[])null).invoke(bean, null));
+		assertSame(loader, bean.getClass().getClassLoader());
+		assertTrue(context.contains(bean));
+	}
+
+	public void testInstantiateClassLoaderStringBeanContext_ClassLoaderNull()
+			throws IOException, ClassNotFoundException {
+		BeanContext context = new BeanContextSupport();
+		Object bean = Beans.instantiate(null, MockJavaBean.class.getName(),
+				context);
+		assertEquals(bean.getClass(), MockJavaBean.class);
+		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+				.getClassLoader());
+		assertTrue(context.contains(bean));
+	}
+
+	public void testInstantiateClassLoaderStringBeanContext_BeanNameNull()
+			throws IOException, ClassNotFoundException {
+		BeanContext context = new BeanContextSupport();
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		try {
+			Object bean = Beans.instantiate(loader, null, context);
+			fail("Should throw NullPointerException.");
+		} catch (NullPointerException e) {
+		}
+	}
+
+	public void testInstantiateClassLoaderStringBeanContext_ContextNull()
+			throws IOException, ClassNotFoundException {
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		Object bean = Beans.instantiate(loader, MockJavaBean.class.getName(),
+				null);
+		assertEquals(bean.getClass(), MockJavaBean.class);
+	}
+
+	/*
+	 * Class under test for Object instantiate(ClassLoader, String, BeanContext,
+	 * AppletInitializer)
+	 */
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Class()
+			throws IOException, ClassNotFoundException, IllegalAccessException,
+			InvocationTargetException, NoSuchMethodException {
+		// copy class
+		InputStream bin = getClass().getResourceAsStream(
+				"/binary/java/beans/mock/MockJavaBean2.bin");
+		copyFile(bin, fileClass);
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		String beanName = "org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2";
+		BeanContext context = new BeanContextSupport();
+		AppletInitializer appInit = new MockAppletInitializer();
+		Object bean = Beans.instantiate(loader, beanName, context, appInit);
+
+		assertEquals("as_class", (String) bean.getClass().getMethod(
+				"getPropertyOne", (Class[])null).invoke(bean, null));
+		assertSame(loader, bean.getClass().getClassLoader());
+		assertTrue(context.contains(bean));
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_Ser()
+			throws ClassNotFoundException, IOException,
+			InvocationTargetException, NoSuchMethodException,
+			IllegalAccessException {
+		// copy class
+		InputStream bin = getClass().getResourceAsStream(
+				"/binary/java/beans/mock/MockJavaBean2.bin");
+		copyFile(bin, fileClass);
+
+		// copy ser
+		InputStream res = getClass().getResourceAsStream(
+				"/serialization/java/beans/mock/MockJavaBean2.ser");
+		copyFile(res, fileSer);
+
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		String beanName = "org.apache.harmony.beans.tests.java.beans.mock.MockJavaBean2";
+		BeanContext context = new BeanContextSupport();
+		AppletInitializer appInit = new MockAppletInitializer();
+		Object bean = Beans.instantiate(loader, beanName, context, appInit);
+
+		assertEquals("as_object", (String) bean.getClass().getMethod(
+				"getPropertyOne", (Class[])null).invoke(bean, null));
+		assertSame(loader, bean.getClass().getClassLoader());
+		assertTrue(context.contains(bean));
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_LoaderNull()
+			throws IOException, ClassNotFoundException {
+		String beanName = "org.apache.harmony.beans.tests.java.beans.MockJavaBean";
+		BeanContext context = new BeanContextSupport();
+		AppletInitializer appInit = new MockAppletInitializer();
+		Object bean = Beans.instantiate(null, beanName, context, appInit);
+		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+				.getClassLoader());
+		assertEquals(beanName, bean.getClass().getName());
+		assertTrue(context.contains(bean));
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_BeanNull()
+			throws IOException, ClassNotFoundException {
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		BeanContext context = new BeanContextSupport();
+		AppletInitializer appInit = new MockAppletInitializer();
+		try {
+			Object bean = Beans.instantiate(loader, null, context, appInit);
+			fail("Should throw NullPointerException.");
+		} catch (NullPointerException e) {
+		}
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_ContextNull()
+			throws IOException, ClassNotFoundException {
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		String beanName = "org.apache.harmony.beans.tests.java.beans.MockJavaBean";
+		AppletInitializer appInit = new MockAppletInitializer();
+		Object bean = Beans.instantiate(loader, beanName, null, appInit);
+		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+				.getClassLoader());
+		assertEquals(beanName, bean.getClass().getName());
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_InitializerNull()
+			throws IOException, ClassNotFoundException {
+		URLClassLoader loader = new URLClassLoader(new URL[] { fileURLCP
+				.toURL() });
+		String beanName = "org.apache.harmony.beans.tests.java.beans.MockJavaBean";
+		BeanContext context = new BeanContextSupport();
+		Object bean = Beans.instantiate(loader, beanName, context, null);
+		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+				.getClassLoader());
+		assertEquals(beanName, bean.getClass().getName());
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean()
+			throws IOException, ClassNotFoundException {
+		/*
+		 * String beanName = MockAppletBean.class.getName(); BeanContext context =
+		 * new BeanContextSupport(); MockAppletInitializer appInit = new
+		 * MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
+		 * Beans.instantiate(null, beanName, context, appInit);
+		 * assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+		 * .getClassLoader()); assertEquals(beanName,
+		 * bean.getClass().getName()); assertTrue(context.contains(bean));
+		 * assertTrue(appInit.activateHasBeenCalled());
+		 * assertTrue(appInit.initializeHasBeenCalled());
+		 * assertTrue(bean.initHasBeenCalled());
+		 */
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_SER()
+			throws IOException, ClassNotFoundException {
+		/*
+		 * String beanName = MockAppletBean2.class.getName(); BeanContext
+		 * context = new BeanContextSupport(); MockAppletInitializer appInit =
+		 * new MockAppletInitializer(); MockAppletBean2 bean = (MockAppletBean2)
+		 * Beans.instantiate(null, beanName, context, appInit);
+		 * assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+		 * .getClassLoader()); assertEquals(beanName,
+		 * bean.getClass().getName()); assertTrue(context.contains(bean));
+		 * assertTrue(appInit.activateHasBeenCalled());
+		 * assertTrue(appInit.initializeHasBeenCalled());
+		 * assertFalse(bean.initHasBeenCalled());
+		 */
+	}
+
+	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_AppletBean_2()
+			throws IOException, ClassNotFoundException {
+		/*
+		 * String beanName = MockAppletBean.class.getName(); BeanContext context =
+		 * new BeanContextSupport(); MockAppletInitializer appInit = new
+		 * MockAppletInitializer(); MockAppletBean bean = (MockAppletBean)
+		 * Beans.instantiate(null, beanName, context, null);
+		 */
+	}
+
+	/*
+	 * public static boolean isInstanceOf(Object bean, Class targetType)
+	 */
+	public void testIsInstanceOf() {
+		MockJavaBean bean = new MockJavaBean();
+		assertTrue(Beans.isInstanceOf(bean, Serializable.class));
+	}
+
+	public void testIsInstanceOf_BeanNull() {
+		try {
+			boolean is = Beans.isInstanceOf(null, Serializable.class);
+			fail("Should throw NullPointerException.");
+		} catch (NullPointerException e) {
+		}
+	}
+
+	public void testIsInstanceOf_TypeNull() {
+		MockJavaBean bean = new MockJavaBean();
+		assertFalse(Beans.isInstanceOf(bean, null));
+	}
+
+	public void testIsInstanceOf_TypeInvalid() {
+		MockJavaBean bean = new MockJavaBean();
+		assertFalse(Beans.isInstanceOf(bean, String.class));
+	}
+
+	public void testSetDesignTime_true() {
+		Beans.setDesignTime(true);
+		assertTrue(Beans.isDesignTime());
+	}
+
+	public void testSetDesignTime_false() {
+		Beans.setDesignTime(false);
+		assertFalse(Beans.isDesignTime());
+	}
+
+	public void testSetGuiAvailable_true() {
+		Beans.setGuiAvailable(true);
+		assertTrue(Beans.isGuiAvailable());
+	}
+
+	public void testSetGuiAvailable_false() {
+		Beans.setGuiAvailable(false);
+		assertFalse(Beans.isGuiAvailable());
+	}
+
+	private void serialize(Object obj, File file) throws FileNotFoundException,
+			IOException {
+		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(
+				file));
+		oos.writeObject(obj);
+		oos.close();
+	}
+
+	private void copyFile(InputStream src, File dest) throws IOException {
+		FileOutputStream fos = new FileOutputStream(dest);
+		int length = 0;
+		byte[] bytes = new byte[1024];
+		while ((length = src.read(bytes)) != -1) {
+			fos.write(bytes, 0, length);
+		}
+		fos.close();
+		src.close();
+	}
+    
+    
+    /**
+     * The test checks the method instantiate()
+     * using specific classloader for class loading
+     */
+    public void testLoadBySpecificClassLoader() {
+        String beanName = "org.apache.harmony.beans.tests.java.beans.auxiliary.SampleBean";
+        
+        try {
+            ClassLoader cls = createSpecificClassLoader();
+            Object bean = Beans.instantiate(cls, beanName);
+            
+            assertNotNull(bean);
+            assertEquals(bean.getClass(), SampleBean.class);
+            
+            SampleBean sampleBean = (SampleBean) bean;
+            checkValues(sampleBean);
+        } catch (ClassNotFoundException cnfe) {
+            fail("Class with name " + beanName + " is not found");
+        } catch (IOException ioe) {
+            fail("IOException is thrown while loading " + beanName + " class");
+        }
+    }
+    
+    /**
+     * The test checks the method instantiate()
+     * using default classloader for class loading
+     */
+    public void testLoadByDefaultClassLoader() {
+        String beanName = "org.apache.harmony.beans.tests.java.beans.auxiliary.SampleBean";
+        
+        try {
+            Object bean = Beans.instantiate(null, beanName);
+            
+            assertNotNull(bean);
+            assertEquals(bean.getClass(), SampleBean.class);
+            
+            SampleBean sampleBean = (SampleBean) bean;
+            checkValues(sampleBean);
+        } catch (ClassNotFoundException cnfe) {
+            fail("Class with name " + beanName + " is not found");
+        } catch (IOException ioe) {
+            fail("IOException is thrown while loading " + beanName + " class");
+        }
+    }
+
+    //regression test for HARMONY-358
+    public void testInstantiate() throws Exception {
+        try {
+            Class.forName(this.getClass().getName(), true, null);
+            fail("This test is designed to run from classpath rather then from bootclasspath");
+        } catch (ClassNotFoundException ok) {
+        }
+        assertNotNull(Beans.instantiate(null, this.getClass().getName()));
+    } 
+
+    //regression test for HARMONY-402
+    public void test_isInstanceOf_Object_Class() {
+        ObjectBean bean = new ObjectBean();
+        // correct non-null targetType
+        Class targetType = Externalizable.class;
+        assertTrue(Beans.isInstanceOf(bean, targetType));
+
+        // null targetType
+        targetType = null;
+        assertFalse(Beans.isInstanceOf(bean, targetType));
+    } 
+    
+    /**
+     * 
+     */
+    public static Test suite() {
+        return new TestSuite(BeansTest.class);
+    }
+    
+    /**
+     * 
+     */
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+    
+    private ClassLoader createSpecificClassLoader() {
+        return new ClassLoader() {
+            public Class loadClass(String name) throws ClassNotFoundException {
+                Class result = super.loadClass(name);
+                return result;
+            }
+        };        
+    }
+    
+    private void checkValues(SampleBean sampleBean) {
+        assertEquals(null, sampleBean.getText());
+    }
+
+    private class ObjectBean implements Externalizable { 
+        public void writeExternal(ObjectOutput out) {}; 
+        public void readExternal(ObjectInput in){}; 
+    } 
+}



Mime
View raw message