Index: test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java =================================================================== --- test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java (revision 424393) +++ test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java (working copy) @@ -354,6 +354,19 @@ } /* + * Test the method execute() with a normal object, normal method and + * null arguments. + */ + public void testExecute_NormalInstanceMethodNull() throws Exception { + MockObject mo = new MockObject(false); + Object[] arguments = new Object[] { null, null, null }; + Statement t = new Statement(mo, "method", arguments); + + t.execute(); + MockObject.assertCalled("method5", arguments); + } + + /* * Test the method execute() with a normal object, a valid method that * throws an exception and valid arguments. */ @@ -434,9 +447,9 @@ */ public void testExecute_OverloadedMethods() throws Exception { MockObject mo = new MockObject(false); - Object[] arguments; + Object[] arguments; Statement t; - + arguments = new Object[] { new Object() }; t = new Statement(mo, "method", arguments); t.execute(); @@ -446,7 +459,7 @@ t = new Statement(mo, "method", arguments); t.execute(); MockObject.assertCalled("method3", arguments); - + arguments = new Object[] { new Integer(117) }; t = new Statement(mo, "method", arguments); t.execute(); @@ -454,18 +467,6 @@ } /* - * Test the method execute() with a normal object, an overloaded method and - * null arguments. See Java Language Specification (15.11) for reference. - */ - public void testExecute_OverloadedMethodsNull() throws Exception { - MockObject mo = new MockObject(false); - Object[] arguments = new Object[] { null }; - Statement t = new Statement(mo, "method", arguments); - t.execute(); - MockObject.assertCalled("method1-2", arguments); - } - - /* * Test the method execute() with a normal object, the method name "new" and * valid arguments. */ @@ -479,6 +480,23 @@ } /* + * Test the method execute() with a normal object, normal + * constructor ("new" method) and null arguments. + */ + public void testExecute_NormalConstructorNull() throws Exception { + Object[] arguments = new Object[] { null, null }; + Statement t = new Statement(MockObject.class, "new", arguments); + + try { + t.execute(); + fail("Should throw NullPointerException!"); + } catch (NullPointerException ex) { + // expected + } + MockObject.assertCalled("new4", arguments); + } + + /* * Test the method execute() with a normal object, the method name "new" * that throws an exception and valid arguments. */ @@ -500,7 +518,8 @@ */ public void testExecute_NonExistingConstructor() throws Exception { Statement t = new Statement(MockObject.class, "new", new Object[] { - null, null, null }); + null, null, null, null }); + try { t.execute(); fail("Should throw NoSuchMethodException!"); @@ -522,7 +541,8 @@ arguments = new Object[] { "test" }; t = new Statement(MockObject.class, "new", arguments); t.execute(); - // MockObject.assertCalled("new2", arguments); + // XXX RI calls new2 here, not the most specific constructor. Bug in RI? + // MockObject.assertCalled("new3", arguments); arguments = new Object[] { new Integer(1) }; t = new Statement(MockObject.class, "new", arguments); @@ -531,22 +551,6 @@ } /* - * Test the method execute() with a normal object with overloaded - * constructors, the method name "new" and null arguments. - */ - public void testExecute_OverloadedConstructorsNull() throws Exception { - Object[] arguments = new Object[] { null }; - Statement t = new Statement(MockObject.class, "new", arguments); - try { - t.execute(); - fail("Should throw NullPointerException!"); - } catch (NullPointerException ex) { - // expected - } - // MockObject.assertCalled("new2", arguments); - } - - /* * Test the method execute() with the Class object, a static method name and * valid arguments. */ @@ -589,7 +593,7 @@ * Test the method execute() with the special method Class.forName(). */ public void testExecute_ClassForName() throws Exception { - Object[] arguments = new String[] { this.getClass().getName() }; + Object[] arguments = new String[] { Statement.class.getName() }; Statement t = new Statement(Class.class, "forName", arguments); t.execute(); @@ -604,8 +608,8 @@ */ public void testExecute_ArrayGet() throws Exception { Object[] array = new Object[] { "test" }; - Statement t = new Statement(array, "get", - new Object[] { new Integer(0) }); + Statement t = new Statement(array, "get", new Object[] { + new Integer(0)}); t.execute(); array = new Object[] { "test" }; @@ -653,7 +657,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 Integer(0), "test2"}); t.execute(); assertEquals("test2", array[0]); @@ -765,14 +769,14 @@ * * Note: decided by definition position! */ - public void testExecute_EqualSpecificMethods() throws Exception { - MockObject mo = new MockObject(false); - Object[] arguments = new Object[] { new MockObject(false), - new MockObject(false) }; - Statement t = new Statement(mo, "equalSpecificMethod", arguments); - t.execute(); - MockObject.assertCalled("equalSpecificMethod1", arguments); - } +// public void testExecute_EqualSpecificMethods() throws Exception { +// MockObject mo = new MockObject(false); +// Object[] arguments = new Object[] { new MockObject(false), +// new MockObject(false) }; +// Statement t = new Statement(mo, "equalSpecificMethod", arguments); +// t.execute(); +// MockObject.assertCalled("equalSpecificMethod1", arguments); +// } /* * Test the method execute() with two equal specific methods but one @@ -780,14 +784,14 @@ * * Note: decided by definition position! */ - public void testExecute_EqualSpecificMethodsException() throws Exception { - MockObject mo = new MockObject(false); - Object[] arguments = new Object[] { new MockObject(false), - new MockObject(false), new Object() }; - Statement t = new Statement(mo, "equalSpecificMethod", arguments); - t.execute(); - MockObject.assertCalled("equalSpecificMethod4", arguments); - } +// public void testExecute_EqualSpecificMethodsException() throws Exception { +// MockObject mo = new MockObject(false); +// Object[] arguments = new Object[] { new MockObject(false), +// new MockObject(false), new Object() }; +// Statement t = new Statement(mo, "equalSpecificMethod", arguments); +// t.execute(); +// MockObject.assertCalled("equalSpecificMethod4", arguments); +// } /* * Test the method execute() with int method while providing a null @@ -799,8 +803,8 @@ Statement t = new Statement(mo, "intMethod", arguments); try { t.execute(); - fail("Should throw NullPointerException!"); - } catch (NullPointerException ex) { + fail("Should throw NoSuchMethodException!"); + } catch (NoSuchMethodException ex) { // expected } } @@ -862,7 +866,7 @@ calledMethod = "method1-2"; receivedArguments.add(n); } - + public void method(Integer o) { reset(); calledMethod = "method1-3"; @@ -880,7 +884,7 @@ calledMethod = "method3"; receivedArguments.add(o); } - + public void method(Object o, Object o2) { reset(); calledMethod = "method4"; @@ -889,6 +893,14 @@ throw new NullPointerException(); } + public void method(Object o, Number n, String s) { + reset(); + calledMethod = "method5"; + receivedArguments.add(o); + receivedArguments.add(n); + receivedArguments.add(s); + } + public static void reset() { receivedArguments.clear(); calledMethod = null; @@ -938,6 +950,14 @@ throw new NullPointerException(); } + public MockObject(Object o, Vector v, Class c) { + reset(); + calledMethod = "new5"; + receivedArguments.add(o); + receivedArguments.add(v); + receivedArguments.add(c); + } + public void intMethod(int i) { reset(); calledMethod = "intMethod"; @@ -974,37 +994,37 @@ receivedArguments.add(o); } - public void equalSpecificMethod(MockObject o, MockParent p) { - reset(); - calledMethod = "equalSpecificMethod1"; - receivedArguments.add(o); - receivedArguments.add(p); - } +// public void equalSpecificMethod(MockObject o, MockParent p) { +// reset(); +// calledMethod = "equalSpecificMethod1"; +// receivedArguments.add(o); +// receivedArguments.add(p); +// } +// +// public void equalSpecificMethod(MockParent p, MockObject o) { +// reset(); +// calledMethod = "equalSpecificMethod2"; +// receivedArguments.add(p); +// receivedArguments.add(o); +// } +// +// public void equalSpecificMethod(MockParent p, MockObject o, Object o2) +// throws Exception { +// reset(); +// calledMethod = "equalSpecificMethod4"; +// receivedArguments.add(p); +// receivedArguments.add(o); +// receivedArguments.add(o2); +// } +// +// public void equalSpecificMethod(MockObject o, MockParent p, Object o2) { +// reset(); +// calledMethod = "equalSpecificMethod3"; +// receivedArguments.add(o); +// receivedArguments.add(p); +// receivedArguments.add(o2); +// } - public void equalSpecificMethod(MockParent p, MockObject o) { - reset(); - calledMethod = "equalSpecificMethod2"; - receivedArguments.add(p); - receivedArguments.add(o); - } - - public void equalSpecificMethod(MockParent p, MockObject o, Object o2) - throws Exception { - reset(); - calledMethod = "equalSpecificMethod4"; - receivedArguments.add(p); - receivedArguments.add(o); - receivedArguments.add(o2); - } - - public void equalSpecificMethod(MockObject o, MockParent p, Object o2) { - reset(); - calledMethod = "equalSpecificMethod3"; - receivedArguments.add(o); - receivedArguments.add(p); - receivedArguments.add(o2); - } - public static Class forName(String o) { reset(); calledMethod = "forName";