lundi 28 septembre 2015

Simplest way to stub a JMS message?

I'd like to unit test a Java EE Message Driven Bean's onMessage() method. It receives a JMS message and does reading and some processing of the message content.

I'd like to stub the JMS message, but both ways known to me are not optimal:

  • Using a mocking framework (e.g. Mockito), I have to stub quite some method calls, which results in unreadable tests.
  • Implementing the javax.jms.Message inteface for a manual stub message means I need to implement like "a hundred" methods, most of which I don't need. That looks ugly to me...

Is there a better way that I could use? I've heard that Spring has a good JMS Facade, but I'm not using Spring.

Aucun commentaire:

Enregistrer un commentaire