简体   繁体   中英

What should be the strategy for integration testing Jms Listeners/Consumers in a Spring Boot Application?

We have a Spring Boot JMS Listener Application that is made up of a Jms Listener, a service orchestration class, and a number of service classes underneath that orchestration class. The application requires integration testing. Originally, I was thinking about testing it using a combination of Spring Test and Mockito, but in order to do that, I would need to use create my mocks and then use them in two separate threads (thread[main] for the test and thread[DefaultMessageListenerContainer-1] for the Jms Listener) and as far as I understand, Mockito only keeps its state in Threadlocal as shown in their documentation . Please see the quote below.

Mockito uses ThreadLocal state to implement a gorgeous mocking syntax in a language full of constraints (yes, it's java). Fortunately, every time you interact with Mockito framework it validates the ThreadLocal state in case you misused the api.

Given this, I was thinking about having two separate test classes, one which will test that the listener is properly wired and it is able to take a message, and the other will test the service orchestrator and the service classes behaviour. Please let me know if there are other alternatives to this strategy that allows me to test both under the same test class.

Thanks,

Juan

In light of what I discovered here , I will be going with creating an integration test to test the JMS Listener and service orchestrator and minimize the number of separate integration tests to keep the build times low and still maintain the quality for coverage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM