- Test Suite
- Opensphere Test Suite
- Message Detector
So I got a brand new task: write an application that's going to process client requests for spare car parts. The requests should be validated, and forwarded to spare part vendors in order to check the availability of the parts. Then the application should gather responses from the vendors, merge them, and send them back to the client. All the communication based on JMS. Sounds like a piece of cake, huh?
After two weeks of happy coding I announced, that the task is ready! My PM asked if I’d tested it. Man! I'm not a beginner. I’m the one who wrote the unit tests! “But I mean integrating it with a real JMS server, and automated integration tests based on that” he said.
What? Am I supposed to write client and vendor simulators? Not only that: I would have to somehow check JMS messages, which are input to and output from my program, and compare them with the expected patterns. The lazy part of my developer's nature said: “no way”, and so I started searching the internet with the hope, that maybe someone somewhere has created something that could help me.
Opensphere? Ok, let's see what they've got here. Customizable JMS message producer where I can define my messages with arbitrary properties and payload type. Messages' content can be enriched with substitution variables or data taken straight from a database. Sounds good! And the good news doesn’t stop here, Openshere’s peer, JMS message consumer, waits for messages and is capable of replying to them with predefined responses.
I set up HonetQ to host my queues and topics, and created my first Opensphere project that ran my application in a simulated environment. All this in just 30 minutes:
Simulation is cool, isn't it? But what I need are tests. Opensphere supports them as well. For me the most crucial element here is a message comparator. When the JMS message consumer gets a message it can be written down to a file, and the comparator checks it against previously prepared, expected patterns. But it's much more than just a simple file diff. In a map message or a text message with XML payload you can define exactly which elements should be compared. This way irrelevant content is simply ignored which would be almost impossible with basic file diff. Graphical presentation of a test case flow is another great feature.
After a day of work I had a complete test suite for my application:
Believe me, it's only the top of the iceberg. I didn't even mention web services, Tibco Rendezvous and SQL support as well as other interesting possibilities. Maybe one day I'll write something more about them... However, after playing with Opensphere for some time, I'm convinced this piece of software is definitely worth those few bucks they want for the license.