One of the great features of Mule and ServiceMix is testability, which lets you start up a Mule and ServiceMix container from, for example, a piece of Java code or an Ant build file. It’s easy to get the developed message flows running, but what about the next step, flow testing? Because Mule and ServiceMix support a wide variety of connectivity options, there are several ways to test message flows, depending on the choice of connectivity for a specific message flow. For instance, when you use JMS, you can use Hermes JMS (http://www.hermesjms.com) to send a message to a specific queue or topic to trigger the message flow; and you can browse a queue or topic to look for messages arriving at the anticipated destination. You can also use Plain Old Unit Tests (POUT) to trigger a message flow and look for messages at specific endpoints.
This book offers another alternative for testing Mule and ServiceMix flows: the Swing test client. The Swing test client provides a wide variety of connectivity support and an easy-to-use graphical interface. For example, you can send messages to a JMS queue or a file directory and receive messages at their target destination. You need only one tool to support your unit testing.
You can start the Swing test client via a console or by using your IDE (such as Eclipse) to start an Ant target. To start the Swing test client via a console, go to the osesb-test-client directory, which is available in the root of the directory that you created to set up the book’s working environment. Then, execute the following Java instruction in the console:
java –jar osesb-test-client.jar
The test client will start, and you’ll see a screen similar to figure F.1.
In the Swing test-client screen, you can select most of the examples described in this book, categorized by open source ESB and chapter number. The Mule examples using the STDIO connector aren’t available in the test client, because these examples should be tested via the console where Mule is started.
You can also start the Swing test client using the Ant build scripts for the book’s different chapters. Eclipse provides a nice Ant view that you can use to easily start Ant targets. This Eclipse functionality can also be used to start the Swing test client in Eclipse. Once the Ant view is available in Eclipse (via the Windows > Show View > Ant menu options), drag the Ant build scripts for the various chapters (for example, resources/chapter8/ch8-examples.xml for chapter 8) to the Ant view. All the targets described in the Ant build file are available in the Ant view, as shown in figure F.2.
Figure F.2 shows that in addition to the ext:test-client Ant target, many other Ant targets are available for chapter 8’s Mule examples. You can use these other Ant targets to start Mule, deploy the examples from chapter 8 to Mule, and start up additional tools such as Apache ActiveMQ. To start the Swing test client, double-click the ext:test-client Ant target to open a screen similar to figure F.1.
The Swing test client is categorized by Mule and ServiceMix chapter configurations. For each chapter, you can click the example you want to test. Because the examples described in this book use all kinds of connectivity, the Swing test client is able to send and receive messages from different message channels; it supports files, JMS, and web services.
For example, when you click the scuba diving example from chapter 11 for the ServiceMix ESB, two panels appear at right on the test client screen: an In panel for sent messages and an Out panel for received messages. The scuba diving example uses JMS to send and receive messages. Figure F.3 shows the panel that enables you to send a scuba diving request message.
This example’s endpoint is configured to be the scuba.in JMS queue. Clicking the Send Message button sends the scuba diving request message to this JMS queue, which triggers the ServiceMix scuba diving message flow.
For other examples, different connectivity options are provided, such as file and web-services support. The panel shown in figure F.3 isn’t that much different; the endpoint points to a file or directory for file connectivity and to an HTTP address for a web service. The message that is sent can be plain text (as shown in figure F.3) or a Java object instance.
The panel you use to receive messages from a specific message channel, shown in figure F.4, is similar to the panel that sends messages.
Clicking the Start button starts a listener or poller to receive messages. You can show the incoming message content by clicking a row in the messages table.
With the Swing test client, you can easily test all the examples in this book. To use the Swing test client in your own project, you can use the client-config.xml file in the resources directory to configure the connectivity required to test your integration logic. Based on the available examples, you should be able to configure your own test easily.
3.149.27.234