Reputation: 5578
I want to run a JUnit test with usage of JMS. Is it possible to have a JUnit test use JMS outside of an Application Server like JBoss or a CDI container?
Upvotes: 3
Views: 7891
Reputation: 243
You may also reconsider using an application server for this - Arquillian (http://arquillian.org) allows for executing unit and integration test within a JavaEE environment of your choice - and manages the app server lifecycle on its own.
Upvotes: 0
Reputation: 1658
Provided that sending and consuming the message is completely decoupled from JMS, you could mock it.
For example: You can have a class that implements an interface like "IMyClassSender". In real code (non junit), all this class does is submit the message to JMS. In junit, implement IMyClassSender with a class that takes the input and instead if submitting to JMS, it passes it to your consumer class.
Alternatively, if you are using active mq: http://activemq.apache.org/how-to-unit-test-jms-code.html
Upvotes: 3