← Blog

Generate test data for your Groovy scripts in CPI

How Figaf generates test data from SAP CPI traces so you can run and test your Groovy scripts locally in Eclipse or IntelliJ.

November 15, 2018 · 2 min read

Update 19 June 2020: We have been improving on this function. See how you can get to debug and test your SAP CPI Groovy scripts much easier with the latest iteration with Git Integration.

I wanted to develop some Groovy scripts but it is a little cumbersome to do it in CPI because you need to deploy, activate the script and then look at the trace. This takes quite a bit of time. I found Eng Swee Yeoh’s blog (How) do you test your Groovy Scripts. Here he shows how you can create a script to run your Groovy Scripts as on CPI, so you can do it in Eclipse or IntelliJ.

I just hate the manual job about setting up the correct content for a test case. So because we had the content needed in Figaf DevOps Suite, we could automate the process.

We have added an implementation of the SAP CPI Camel Message class so users could create it. We have included it into the script, so you only need the public Camel Core. The implementation may not be fully complete but it is a lot faster than downloading all the required jar files as described in Yeoh’s blog.

To view a demo of how this works, check the following video:

Watch on YouTube IRT Develop CPI Groovy development

Download the required libraries:

If you use Eclipse you can create a Groovy Project, then add the above jars. Then add the current Groovy script and the generated script to the project. You will need to change the location of the CPI Groovy script so it matches. Once you save the payload in an Expression use the command ${bodyAs(String)}, then you will get access to the payload.

If you have ideas for improvement, let us know on LinkedIn.

Known limitations: For some headers/properties that are saved in org.apache.camel.converter.stream.InputStreamCache Figaf DevOps Suite cannot access the payload. You need to convert the payload to String before adding it as an attribute if it is binary.

start a free trial of Figaf DevOps Suite and try it out with your system.

This post covers these products

Capabilities covered

More from the blog

All posts →

See this working in your landscape

No credit card required.

Integration cost calculator →

Start your free trial

No credit card required

Try Figaf DevOps Suite free for 30 days. It takes less than an hour to get started, and we send everything you need by email.

Join our newsletter

Get the latest about Figaf, SAP and anything relevant to SAP integration, every week in Figaf Weekly.