AbstractMessageConstructionInterceptor implements MessageConstructionInterceptor { @Override public Message interceptMessageConstruction(Message message, String messageType, TestContext context) { if (supportsMessageType(messageType)) { return interceptMessage(message, messageType, context); } else { log.debug(String.format("Message interceptor type '%s' skipped for message type: %s", getName(), messageType)); return message; } }  @Override Message interceptMessageConstruction(Message message, String messageType, TestContext context); @Override MessageDirection getDirection(); void setDirection(MessageDirection direction);  }
@Test public void testInterceptMessageConstruction() throws Exception { MessageConstructionInterceptor interceptor = new AbstractMessageConstructionInterceptor() { @Override public boolean supportsMessageType(String messageType) { return MessageType.XML.toString().equalsIgnoreCase(messageType); } @Override protected Message interceptMessage(Message message, String messageType, TestContext context) { return new DefaultMessage("Intercepted!"); } @Override protected String getName() { return "MockInterceptor"; } }; Message in = new DefaultMessage("Hello Citrus!"); Message intercepted = interceptor.interceptMessageConstruction(in, MessageType.XML.toString(), context); Assert.assertEquals(intercepted.getPayload(String.class), "Intercepted!"); intercepted = interceptor.interceptMessageConstruction(in, MessageType.PLAINTEXT.toString(), context); Assert.assertEquals(intercepted.getPayload(String.class), "Hello Citrus!"); }