### Question:
AfterThrowingAdvice { boolean isAfterThrowingCalled() { return afterThrowingCalled; }  void reset(); @AfterThrowing(pointcut = "execution(void throwsRuntimeException())", throwing = "ex") void logException(RuntimeException ex);  }### Answer:
@Test public void afterThrowingIsNotCalledIfMethodReturnSuccessfully() { assertFalse(afterThrowingAdvice.isAfterThrowingCalled()); simpleService.doSomething(); assertFalse(afterThrowingAdvice.isAfterThrowingCalled()); }
@Test(expected = RuntimeException.class) public void afterThrowingIsCalledIfMethodThrowsRuntimeException() { assertFalse(afterThrowingAdvice.isAfterThrowingCalled()); try { simpleService.throwsRuntimeException(); } finally { assertTrue(afterThrowingAdvice.isAfterThrowingCalled()); } }
@Test(expected = Exception.class) public void afterThrowingIsNotCalledIfMethodThrowsException() throws Exception { assertFalse(afterThrowingAdvice.isAfterThrowingCalled()); try { simpleService.throwsException(); } finally { assertFalse(afterThrowingAdvice.isAfterThrowingCalled()); } }