harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r465154 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ test/java/org/apache/harmony/beans/tests/java/beans/ test/support/java/org/apache/harmony/beans/tests/support/
Date Wed, 18 Oct 2006 06:15:36 GMT
Author: mloenko
Date: Tue Oct 17 23:15:34 2006
New Revision: 465154

URL: http://svn.apache.org/viewvc?view=rev&rev=465154
Log:
applied patch from HARMONY-1504
[classlib][beans] RI throws NPE for public EventSetDescriptor(...) while Harmony does not

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java?view=diff&rev=465154&r1=465153&r2=465154
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
Tue Oct 17 23:15:34 2006
@@ -92,15 +92,18 @@
 
         this.listenerType = listenerType;
 
-        if (listenerMethodNames != null) {
-            for (String element : listenerMethodNames) {
-                try {
-                    listenerMethodDescriptors.add(new MethodDescriptor(
-                            findMethodByName(listenerType, element)));
-                } catch (IntrospectionException ie) {
-                    listenerMethodDescriptors.clear();
-                    throw ie;
-                }
+        if (listenerMethodNames == null) {
+            throw new NullPointerException();
+        }
+
+        for (String element : listenerMethodNames) {
+            try {
+                listenerMethodDescriptors
+                        .add(new MethodDescriptor(findMethodByName(
+                                listenerType, element)));
+            } catch (IntrospectionException ie) {
+                listenerMethodDescriptors.clear();
+                throw ie;
             }
         }
 
@@ -127,15 +130,16 @@
 
         this.listenerType = listenerType;
 
-        if (listenerMethodNames != null) {
-            for (String element : listenerMethodNames) {
-                try {
-                    listenerMethodDescriptors.add(new MethodDescriptor(
-                            findMethodByName(listenerType, element)));
-                } catch (IntrospectionException ie) {
-                    listenerMethodDescriptors.clear();
-                    throw ie;
-                }
+        if (listenerMethodNames == null) {
+            throw new NullPointerException();
+        }
+        for (String element : listenerMethodNames) {
+            try {
+                listenerMethodDescriptors.add(new MethodDescriptor(
+                        findMethodByName(listenerType, element)));
+            } catch (IntrospectionException ie) {
+                listenerMethodDescriptors.clear();
+                throw ie;
             }
         }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java?view=diff&rev=465154&r1=465153&r2=465154
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EventSetDescriptorTest.java
Tue Oct 17 23:15:34 2006
@@ -38,20 +38,6 @@
 public class EventSetDescriptorTest 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 EventSetDescriptor(Class, String, Class,
      * String)
      */
@@ -143,12 +129,9 @@
         String listenerMethodName = eventSetName;
         Class sourceClass = MockSourceClass.class;
         Class listenerType = MockPropertyChangeListener.class;
-        try {
-            new EventSetDescriptor(sourceClass, "", listenerType,
-                    listenerMethodName);
-            fail("Should throw StringIndexOutOfBoundsException.");
-        } catch (StringIndexOutOfBoundsException e) {
-        }
+
+        new EventSetDescriptor(sourceClass, "", listenerType,
+                listenerMethodName);
     }
 
     /*
@@ -342,7 +325,7 @@
     public void testEventSetDescriptorClassStringClassStringArrayStringString_eventNull()
             throws IntrospectionException {
         Class sourceClass = MockSourceClass.class;
-        String eventSetName = null;
+		String eventSetName = "MockPropertyChange";
         Class listenerType = MockPropertyChangeListener.class;
         String[] listenerMethodNames = { "mockPropertyChange",
                 "mockPropertyChange2", };
@@ -369,6 +352,16 @@
         assertEquals(listenerType, esd.getListenerType());
         assertTrue(esd.isInDefaultEventSet());
         assertFalse(esd.isUnicast());
+        //Regression for HARMONY-1504
+		try {
+			new EventSetDescriptor(sourceClass,
+				null, listenerType, listenerMethodNames, addMethod,
+				removeMethod);
+			fail("NullPointerException expected");
+		} catch (NullPointerException e) {
+			//expected
+		}
+
     }
 
     /*
@@ -581,7 +574,7 @@
 
         assertEquals(addMethod, esd.getAddListenerMethod().getName());
         assertEquals(removeMethod, esd.getRemoveListenerMethod().getName());
-        assertEquals(getMethod, esd.getGetListenerMethod().getName());
+		assertNull(esd.getGetListenerMethod());
 
         assertEquals(2, esd.getListenerMethods().length);
         assertEquals(listenerMethodNames[0], esd.getListenerMethods()[0]
@@ -625,6 +618,16 @@
                 eventSetName, listenerType, listenerMethodNames, addMethod,
                 removeMethod, getMethod);
         assertNull(esd.getGetListenerMethod());
+		
+		//Regression for Harmony-1504
+        try {
+            new EventSetDescriptor(sourceClass,
+                    eventSetName, listenerType, null, addMethod,
+                    removeMethod, getMethod);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+            //expected
+        }
     }
 
     /*
@@ -643,7 +646,7 @@
         EventSetDescriptor esd = new EventSetDescriptor(sourceClass,
                 eventSetName, listenerType, listenerMethodNames, addMethod,
                 removeMethod, getMethod);
-        assertEquals(addMethod, esd.getGetListenerMethod().getName());
+		assertNull(esd.getGetListenerMethod());
     }
 
     /*

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java?view=diff&rev=465154&r1=465153&r2=465154
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/OtherBean.java
Tue Oct 17 23:15:34 2006
@@ -28,7 +28,7 @@
 
 public class OtherBean {
 
-    public void addSaampleListener(SampleListener listener) {
+    public void addSampleListener(SampleListener listener) {
     }
 
     public void removeSampleListener(SampleListener listener) {



Mime
View raw message