@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!"); }
@Override public boolean supportsMessageType(String messageType, Message message) { return messageType.equalsIgnoreCase(MessageType.XML.toString()); }