等待executorChannel在Junit完成
我正在使用春季集成和Junit。
@Test
public void testOnePojo() throws Exception {
ExecutorChannel orderSendChannel =
context.getBean("validationChannel", ExecutorChannel.class);
ExecutorChannel orderReceiveChannel = context.getBean("auditChannel", ExecutorChannel.class);
orderReceiveChannel.subscribe(t -> {
System.out.println(t);//I want to see this output
});
orderSendChannel.send(getMessageMessage());
}
我看不到接收通道的输出。 Junit订阅后退出。它有一种适当的方式在内部等待testOnePojo
,直到auditchannel
接收响应。
I am using spring integration and junit.
@Test
public void testOnePojo() throws Exception {
ExecutorChannel orderSendChannel =
context.getBean("validationChannel", ExecutorChannel.class);
ExecutorChannel orderReceiveChannel = context.getBean("auditChannel", ExecutorChannel.class);
orderReceiveChannel.subscribe(t -> {
System.out.println(t);//I want to see this output
});
orderSendChannel.send(getMessageMessage());
}
I cannot see the output from the receiving channel. JUnit exits after subscribing. It there a proper way to wait inside testOnePojo
until auditChannel
receives a response.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
you can use a CoundDownLatch in your test and wait for the MessageHandler to handle your message. Your example would look something like this: