4 Replies Latest reply on Jun 30, 2011 1:34 PM by Tom Cunningham

    ESB Unit and Integration Tests

    Ryan Hochstetler Newbie

      I'm beginning the development phase of a small-ish (but growing) ESB implementation and would like to hear about strategies for writing and executing unit and integration tests on ESB actions and services, respectively. I've browsed the test code in the repository and have a few ideas, but was wondering if there are developers out there who have found their own test strategies.

      Actions and Composers are just POJOs, so unit testing them should be simple, given that the only ESB dependencies are a ConfigTree and the Message-related clasess in most cases (the Factory, the PayloadProxy and the Message itself). I've considered using a mock ServiceInvoker for our custom routers. Testing a service as a whole is where I seem to run into trouble. I'd love it if I didn't have to boot an entire JBoss instance and deploy to it, just to test a service, but I don't yet see any other way.

      Which strategies for automated testing of ESB services have you found to be the most useful?

        • 1. Re: ESB Unit and Integration Tests
          Ryan Hochstetler Newbie

          Well, this is disappointing. 22 reads and not a single reply. There's plenty of help for the "pleez snd me teh codez" questions around here, but someone asks a question about good project practices and all I hear is crickets chirping....

          • 2. Re: ESB Unit and Integration Tests
            Daniel Bevenius Master


            someone asks a question about good project practices and all I hear is crickets chirping....

            Sorry about this. We have been a lagging a bit since last week when we were all away and some post have been missed.

            Take a look at org.jboss.soa.esb.testutils.AbstractTestRunner and org.jboss.soa.esb.listeners.gateway.JBRIntegratedUnitTest which should give you an idea of how you can test your action pipeline.



            • 3. Re: ESB Unit and Integration Tests
              Tim Heap Newbie

              I am struggling with the same concept, all I can find is feature requests for unit testing JBOSS-ESB, but not examples. I have to build a new esb project and would appreciate any suggestions.



              • 4. Re: ESB Unit and Integration Tests
                Tom Cunningham Master

                There are plenty of examples within the source of the project - from the ones that Daniel talks about, to integration level tests where the ESB is deployed to a server, a test is run, and the ESB is undeployed (see the qa/quickstarts directory, which unit tests the quickstarts by sending a message in, stores the result in a JMX MBean, and then tests the result).        As Ryan said above, actions should be testable pretty easily as POJOs - testing services is where you probably need to do more heavyweight testing - whether it be using one of the utilities that Daniel described or testing within the appserver.


                You can also take a look at Arquillian - there are a few limitations there (AS_CLIENT mode, etc) which Aslak spells out here, but it should work if you are looking for an in-container alternative :