protected Event doExecute(RequestContext context) throws Exception { Object bean = getBean(context); Object returnValue = getMethodInvoker().invoke(methodSignature, bean, context); if (methodResultExposer != null) { methodResultExposer.exposeResult(returnValue, context); } return resultEventFactory.createResultEvent(bean, returnValue, context); }
public void testInvocationTargetException() { try { methodInvoker.invoke(new MethodSignature("test"), new TestObject(), null); fail(); } catch (MethodInvocationException e) { assertTrue(e.getTargetException() instanceof IllegalArgumentException); assertEquals("just testing", e.getTargetException().getMessage()); } }
public void testInvalidMethod() { try { methodInvoker.invoke(new MethodSignature("bogus"), new TestObject(), null); fail(); } catch (MethodInvocationException e) { assertTrue(e.getTargetException() instanceof InvalidMethodKeyException); } }
public void testPrimitiveArg() { Parameters parameters = new Parameters(); parameters.add(new Parameter(Boolean.class, new StaticExpression(true))); MethodSignature method = new MethodSignature("testPrimitiveArg", parameters); assertEquals(Boolean.TRUE, methodInvoker.invoke(method, new TestObject(), null)); }
public void testBeanArg() { Parameters parameters = new Parameters(); Bean bean = new Bean(); parameters.add(new Parameter(Bean.class, new StaticExpression(bean))); MethodSignature method = new MethodSignature("testBeanArg", parameters); assertSame(bean, methodInvoker.invoke(method, new TestObject(), null)); }