@Test public void test() throws Throwable { final Object[] args = new Object[] { null }; context.checking(new Expectations() { { allowing(pjp).getTarget(); will(returnValue(target)); allowing(pjp).toShortString(); will(returnValue("shortString")); oneOf(pjp).proceed(); allowing(pjp).getArgs(); will(returnValue(args)); allowing(pjp).getSignature(); will(returnValue(signature)); allowing(signature).toShortString(); will(returnValue("signatureShortString")); } }); sut.profile(pjp); context.assertIsSatisfied(); }
public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } }
PerformanceTimer { public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } } }
PerformanceTimer { public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } }  }
PerformanceTimer { public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } }  Object profile(final ProceedingJoinPoint call); }
PerformanceTimer { public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } }  Object profile(final ProceedingJoinPoint call);  }