@Test public void testTooManyArguments() throws Exception { delegator.setTargetMethod("setName"); // single argument expected but two provided delegator.invokeDelegateMethodWithArguments(new Object[] { "name", "anotherName" }); assertEquals("name", foo.getName()); }
/** * Regular use - calling methods directly and via delegator leads to same * results */ @Test @Ignore //FIXME public void testDelegationWithMultipleArguments() throws Exception { FooService fooService = new FooService(); delegator.setTargetObject(fooService); delegator.setTargetMethod("processNameValuePair"); delegator.afterPropertiesSet(); final String FOO_NAME = "fooName"; final int FOO_VALUE = 12345; delegator.invokeDelegateMethodWithArguments(new Object[] { FOO_NAME, FOO_VALUE }); Foo foo = fooService.getProcessedFooNameValuePairs().get(0); assertEquals(FOO_NAME, foo.getName()); assertEquals(FOO_VALUE, foo.getValue()); }