Unit testing with JMS (ActiveMQ)

痞子三分冷 提交于 2019-12-04 00:30:59

In my experience (after trying to do the same thing) when you are using JMS you are doing something like

1) Get JMS Message 2) Extract Object from Message 3) Do something with Object

From that point of view I would suggest you unit test #3 but don't bother unit testing #1 or #2 -- don't test the framework -- focus on testing your code. I think it's of little benefit to (unit) test your infrastructure (similarly EJB infrastructure etc.). Things like that are better left to integration / system testing.

For simple integration tests you can run the ActiveMQ broker in embedded mode. With Maven, this can be automated so you do not even have to download and install the ActiveMQ message broker.

i looking for same kind of thing I've done it once with JMock, with it ypu can test the message creattion and combined with hamcrest you can achieve nice things.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!