Generate Test data for your Groovy scripts in CPI

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:

  • Camel  and download the latest release of Camel to get the Apache Core, this contains the Camel Attachment
  • CPI APIs download the Generic API and the Scripting API.
  • Groovy JSON parser

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.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *