/** * Returns the target root cause exception of the method invocation failure. * @return the target throwable */ public Throwable getTargetException() { Throwable targetException = getCause(); while (targetException instanceof InvocationTargetException) { targetException = ((InvocationTargetException) targetException).getTargetException(); } return targetException; } }
throw new MethodInvocationException(signature, arguments, e.getTargetException()); } catch (Exception e) { throw new MethodInvocationException(signature, arguments, e);
public void testGetTargetException() { // runtime exception IllegalArgumentException iae = new IllegalArgumentException("test"); MethodInvocationException ex = testException(iae); assertSame(iae, ex.getTargetException()); // exception IOException ioe = new IOException("test"); ex = testException(ioe); assertSame(ioe, ex.getTargetException()); // nested InvocationTargetException ite = new InvocationTargetException(ioe); ex = testException(ite); assertSame(ioe, ex.getTargetException()); // deep nesting ite = new InvocationTargetException(new InvocationTargetException(ioe)); ex = testException(ite); assertSame(ioe, ex.getTargetException()); }
throw new MethodInvocationException(signature, arguments, e.getTargetException()); } catch (Exception e) { throw new MethodInvocationException(signature, arguments, e);
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()); } }
throw new MethodInvocationException(signature, arguments, e.getTargetException()); } catch (Exception e) { throw new MethodInvocationException(signature, arguments, e);
/** * Returns the target root cause exception of the method invocation failure. * @return the target throwable */ public Throwable getTargetException() { Throwable targetException = getCause(); while (targetException instanceof InvocationTargetException) { targetException = ((InvocationTargetException) targetException).getTargetException(); } return targetException; } }
public void testInvalidMethod() { try { methodInvoker.invoke(new MethodSignature("bogus"), new TestObject(), null); fail(); } catch (MethodInvocationException e) { assertTrue(e.getTargetException() instanceof InvalidMethodKeyException); } }
throw new MethodInvocationException(signature, arguments, e.getTargetException()); } catch (Exception e) { throw new MethodInvocationException(signature, arguments, e);
/** * Returns the target root cause exception of the method invocation failure. * @return the target throwable */ public Throwable getTargetException() { Throwable targetException = getCause(); while (targetException instanceof InvocationTargetException) { targetException = ((InvocationTargetException) targetException).getTargetException(); } return targetException; } }
private MethodInvocationException testException(Throwable cause) { return new MethodInvocationException(new MethodSignature("test"), null, cause); } }
/** * Returns the target root cause exception of the method invocation failure. * @return the target throwable */ public Throwable getTargetException() { Throwable targetException = getCause(); while (targetException instanceof InvocationTargetException) { targetException = ((InvocationTargetException) targetException).getTargetException(); } return targetException; } }