How to integration test Solace with Spring Boot AutoConfig / JmsListener
Hello
the project I'm working on needs me to integrate a receiver for Solace PubSub+ Messages with Spring Boot. The following snippet resembles my current implementation. The controller receives a message, forwards it to my usecase which extracts some headers and the payload and creates a MyMessage POJO which in turn is finally handed back to the controller.
@Component @RequiredArgsConstructor public class MyController { private final MyUseCase myUseCase; @JmsListener(destination = "MyQueue") public MyMessage forward(Message<byte[]> message) { return this.myUseCase.handle(message); } }
The PubSub+ broker runs on Docker and has "MyQueue" configured.
Running the application and manually sending a Message on MyQueue shows that the controller is working as intended. We're running JUnit5 and Spring's MockMVC for our other controllers.
How can I test this controller with integration tests?
I see that I need a sender that posts a message on MyQueue which is then received by MyController. But how can I be sure that my Listener receives and forwards the message?
Is there a way to 'intercept' the returned MyMessage and evaluate it's fields?
Best Answer
-
Hi @rothek,
Can you take a look at Gary's answer here and see if it gives you what you need: https://stackoverflow.com/questions/42803627/writing-tests-to-verify-received-msg-in-jms-listener-spring-boot
1
Answers
-
Hi @rothek,
Can you take a look at Gary's answer here and see if it gives you what you need: https://stackoverflow.com/questions/42803627/writing-tests-to-verify-received-msg-in-jms-listener-spring-boot
1