I'm new in Spring JMS, I'm trying to test a method that uses @JMSListener.
Do you have idea how to test this using mockrunner or other tool you know?
I've seen this sample but I'm not sure if this is applicable for my case. https://dzone.com/articles/mockrunner-jms-spring-unit
@Service
public class MyJMSService {
@JmsListener(destination = "jms/queuename")
public void processMessage(ObjectMessage msg) throws JMSException {
//do stuff
}
}
I have not used mockrunner. But it should be similar to other mocking frameworks such as eazymock or mockito. What you need to do is mock all the external calls. In your test class inside the @BeforeMethod you can create and initialize the mocks. Then you record the mocks inside your test method, saying if this is called with these arguments, merely return this. Then you verify the mock interactions. Hope this helps. Happy coding.