An intro on TDD: http://www.agiledata.org/essays/tdd.html
When working with ESB products you work on a different abstraction layer. You are more focused on configuring a message flow, detailing how a specific type of message needs to be routed, transformed, filtered and delivered. You are not as close to the code as a java developer hence it is more difficult to test the complete flow. In addition to that, ESB products are very focused on connectivity to for example an Oracle Database or a SAP backend system. This makes it even more difficult to test because it requires these external systems to be available during testing and also to produce predictable results.
Oracle Service Bus (OSB) is such an ESB. I will not go into depth about the product here, but important to know is that it is very much oriented towards Web Services and XML. These standards will help us to test our integration logic.
In the below picture you can see the setup for our tests. The following steps happen during a test run:
- A test request is read from a file and sent using a HTTP client to OSB
- OSB runs the integration logic as it would for any request
- The business service it invokes is configured with a test endpoint. An embedded HTTP server is used for this purpose.
- The test endpoint can assert the incoming request, wait for a configured period of time and return a configured response.
- OSB will return a response to the test client as well, which can then in its turn assert the response.
Some of the code for executing this test:
First question to expect is of course: why the custom code and not SOAP UI?
Indeed you can use SOAPUI as SOAP client and SOAP mock server. The reasons for not doing this is because you have a lot more control. When I start up a test I can change the behaviour of the mock server:
- I can choose to let it return different responses
- I can let it wait so that OSB will not have a response in time; allows me to test the exception handling and retry mechanisms.
I can also assert the request that comes from OSB to make sure it is as expected. In case I have to call multiple business services I can have one service return a sucessfull response and have another one time out.
All this more complex testing is a lot harder, if not impossible, to configure using SOAP UI.
Author: Jeroen V
No comments:
Post a Comment