### Question:
AfterReturningAdvice { boolean isAfterReturningCalled() { return afterReturningCalled; }  void reset(); @AfterReturning(pointcut = "execution(* *(..))", returning = "string") void logResult(String string);  }### Answer:
@Test public void afterReturningIsNotCalledIfReturnTypeDoesntMatch() { assertFalse(afterReturningAdvice.isAfterReturningCalled()); simpleService.returnsInt(); assertFalse(afterReturningAdvice.isAfterReturningCalled()); }
@Test(expected = RuntimeException.class) public void afterReturningIsNotCalledIfExceptionIsThrown() { assertFalse(afterReturningAdvice.isAfterReturningCalled()); try { simpleService.returnsStringAndThrowsRuntimeException(); } finally { assertFalse(afterReturningAdvice.isAfterReturningCalled()); } }
@Test public void afterReturningIsCalledIfReturnTypeMatches() { assertFalse(afterReturningAdvice.isAfterReturningCalled()); simpleService.returnsString(); assertTrue(afterReturningAdvice.isAfterReturningCalled()); }