I'm not sure how to test a message listener. One thing is the error I receive. The other is I don't even know if I'm on the right track.
class TestListenerTest extends Specification {
def "TestListener should receive a message"() {
given:
Message message = Mock ( Message )
TestListener listener = new TestListener()
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory()
JmsTemplate jmsTemplate = new JmsTemplate( connectionFactory )
when:
jmsTemplate.convertAndSend( "TEST_QUEUE_IN", message )
then:
1 * listener.onMessage( message )
}
}
I get the following error (without line break):
AMQ229031: Unable to validate user from /127.0.0.1:53051.
Username: null; SSL certificate subject DN: unavailable;
When I add a JMSContext with connectionFactory.createContext( "userName", "password"), the error is still there, just with userName instead of null. However, I'm not even sure if the way I test it is correct (barring the error).