3 Replies Latest reply on Apr 15, 2014 3:11 PM by aaroncirillo

    Junit testing and JMS

    aaroncirillo

      I am trying to write some unit tests for services in Switchyard which make use of a HornetQ JMS topic on JBoss AS. When I attempt to run the unit tests they fail because there is no JMS broker or topic available in the JVM in which Junit starts. I get error messages like the following from Junit:

       

      testListen(com.example.switchyard.pubsub.Subscriber2Test): org.switchyard.SwitchYardException: Failed to create route route1 at: >>> To[jms:topic:PriceTopic?connectionFactory=#ConnectionFactory] <<< in route: Route[[From[switchyard://PriceService]] -> [Log[Received mes... because of Failed to resolve endpoint: jms://topic:PriceTopic?connectionFactory=%23ConnectionFactory due to: No bean could be found in the registry for: ConnectionFactory of type: javax.jms.ConnectionFactory

        testListen(com.example.switchyard.pubsub.Subscriber3Test): org.switchyard.SwitchYardException: Failed to create route route2 at: >>> To[jms:topic:PriceTopic?connectionFactory=#ConnectionFactory] <<< in route: Route[[From[switchyard://PriceService]] -> [Log[Received mes... because of Failed to resolve endpoint: jms://topic:PriceTopic?connectionFactory=%23ConnectionFactory due to: No bean could be found in the registry for: ConnectionFactory of type: javax.jms.ConnectionFactory

        testSubmitPrice(com.example.switchyard.pubsub.PriceServiceTest): org.switchyard.SwitchYardException: Failed to create route route3 at: >>> To[jms:topic:PriceTopic?connectionFactory=#ConnectionFactory] <<< in route: Route[[From[switchyard://PriceService]] -> [Log[Received mes... because of Failed to resolve endpoint: jms://topic:PriceTopic?connectionFactory=%23ConnectionFactory due to: No bean could be found in the registry for: ConnectionFactory of type: javax.jms.ConnectionFactory

        testListen(com.example.switchyard.pubsub.Subscriber1Test): org.switchyard.SwitchYardException: Failed to create route route4 at: >>> To[jms:topic:PriceTopic?connectionFactory=#ConnectionFactory] <<< in route: Route[[From[switchyard://PriceService]] -> [Log[Received mes... because of Failed to resolve endpoint: jms://topic:PriceTopic?connectionFactory=%23ConnectionFactory due to: No bean could be found in the registry for: ConnectionFactory of type: javax.jms.ConnectionFactory

       

      I understand why this is happening, but I am unsure of the approach that is normally taken to solve this issue. I have bumped into something called the JBoss Microcontainer, which looks like it might be able to be used to start up a small instance of JBoss that I could run HornetQ inside of for my unit tests. I'm not sure if that's the right approach though.

       

      Anyone else out there have to do any unit testing that makes use of JMS?

       

      Thanks