Unit testing with JMS (ActiveMQ)
Asked Answered
D

3

12

How to do unit testing with JMS ? Is it some de-facto for this ?

I googled something - Unit testing for JMS: http://activemq.apache.org/how-to-unit-test-jms-code.html - jmsTemplate: activemq.apache.org/jmstemplate-gotchas.html - mockRunner : mockrunner.sourceforge.net/

Do you have any good experience on those and suggestion for me ?

Dzerzhinsk answered 20/5, 2010 at 1:3 Comment(0)
K
12

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.

Kenward answered 22/5, 2010 at 20:32 Comment(0)
C
5

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.

Component answered 5/9, 2010 at 10:11 Comment(0)
P
1

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.

Purnell answered 22/5, 2010 at 20:21 Comment(1)
and what if you 1) get a message 2)do some tricks 3)send a message to a specific destination??Purnell

© 2022 - 2024 — McMap. All rights reserved.