Streamlined Testing for Automation Workflows with WSO2 and WireMock Cloud

Ethan Jones
Head of Product
August 20, 2024

Enterprise teams use WSO2 workflows every day to manage complex processes across their services. WSO2 workflows help collaboration, streamlined processes, and consistency - all things we are huge fans of here at WireMock.

But, testing your WS02 workflows can get challenging quickly when dealing with the hassle - or the limitations - of real, external systems. We think we can help with that!

By integrating WS02 with mock APIs on WireMock Cloud, you can streamline your testing process, catch bugs early, and ensure your workflows handle all possible situations. Let’s take a look.

Why Integrate WS02 with WireMock Cloud?

Integrating WS02 with WireMock Cloud will allow you to call out from your workflows to realistic, dynamic API mocks in the cloud. This delivers your team several huge benefits that will likely solve challenges you’ve already had:

  1. Controlled testing environment: WireMock Cloud allows you to simulate external APIs, giving you complete control over the testing environment at a very low cost and with a high degree of flexibility. This ensures your WS02 workflows function correctly without relying on live systems.

  2. Cost-effective: Save on costs by avoiding the need for access to production or staging environments when testing your WSO2 workflows.

  3. Enhanced Error Handling: Test your workflows against various scenarios, including error responses, to ensure robust error handling in production.

  4. Accelerated development: Quickly iterate and test your workflows, leading to faster development cycles and reduced time to market.

How to Configure WS02 with WireMock Cloud

Below we show how you can use WireMock Cloud to mock an API being called from a WSO workflow. While this is a relatively simple example, you could use the same template to apply the same pattern, no matter what kind of application you are working on.

For example, if you are using WSO2 to develop a healthcare application, you could mock endpoints such as EHR systems for situations where accessing the real APIs would not be feasible due to security or other concerns.

Step 1: Set Up Your WS02 Project

Start by creating a WS02 project that processes JSON payloads representing arithmetic operations (e.g., addition, division). Configure the project to route these operations to appropriate SOAP web services based on the specified operation.

In our example today, we’re going to be using the WSO2 demo template.

Step 2: Modify URLs to Point to WireMock Cloud

Update the URLs in your WS02 workflow to route requests to WireMock Cloud instead of the actual SOAP web services. This ensures that all operations are handled by the mock endpoints set up in WireMock.

Step 3: Configure WireMock Cloud Stubs

Next, configure WireMock Cloud to handle requests for the arithmetic operations. Here’s how you can set up some stubs to quickly use with WSO2’s demo app – but your own stubs will, of course, look different:

  1. Addition Stub:some text
    • Create a stub that takes two numbers and returns their sum.
    • Add a special condition to return a fault if one of the numbers is a specific value (e.g., 101).

  2. Division Stub:some text
    • Set up a stub that returns a canned response regardless of the input.

For more help with stubs and WireMock Cloud, check out the WireMock Cloud Academy or reach out to us.

Step 4: Test the Workflow

Run your WS02 workflow and use a tool like Postman or a similar HTTP client to send requests to your workflow.

  1. Addition Request:some text
    • Send a request to add two numbers, e.g., 2 and 3.
    • Verify that the response is as expected (e.g., 5).

  2. Error Handling:some text
    • Send a request with the special fault-inducing value, e.g., 101.
    • Observe how the workflow handles the error response from WireMock, identifying any issues in error handling.

  3. Division Request:some text
    • Send a request for division with any numbers.
    • Verify that the canned response (e.g., 41) is returned as expected.

Get Started 

Integrating WS02 with WireMock Cloud will help you get more out of WSO2 while saving time and money (everyone’s favourite things to save.)

Embrace the power of API mocking with WS02 and WireMock Cloud, and watch your development cycles accelerate and your error rates plummet. Integrate today and start getting higher quality software out the door faster.

If you’re not using WireMock Cloud yet, create your free account here.

/

Latest posts

Have More Questions?