Generate Test data for your Groovy scripts in CPI

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 the look at the trace. This takes quite a bit of time. I found Eng Swee Yeoh 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 IRT 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 is described in Yeoh’s blog .

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

 

Download the libraries required:

If you use Eclipse you can create a Groovy Project, then add the above jars.  Then add the current groovy script and the generated to the project. You will need to change the location of the CPI grovy 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 please share. 

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

Download the IRT application and try it out with your system. It is free for 10 Interfaces.

Simplify your SAP Integration in under 10 minutes with Figaf DevOps Suite on Cloud.

 
No credit card is required. 30 days free trial.

Latest Articles