Git Product home page Git Product logo

wso2unittesting's Introduction

WSO2UnitTest

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.

Tested On

  • WSO2 EI 6.1.0

How To Install

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/

How To Use it

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;

Disclaimer

This project is not a replacement to WSO2 TAF, it was just another way I found to test the sequences of the projects;

wso2unittesting's People

Contributors

fjunior87 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.