简体   繁体   English

如何测试 Spring 集成变压器?

[英]How do I test a Spring Integration Transformer?

I am new to Spring Integration (been using Spring before).我是 Spring 集成的新手(之前一直在使用 Spring)。 I have made a transformer like this:我做了一个这样的变压器:

@Transformer(inputChannel = "signering", outputChannel = "validering")

and now I want to test it.现在我想测试它。 So I have done like this in my test:所以我在我的测试中这样做了:

@Autowired
MessageChannel signering;

@Autowired
PollableChannel validering;

When I invoke the transformer in my test it seems to work当我在测试中调用变压器时,它似乎可以工作

signering.send(msg.build());

but I am unable to intercept the outgoing message (which is what I want).但我无法拦截传出的消息(这是我想要的)。 Instead it seems to go to the real bean validering and onwards.相反,它似乎是 go 到真正的 bean 验证等。 I have added a.receive call after the send call, but it gets nothing.我在 send 调用之后添加了 a.receive 调用,但它什么也没得到。 And the Internet is not really helpful right now.互联网现在并没有真正的帮助。 What examples I find for Spring Integration testing seems to be using XML context, and they are pretty old at that.我为 Spring 集成测试找到的示例似乎是使用 XML 上下文,而且它们已经很老了。 What is the current way of doing this kind of testing?目前进行这种测试的方法是什么?

In your test case, add a ChannelInterceptor to the output channel, before sending the request, to examine the output.在您的测试用例中,在发送请求之前,将ChannelInterceptor添加到 output 通道,以检查 output。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何对 Spring Boot 应用程序进行集成测试? - How to do an integration test for a Spring Boot application? 如何在Spring集成中使用JAVA配置创建xslt-transformer? - How can I create xslt-transformer with JAVA config in Spring integration? Spring Integration:Transformer:文件到对象 - Spring Integration : Transformer : file to Object 打破 Transformer 流程​​ Spring 集成 - Break the Transformer flow Spring Integration 如何使用 Spring MVC 控制器作为集成测试的假端点? - How do I use a Spring MVC Controller as a Fake Endpoint for an Integration Test? 如何使用 JUnit、Spring Boot 和 TestContainers 防止集成测试中的数据冲突? - How do I prevent data conflicts in integration test using JUnit, Spring Boot and TestContainers? Spring 测试集成未运行我如何处理此错误? - Spring test integration not run how I deal with this error? Spring Integration Unzip转换器抛出ReplyRequiredException异常 - Spring integration Unzip transformer throws ReplyRequiredException exception Spring Integration Proxy Gateway上的入站变压器 - Inbound Transformer on Spring Integration Proxy Gateway 在Transformer中获取消息标题-Spring集成 - Get Message Headers in transformer- Spring integration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM