Monday 4 August 2014

OpenCDS - Test your service using SoapUI


I found SoapUI very useful for testing my OpenCDS services. One of the advantages is that SoapUI allows you to create Groovy scripts to customize your test cases.  Additionally, you can use LoadUI for advanced service load testing.  In this post I describe how I am using SoapUI to test my OpenCDS services, if you have a better approach please let me know :)

Tools used:

-SoapUI - you can downloaded from here
-Example SoapUI project, available here
-Example input vMR available here

Steps:

1.- Create a folder in you machine (e.g., "/home/MyVmrContent" in Linux or C:\MyVmrConten in Windows)

2.- Create two XML files in the new folder, something like this:

OpenCDSInput.xml - This contains the decoded vMR that we want to send the the service.  You can download an example vMR here 

OpenCDSOuput.xml - This will contain the vMR that we get from the OpenCDS service, for now just leave it empty.

3.- Open SoapUI and import the example SoapUI project.  File-> Import Project.  Then open the evaluateAtSpecifiedTime test step


and change the Endpoint of the service, in this example my OpenCDS service is located in http://10.42.0.62:18080/opencds-decision-support-service/evaluate 




4.-Open the Groovy script "Changebase64EncodePaylod".  This script encode the content of the OpenCDSInput.xml and put it inside the SOAP message request.




Change the path of the input file "OpenCDSInput.xml" to your folder






5.- Now you can run the test by opening the  "Show test editor"



 and just click in the green arrow to test your service.


6.- Thats it!. The decoded OpenCDS response will be available in the file OpenCDSOutput.xml.  The advantage of this approach is that you can work directly with your XML editor without having to manually decode the vMR into base64.  Additionally, you can create more Groovy scripts and make more complex test scenarios, such as sending different requests based on the content of a SOAP message response, etc. 


Notes

This example is based on the Oxygen demo available here:
http://develop.opencds.org/OpenCDSDemo/latest/OxygenDemo.wssc