harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r474941 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ main/java/org/apache/harmony/beans/internal/nls/ test/java/org/apache/harmony/beans/tests/java/beans/ test/support/java/org/apache/harmony/bean...
Date Tue, 14 Nov 2006 19:51:50 GMT
Author: ayza
Date: Tue Nov 14 11:51:50 2006
New Revision: 474941

URL: http://svn.apache.org/viewvc?view=rev&rev=474941
Log:
enabling seven tests from IntrospectorTest class

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockPropertyChangeListener.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java?view=diff&rev=474941&r1=474940&r2=474941
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
Tue Nov 14 11:51:50 2006
@@ -23,6 +23,9 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.harmony.beans.internal.nls.Messages;
+
+
 public class Introspector {
 
     public static final int USE_ALL_BEANINFO = 1;
@@ -106,12 +109,23 @@
 
     private static BeanInfoWrapper getBeanInfo(Class<?> beanClass,
             Class<?> stopClass, boolean ignoreBeanClassBeanInfo,
-            boolean ignoreSuperClassBeanInfo) {
+            boolean ignoreSuperClassBeanInfo) throws IntrospectionException {
+        BeanInfoWrapper beanInfoWrapper;
+        BeanInfo beanInfo;
+        BeanInfoImpl beanInfoImpl;
+        BeanInfoWrapper wrapper;
+        Class<?> parent;
+        
         if (beanClass == null) {
             throw new java.lang.NullPointerException();
         }
+        
+        if (stopClass != null && !stopClass.isAssignableFrom(beanClass)) {
+            throw new IntrospectionException(
+                    Messages.getString("beans.4E")); //$NON-NLS-1$
+        }
 
-        BeanInfoWrapper beanInfoWrapper = findBeanInfoClassInCache(beanClass,
+        beanInfoWrapper = findBeanInfoClassInCache(beanClass,
                 stopClass, ignoreBeanClassBeanInfo, ignoreSuperClassBeanInfo);
 
         if (beanInfoWrapper != null) {
@@ -120,10 +134,12 @@
 
         // find bean info as a separate class
 
-        BeanInfo beanInfo = null;
+        beanInfo = null;
+
         if (!ignoreBeanClassBeanInfo) {
             try {
                 Class<?> beanInfoClass = findBeanInfoClass(beanClass);
+
                 if (beanInfoClass != null) {
                     beanInfo = (BeanInfo) beanInfoClass.newInstance();
                 }
@@ -135,14 +151,15 @@
 
         // generate bean info automatically
 
-        BeanInfoImpl beanInfoImpl = new BeanInfoImpl(beanClass);
+        beanInfoImpl = new BeanInfoImpl(beanClass);
 
         // ...
 
-        BeanInfoWrapper wrapper = new BeanInfoWrapper(beanInfo, beanInfoImpl);
+        wrapper = new BeanInfoWrapper(beanInfo, beanInfoImpl);
 
-        Class<?> parent = beanClass.getSuperclass();
-        if ((parent != null) && (parent != stopClass)) {
+        parent = beanClass.getSuperclass();
+        
+        if (parent != null && parent != stopClass) {
             BeanInfoWrapper parentBeanInfo = getBeanInfo(parent, stopClass,
                     ignoreSuperClassBeanInfo, ignoreSuperClassBeanInfo);
 
@@ -233,6 +250,7 @@
 
     private static String[] path = { "org.apache.harmony.beans.infos" }; //$NON-NLS-1$
 
-    private static final Map<String, List<BeanInfoData>> beanInfos = new HashMap<String,
List<BeanInfoData>>();
+    private static final Map<String, List<BeanInfoData>> beanInfos =
+            new HashMap<String, List<BeanInfoData>>();
 
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties?view=diff&rev=474941&r1=474940&r2=474941
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
Tue Nov 14 11:51:50 2006
@@ -93,3 +93,4 @@
 beans.4B=type is null
 beans.4C=encoder is null
 beans.4D=Invalid method call
+beans.4E=stopClass is not ancestor of beanClass

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java?view=diff&rev=474941&r1=474940&r2=474941
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Tue Nov 14 11:51:50 2006
@@ -417,9 +417,10 @@
         BeanInfo info = Introspector.getBeanInfo(MockFoo.class,
                 MockFooStop.class);
         PropertyDescriptor[] pds = info.getPropertyDescriptors();
-        assertEquals(1, pds.length);
-        assertEquals("name", pds[0].getName());
-        assertEquals(String.class, pds[0].getPropertyType());
+
+        assertEquals(2, pds.length);
+        assertTrue(contains("name", String.class, pds));
+        assertTrue(contains("complexLabel", MockFooLabel.class, pds));
     }
 
     public void testGetBeanInfoClassClass_Method()
@@ -427,11 +428,12 @@
         BeanInfo info = Introspector.getBeanInfo(MockFoo.class,
                 MockFooStop.class);
         MethodDescriptor[] mds = info.getMethodDescriptors();
-        assertEquals(2, mds.length);
-
-        for (MethodDescriptor element : mds) {
-            assertTrue(element.getName().endsWith("Name"));
-        }
+        
+        assertEquals(4, mds.length);
+        assertTrue(contains("getName", mds));
+        assertTrue(contains("setName", mds));
+        assertTrue(contains("getComplexLabel", mds));
+        assertTrue(contains("setComplexLabel", mds));
     }
 
     public void testGetBeanInfoClassClass_StopNull()
@@ -581,11 +583,10 @@
         BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
                 Introspector.IGNORE_IMMEDIATE_BEANINFO);
         EventSetDescriptor[] esds = info.getEventSetDescriptors();
-        assertEquals(1, esds.length);
-        for (EventSetDescriptor element : esds) {
-            String name = element.getName();
-            assertEquals("mockPropertyChange.MockFooChildBeanInfo", name);
-        }
+
+        assertEquals(2, esds.length);
+        assertTrue(contains("mockPropertyChange", esds));
+        assertTrue(contains("mockPropertyChange.MockFooChildBeanInfo", esds));
     }
 
     /*
@@ -641,7 +642,9 @@
         BeanInfo info = Introspector.getBeanInfo(MockFooSub.class,
                 Introspector.IGNORE_ALL_BEANINFO);
         EventSetDescriptor[] esds = info.getEventSetDescriptors();
-        assertEquals(0, esds.length);
+
+        assertEquals(1, esds.length);
+        assertTrue(contains("mockPropertyChange", esds));
     }
 
     /*
@@ -1451,7 +1454,7 @@
         }
     }
 
-    private void assertBeanInfoEquals(BeanInfo beanInfo, BeanInfo info) {
+    private static void assertBeanInfoEquals(BeanInfo beanInfo, BeanInfo info) {
         // compare BeanDescriptor
         assertEquals(beanInfo.getBeanDescriptor().getDisplayName(), info
                 .getBeanDescriptor().getDisplayName());
@@ -1501,6 +1504,43 @@
 
     }
 
+    private static boolean contains(String propName, Class<?> propClass,
+            PropertyDescriptor[] pds)
+    {
+        for (PropertyDescriptor pd : pds) {
+            if (propName.equals(pd.getName()) &&
+                    propClass.equals(pd.getPropertyType())) {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    private static boolean contains(String methodName,
+            MethodDescriptor[] mds)
+    {
+        for (MethodDescriptor md : mds) {
+            if (methodName.equals(md.getName())) {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+
+    private static boolean contains(String methodName,
+            EventSetDescriptor[] esds)
+    {
+        for (EventSetDescriptor esd : esds) {
+            if (methodName.equals(esd.getName())) {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
     /*
      * The following classes are used to test introspect properties
      */

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockPropertyChangeListener.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockPropertyChangeListener.java?view=diff&rev=474941&r1=474940&r2=474941
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockPropertyChangeListener.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockPropertyChangeListener.java
Tue Nov 14 11:51:50 2006
@@ -17,10 +17,12 @@
 
 package org.apache.harmony.beans.tests.support.mock;
 
+import java.util.EventListener;
+
 /**
  * TODO Type description
  */
-public interface MockPropertyChangeListener {
+public interface MockPropertyChangeListener extends EventListener {
     /*
      * fire MockPropertyChange event.
      */



Mime
View raw message