Spring integration 如何在spring集成测试中调用通道

Spring integration 如何在spring集成测试中调用通道,spring-integration,spring-integration-dsl,Spring Integration,Spring Integration Dsl,我有一个接受字符串输入的流 @Bean public IntegrationFlow myFlow() { // @formatter:off return IntegrationFlows.from("some.input.channel") .handle(someService) .get(); 如何从集成测试中调用它,如何在

我有一个接受字符串输入的流

  @Bean
  public IntegrationFlow myFlow() {
        // @formatter:off
        return IntegrationFlows.from("some.input.channel")
                               .handle(someService)
                               .get();

如何从集成测试中调用它,如何在“some.input.channel”上放置字符串消息

/**
 * Populate the {@link MessageChannel} name to the new {@link IntegrationFlowBuilder} chain.
 * The {@link org.springframework.integration.dsl.IntegrationFlow} {@code inputChannel}.
 * @param messageChannelName the name of existing {@link MessageChannel} bean.
 * The new {@link DirectChannel} bean will be created on context startup
 * if there is no bean with this name.
 * @return new {@link IntegrationFlowBuilder}.
 */
public static IntegrationFlowBuilder from(String messageChannelName) {
然后打开所用框架的参考手册:

因此,JavaDSL创建的通道成为应用程序上下文中的bean。 只需将其自动连接到测试类并从测试方法调用其
send()

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = MyFlowConfiguration.class)
public class IntegrationFlowTests {

    @Autowired
    @Qualifier("some.input.channel")
    private MessageChannel someInputChannel;

    @Test
    public void myTest() {
          this.someInputChannel.send(new GenericMessage<>("foo"));
    }
}
@RunWith(SpringRunner.class)
@ContextConfiguration(类=MyFlowConfiguration.class)
公共类集成流测试{
@自动连线
@限定符(“some.input.channel”)
私有消息通道someInputChannel;
@试验
公共无效myTest(){
this.someInputChannel.send(新的GenericMessage(“foo”);
}
}

感谢分享文档链接,我的测试成功了