harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r421166 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/Statement.java test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
Date Wed, 12 Jul 2006 06:34:23 GMT
Author: mloenko
Date: Tue Jul 11 23:34:23 2006
New Revision: 421166

URL: http://svn.apache.org/viewvc?rev=421166&view=rev
Log:
fixes for HARMONY-840
[classlib][beans] enabling of tests from StatementTest class (3)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java?rev=421166&r1=421165&r2=421166&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Statement.java
Tue Jul 11 23:34:23 2006
@@ -184,25 +184,29 @@
     }
 
     private Method findArrayMethod() throws NoSuchMethodException {
+        // the code below reproduces exact RI exception throwing behavior 
         if (!methodName.equals("set") && !methodName.equals("get")) {
             throw new NoSuchMethodException("Unknown method name for array");
+        } else if (arguments.length > 0 &&
+                   arguments[0].getClass() != Integer.class) {
+            throw new ClassCastException(
+                    "First parameter in array getter(setter) is not of "
+                            + "Integer type");
         } else if (methodName.equals("get") && (arguments.length != 1)) {
-            throw new NoSuchMethodException(
+            throw new ArrayIndexOutOfBoundsException(
                     "Illegal number of arguments in array getter");
         } else if (methodName.equals("set") && (arguments.length != 2)) {
-            throw new NoSuchMethodException(
+            throw new ArrayIndexOutOfBoundsException(
                     "Illegal number of arguments in array setter");
-        } else if (arguments[0].getClass() != Integer.class) {
-            throw new NoSuchMethodException(
-                    "First parameter in array getter(setter) is not of "
-                            + "Integer type");
-        }
-
-        Class[] argClasses = methodName.equals("get") ? new Class[] {
-                Object.class, int.class } : new Class[] { Object.class,
-                int.class, Object.class };
+        } 
 
-        return Array.class.getMethod(methodName, argClasses);
+        if (methodName.equals("get")) {
+            return Array.class.getMethod("get",
+                    new Class[] { Object.class, int.class } );
+        } else {
+            return Array.class.getMethod("set",
+                    new Class[] { Object.class, int.class, Object.class } );
+        }
     }
 
     private Object[] getArrayMethodArguments() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java?rev=421166&r1=421165&r2=421166&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
Tue Jul 11 23:34:23 2006
@@ -612,7 +612,7 @@
     public void testExecute_ArrayGet() throws Exception {
         Object[] array = new Object[] { "test" };
         Statement t = new Statement(array, "get", new Object[] {
-                new Integer(0), new Object() });
+                new Integer(0)});
         t.execute();
 
         array = new Object[] { "test" };
@@ -660,7 +660,7 @@
     public void testExecute_ArrayInvalidSet() throws Exception {
         Object[] array = new Object[] { "test" };
         Statement t = new Statement(array, "set", new Object[] {
-                new Integer(0), "test2", new Object() });
+                new Integer(0), "test2"});
         t.execute();
         assertEquals("test2", array[0]);
 



Mime
View raw message