TimestampInterceptor extends AbstractPhaseInterceptor<Message> { @Override public void handleMessage(Message message) { message.put(INVOCATION_TIME_KEY, new Date()); } TimestampInterceptor(); @Override void handleMessage(Message message); @Override void handleFault(Message messageParam); static final String INVOCATION_TIME_KEY; }
@Test public void testHandleMessage() { Message message = new MessageImpl(); Date beforeDate = new Date(); TimestampInterceptor interceptor = new TimestampInterceptor(); interceptor.handleMessage(message); Date interceptorDate = (Date) message.get(interceptor.INVOCATION_TIME_KEY); assertNotNull(interceptorDate); assertTrue(beforeDate.before(interceptorDate) || beforeDate.equals(interceptorDate)); }