This project's intention is to allow a way the developers to create unit tests for their WSO2 ESB Projects. This project considers a sequence as an unit to be tested.
This Project was inspired by this blog post.
WSO2 provides a Test Automation Framework, but the documentation is not very clear (in my point of view) and seems a little bit complex.
- WSO2 EI 6.1.0
In order to use the Utilty API, we need to build the car file and deploy it to the WSO2 ESB/EI server.
We need to:
cd WSO2UnitTestParent
mvn clean install
And deploy the car file genereated to the WSO2 ESB/EI Server. The car file can be found at:
WSO2UnitTestParent/WSO2UnitTestCompositApplication/target/
Once the application is deployed to the server, we can issue http requests to the API Exposed by the application:
http://[serverhost]:8280/unittest/test
The API expects only HTTP POST requests with a JSON Payload similar to the one below:
{
"payload" : "<abc xmlns=\"http://www.abc.com\"><text>123</text></abc>",
"requestType": "xml",
"responseType": "xml"
"properties": [
{
"name":"PROP1",
"value": "ABC",
"scope": "default",
"type":"STRING"
}
],
"sequences": [
"SequenceForTest"
]
}
It is a simple JSON with the following properties:
- payload: The Payload that will be handled by the sequence that will be executed;
- requestType: The type of the request payload. It can be xml or json;
- responseType: The type of the response payload. It can be xml or json;
- properties: An array of the properties that are used inside the sequence;
- sequences: An array of the sequences to be executed. For this initial version it allows only one sequence;
The basic idea around this is:
- define a sequence to be executed;
- define the payload the sequence will handle. It can be xml or json;
- define properties that the sequence is expecting;
This API will provide a response like below:
{
"payload": "<abc xmlns=\"http://www.abc.com\"><text>123</text></abc>",
"requestType": "xml",
"responseType": "xml",
"properties": [
{
"name": "PROP1",
"value": "ABC",
"type": "STRING",
"scope": "default"
},
{
"name": "IS_VALID",
"value": "true",
"type": "STRING",
"scope": "default"
},
{
"name": "OP_PROP",
"value": "opProp",
"type": "STRING",
"scope": "operation"
}
],
"sequences": [
"SequenceForTest"
]
}
It has the same properties as the request, the differences will be:
- The payload is the one resulting after executing the sequence;
- The properties array contains all the default and operation scoped properties set after executing the sequence;
With this approache we can use some automation tool to issue the requests and check the response. We can use for example Postman to create requests and tests;
This project is not a replacement to WSO2 TAF, it was just another way I found to test the sequences of the projects;