I want to do an integration test of two Spring Boot apps which are also using Spring Integration flows. To test my apps, I want to check the messages routed through myMessageChannel
. It is defined in an XML flow in one of the applications.
How do I wiretap into my direct message channel and redirect the messages to a PollableChannel, so I can read them one by one? None of the methods I found online worked for me.
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {App1.class, App2.class}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource("classpath:integration.properties")
public class MyWireTapTest {
@Autowired
MessageChannel myMessageChannel;
@Test
public void test() {
// This is basically what I want to do
// But it does not work, since it is a direct channel
myMessageChannel.recieve();
}
}
Autowire it as AbstractMessageChannel
and use
myMessageChannel.addInterceptor(new WireTap(tapChannel));