LoggingAspect { @Around("( allContextHandlerClassMethods() || loggableAnnotation() || allPepMethods()) && ( ! noLogAnnotation())") public Object logAndExecute(ProceedingJoinPoint joinPoint) throws Throwable { if (null == aspectUtils) { if(null == marshaller) marshaller = new SimpleMarshallerImpl(); aspectUtils = new AspectUtils(marshaller); } aspectUtils.beforeMethod(joinPoint); long startNanos = System.nanoTime(); Object result = joinPoint.proceed(); long stopNanos = System.nanoTime(); long lengthMillis = TimeUnit.NANOSECONDS.toMillis(stopNanos - startNanos); aspectUtils.afterMethod(joinPoint, result, lengthMillis); return result; }  SimpleMarshaller getMarshaller(); void setMarshaller(SimpleMarshaller marshaller); AspectUtils getAspectUtils(); void setAspectUtils(AspectUtils aspectUtils); @Around("( allContextHandlerClassMethods() || loggableAnnotation() || allPepMethods()) && ( ! noLogAnnotation())") Object logAndExecute(ProceedingJoinPoint joinPoint); @Pointcut("execution(* gov.samhsa.acs.pep.*.*(..))") void allPepMethods(); @Pointcut("@annotation(gov.samhsa.acs.common.log.Loggable)") void loggableAnnotation(); @Pointcut("execution(* gov.samhsa.acs.contexthandler.ContextHandlerImpl.*(..))") void allContextHandlerClassMethods(); @Pointcut("@annotation(gov.samhsa.acs.common.log.NO_LOG)") void noLogAnnotation();  }
@Test public void testLogAndExecute() throws Throwable { Object objMock = mock(Object.class); ProceedingJoinPoint pjp = mock(ProceedingJoinPoint.class); when(pjp.proceed()).thenReturn(objMock); Object obj = sut.logAndExecute(pjp); assertNotNull(obj); }