harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r421208 - /incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java
Date Wed, 12 Jul 2006 09:46:39 GMT
Author: mloenko
Date: Wed Jul 12 02:46:39 2006
New Revision: 421208

URL: http://svn.apache.org/viewvc?rev=421208&view=rev
Log:
more clean-up

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeansTest.java

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=421208&r1=421207&r2=421208&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 Jul 12 02:46:39 2006
@@ -43,291 +43,304 @@
 public class BeansTest extends TestCase {
 
     private final String MOCK_JAVA_BEAN2 = "tests.api.java.beans.mock.MockJavaBean2";
+
     private final String MOCK_JAVA_BEAN2_FILE = "/binary/java/beans/mock/MockJavaBean2.bin";
+
     private final String MOCK_JAVA_BEAN2_SFILE = "/serialization/java/beans/mock/MockJavaBean2.ser";
 
-	/*
-	 * public Beans()
-	 */
-	public void testBeans() {
-		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 Exception {
-
-		ClassLoader loader = new BinClassLoader();
-		Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2);
-
-		assertEquals("as_class", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-	}
+    /*
+     * public Beans()
+     */
+    public void testBeans() {
+        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 Exception {
+
+        ClassLoader loader = new BinClassLoader();
+        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2);
+
+        assertEquals("as_class", (String) bean.getClass().getMethod(
+                "getPropertyOne", (Class[]) null).invoke(bean, null));
+        assertSame(loader, bean.getClass().getClassLoader());
+    }
 
-	public void testInstantiateClassLoaderString_Ser() throws Exception {
+    public void testInstantiateClassLoaderString_Ser() throws Exception {
         ClassLoader loader = new SerClassLoader();
-		Object bean = Beans.instantiate(loader,MOCK_JAVA_BEAN2);
+        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2);
 
         assertEquals("as_object", (String) bean.getClass().getMethod(
-				"getPropertyOne", (Class[])null).invoke(bean, null));
-		assertSame(loader, bean.getClass().getClassLoader());
-	}
-
-	public void testInstantiateClassLoaderString_ClassLoaderNull() throws Exception {
-		Object bean = Beans.instantiate(null, MockJavaBean.class.getName());
-		assertEquals(bean.getClass(), MockJavaBean.class);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-	}
-
-	public void testInstantiateClassLoaderString_BeanNameNull() throws Exception {
-		try {
-			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 Exception {
-
-        ClassLoader loader = new BinClassLoader ();
-		BeanContext context = new BeanContextSupport();
-		Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);
+                "getPropertyOne", (Class[]) null).invoke(bean, null));
+        assertSame(loader, bean.getClass().getClassLoader());
+    }
+
+    public void testInstantiateClassLoaderString_ClassLoaderNull()
+            throws Exception {
+        Object bean = Beans.instantiate(null, MockJavaBean.class.getName());
+        assertEquals(bean.getClass(), MockJavaBean.class);
+        assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+                .getClassLoader());
+    }
+
+    public void testInstantiateClassLoaderString_BeanNameNull()
+            throws Exception {
+        try {
+            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 Exception {
+
+        ClassLoader loader = new BinClassLoader();
+        BeanContext context = new BeanContextSupport();
+        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, 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 Exception {
-		ClassLoader loader = new SerClassLoader();
-		BeanContext context = new BeanContextSupport();
-		Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, 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 Exception
{
-		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 Exception
{
-		BeanContext context = new BeanContextSupport();
-		ClassLoader loader = createSpecificClassLoader();
-		try {
-			Beans.instantiate(loader, null, context);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-		}
-	}
+                "getPropertyOne", (Class[]) null).invoke(bean, null));
+        assertSame(loader, bean.getClass().getClassLoader());
+        assertTrue(context.contains(bean));
+    }
+
+    public void testInstantiateClassLoaderStringBeanContext_Ser()
+            throws Exception {
+        ClassLoader loader = new SerClassLoader();
+        BeanContext context = new BeanContextSupport();
+        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);
 
-	public void testInstantiateClassLoaderStringBeanContext_ContextNull() throws Exception {
+        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 Exception {
+        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 Exception {
+        BeanContext context = new BeanContextSupport();
+        ClassLoader loader = createSpecificClassLoader();
+        try {
+            Beans.instantiate(loader, null, context);
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {}
+    }
+
+    public void testInstantiateClassLoaderStringBeanContext_ContextNull()
+            throws Exception {
         ClassLoader loader = createSpecificClassLoader();
-		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
Exception {
-		ClassLoader loader = new BinClassLoader();
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, 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 Exception
{
-
-		ClassLoader loader = new SerClassLoader();
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, 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
Exception {
-		String beanName = "org.apache.harmony.beans.tests.support.mock.MockJavaBean";
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
+        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 Exception {
+        ClassLoader loader = new BinClassLoader();
+        BeanContext context = new BeanContextSupport();
+        AppletInitializer appInit = new MockAppletInitializer();
+        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, 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 Exception {
+
+        ClassLoader loader = new SerClassLoader();
+        BeanContext context = new BeanContextSupport();
+        AppletInitializer appInit = new MockAppletInitializer();
+        Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, 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 Exception {
+        String beanName = "org.apache.harmony.beans.tests.support.mock.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));
-	}
+        assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
+                .getClassLoader());
+        assertEquals(beanName, bean.getClass().getName());
+        assertTrue(context.contains(bean));
+    }
 
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_BeanNull() throws
Exception {
+    public void testInstantiateClassLoaderStringBeanContextAppletInitializer_BeanNull()
+            throws Exception {
         ClassLoader loader = createSpecificClassLoader();
-		BeanContext context = new BeanContextSupport();
-		AppletInitializer appInit = new MockAppletInitializer();
-		try {
-			Beans.instantiate(loader, null, context, appInit);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-		}
-	}
+        BeanContext context = new BeanContextSupport();
+        AppletInitializer appInit = new MockAppletInitializer();
+        try {
+            Beans.instantiate(loader, null, context, appInit);
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {}
+    }
 
-	public void testInstantiateClassLoaderStringBeanContextAppletInitializer_ContextNull() throws
Exception {
+    public void testInstantiateClassLoaderStringBeanContextAppletInitializer_ContextNull()
+            throws Exception {
         ClassLoader loader = createSpecificClassLoader();
-		String beanName = "org.apache.harmony.beans.tests.support.mock.MockJavaBean";
-		AppletInitializer appInit = new MockAppletInitializer();
-		Object bean = Beans.instantiate(loader, beanName, null, appInit);
-		assertSame(ClassLoader.getSystemClassLoader(), bean.getClass()
-				.getClassLoader());
-		assertEquals(beanName, bean.getClass().getName());
-	}
+        String beanName = "org.apache.harmony.beans.tests.support.mock.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 Exception {
+    public void testInstantiateClassLoaderStringBeanContextAppletInitializer_InitializerNull()
+            throws Exception {
         ClassLoader loader = createSpecificClassLoader();
-		String beanName = "org.apache.harmony.beans.tests.support.mock.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 {
-			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());
-	}
+        String beanName = "org.apache.harmony.beans.tests.support.mock.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 {
+            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());
+    }
 
     /**
-     * The test checks the method instantiate()
-     * using specific classloader for class loading
+     * The test checks the method instantiate() using specific classloader for
+     * class loading
      */
     public void testLoadBySpecificClassLoader() throws Exception {
         String beanName = "org.apache.harmony.beans.tests.support.SampleBean";
@@ -339,42 +352,35 @@
         assertEquals(bean.getClass(), SampleBean.class);
 
         SampleBean sampleBean = (SampleBean) bean;
-        checkValues(sampleBean);
+        assertNull(sampleBean.getText());
     }
-    
+
     /**
      * The test checks the method instantiate() using default classloader for
      * class loading
      */
-    public void testLoadByDefaultClassLoader() {
+    public void testLoadByDefaultClassLoader() throws Exception {
         String beanName = "org.apache.harmony.beans.tests.support.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");
-        }
+
+        Object bean = Beans.instantiate(null, beanName);
+
+        assertNotNull(bean);
+        assertEquals(bean.getClass(), SampleBean.class);
+
+        SampleBean sampleBean = (SampleBean) bean;
+        assertNull(sampleBean.getText());
     }
 
-    //regression test for HARMONY-358
+    // 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) {
-        }
+        } catch (ClassNotFoundException ok) {}
         assertNotNull(Beans.instantiate(null, this.getClass().getName()));
-    } 
+    }
 
-    //regression test for HARMONY-402
+    // regression test for HARMONY-402
     public void test_isInstanceOf_Object_Class() {
         ObjectBean bean = new ObjectBean();
         // correct non-null targetType
@@ -384,34 +390,32 @@
         // 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() {};
     }
-    
-    private void checkValues(SampleBean sampleBean) {
-        assertEquals(null, sampleBean.getText());
-    }
 
-    private class ObjectBean implements Externalizable { 
-        public void writeExternal(ObjectOutput out) {}; 
-        public void readExternal(ObjectInput in){}; 
-    } 
+    private class ObjectBean implements Externalizable {
+
+        public void writeExternal(ObjectOutput out) {};
+
+        public void readExternal(ObjectInput in) {};
+    }
 
     private class BinClassLoader extends ClassLoader {
 
@@ -424,7 +428,8 @@
                 // makes sense to get actual file size?
                 byte[] buf = new byte[10000];
 
-                InputStream in = getClass().getResourceAsStream(MOCK_JAVA_BEAN2_FILE);
+                InputStream in = getClass().getResourceAsStream(
+                        MOCK_JAVA_BEAN2_FILE);
 
                 int sz = 0;
 
@@ -443,11 +448,14 @@
     }
 
     private class SerClassLoader extends BinClassLoader {
-        private final String MOCK_JAVA_BEAN2_SNAME = MOCK_JAVA_BEAN2.replace('.', '/') +
".ser";;
 
-        protected URL findResource(String name)  {
+        private final String MOCK_JAVA_BEAN2_SNAME = MOCK_JAVA_BEAN2.replace(
+                '.', '/')
+                + ".ser";;
+
+        protected URL findResource(String name) {
             if (MOCK_JAVA_BEAN2_SNAME.equals(name)) {
-                name = MOCK_JAVA_BEAN2_SFILE; 
+                name = MOCK_JAVA_BEAN2_SFILE;
             }
             return super.getResource(name);
         }



Mime
View raw message