Skip to Content

(How) Do You Test Your Groovy Scripts?

It all started with a basic (yet very important) question:-

Do you test your Groovy scripts?

Or more accurately, How do you test your Groovy scripts?


if(!software.isTestable()) {
  software = null;


WebUI, SchmebUI

If we leave it to chance, life with SAP Cloud Platform Integration would be colorless like this:-

How do you even work with such an editor in this day and age… let alone test anything on it??

Well, on occasions like this, pardon me, but I would rather take chance into my own hands, and have a bit more color in my life (code completion and on-the-fly syntax check, anyone?):-


Ok, Eclipse is Groovier, but how do we test?

Well, before Vadim Klimov took matters into his own hands, we would have had to rely on creating our own versions of Cloud Integration’s libraries using techniques like Reflecting on the Message class by Morten Wittrock.

But fortunately for all of us, Vadim bravely trailblazed the way forward with Dark Side of Groovy Scripting: Behind the Scenes of Cloud Integration Runtime.

Before you even continue, you will really need to read thoroughly the above blog, as that is both prerequisite and key.

You will also need the below:-

Eclipse Neon (What do you mean you don’t have it yet?!)

Groovy Eclipse (Eclipse is Groovier with Groovy)


Let the testing begin!

All ready now?

Let’s first create a Groovy Project.


After that, let’s play nice and have a decent package for your Groovy scripts. You will need two scripts here:-

  • The Groovy script that will be used in your integration flow
  • The script that will test the above script

For simplicity, I will just copy over the default Groovy script that is generated from Cloud Integration, namely script1.groovy below.

For the other script, I will just create a new Groovy class named GroovyScriptTest.groovy.


All good so far? Let’s replace the code in the testing class with the following code. It’s just a very basic logic to showcase the approach. Essentially what it does is:-

  • Load the script to be tested
  • Initialize the message to be passed into the script
  • Execute the script to be tested
  • Display the results via console

Nothing fancy, but I encourage you to at least try to understand what each part does (there’s always Google if you need any help!)

package com.equalize.groovy.testing


// Load Groovy Script
GroovyShell shell = new GroovyShell()
def script = shell.parse(new File("src/com/equalize/groovy/testing/script1.groovy"))

// Initialize message with body, header and property
Message msg = new MessageImpl()
msg.setBody(new String("Hello Groovy World"))
msg.setHeader("oldHeader", "MyGroovyHeader")
msg.setProperty("oldProperty", "MyGroovyProperty")

// Execute script

// Display results of script in console
println("Body:\r\n" + msg.getBody())

def displayMaps = { String mapName, Map map ->
	println mapName
	map.each { key, value -> println( key + " = " + value) }
displayMaps("Headers:", msg.getHeaders())
displayMaps("Properties:", msg.getProperties())


You will now notice some syntax errors in both scripts, the most noticeable one would be for the following elusive class:-

Now this is where the fun really begins. Did you bother to read Vadim’s blog? You will need it now. Go hunt for the required JAR file, then add it to the project’s build path.

Once you got all the syntax error sorted, try executing the testing script:-

Right Click > Run As > Groovy Script

Oh no! More errors – looks like some other JAR files are required during runtime. So keep doing the below:-

Hunt, Add, Test, Repeat

Finally, when all is in place, you will be rewarded with the below screen in the console output 🙂


Voila! Now, this is how you test your Groovy scripts!


Update 20 Oct 2017

Interesting observation – if you head over to (, there is a recently added section detailing how you can add the JAR file for the Message class into your Groovy project 🙂

Another interesting observation is that it does not tell you where to download the file! :p


Update 5 Jan 2018

Further interesting observation. The online documentation has been updated with details on how to download the JAR file for the above mentioned elusive class, now termed the Script API Methods.


Basically, you just have to get it from the SAP Development Tools page


The problem with this approach is that it only gives you a real bare bones JAR file.


IMHO, if you want to do any serious development/testing work locally in Eclipse, this JAR file is insufficient and not worth the effort.

You must be Logged on to comment or reply to a post.
  • Nice workaround. much needed one. This reminds me stand alone java mapping testing.

    I am not yet into HCI . Had a little chance to play with HCI long back.


    message mapping test is available in HCI. It would be nice if SAP does the same with scripts also. and of course changing the colorless editor too.



  • Hi @Eng Swee Yeoh,


    It's a great blog and very useful for us to work on groovy scripts in HCI. I see there is a link provided in SAP Help portal ( detailing how we can add the JAR file for the Message class into your Groovy project but the link to download the jar is missing.

    We are working on Groovy script for our complex logic's which needs to be tested constantly for achieving the results. Can you please share the link to download jar file for class ? It will be really helpful.




    Rajesh N


      Hi Rajesh


      You will really need to read the blog properly - as it is really obvious, I won't spoil the fun for you.



      Eng Swee

      • Hi - Thanks I followed the blog ( ) and able to fix it.



        Rajesh N

  • Hi@Eng Swee Yeoh

    Thanks for your post! It's great that I could do some local test!

    I have to ask a similar question with Rajesh's.  The syntax is fixed by import jar file as you suggested, however, I can find no hints for  Seems this class is not in the cloud.integration.script.apis-1.36.1.jar file. Could you advise a bit?


    Happy new year~


    • Hi Rong Wei , Former Member ,


      Please see the updated section of my blog (at the end). I wouldn't suggest using the JAR file provided by SAP in the Development Tools page. Instead, please follow the steps listed in this blog (in particular Hunt, Add, Test, Repeat) and also the details from Vadim's blog.



      Eng Swee

    • Hi Rong,

      Have you solved you issue? I meet the same situation, no hints for .


      Best Regards


  • /
    • You are on the right track, but you probably missed out the Repeat step of "Hunt, Add, Test, Repeat" step. Keep going until you get all the necessary JAR files - there are quite a few of them required.

      • Hi,

        It is not very clear where to hunt, I tried to download the JAR for "org.apache.camel.TypeConversionException", but it does not exist in CPI :S  , any idea?.


        Kind Regards.


        • Hunt the same way you got the JAR file for the class.

          If you are not sure where to hunt, how did you get that JAR in the first place?

          • Hi,

            I know how to hunt( identify missing class, run the IFlow in CPI to extract the corresponding JAR and import the JAR in my project, test and repeat), but I can't identify the missing class ( I thought it was this "org.apache.camel.TypeConversionException", but I can not download the JAR from CPI, I executed the IFlow for it but it does not return anything), thanks for the replies and your time 😉 .


            Kind Regards.


          • Class org.apache.camel.TypeConversionException is correct, and you should be able to find it in JAR file in the current version of the tenant.


          • Hi,

            Thanks, but I solved it with CPI libraries from SAP PO 😉


            1. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\
            2. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\\lib\
            3. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\
            4. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\org.apache.camel-camel-core-2.17.4-sap-05.jar
            5. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\
            6. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\
            7. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\
            8. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\
            9. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\org.slf4j-jcl-over-slf4j-1.7.5.jar
            10. <DISK>:\usr\sap\<SYSID>\J00\j2ee\cluster\bin\ext\\lib\org.slf4j-slf4j-api-1.7.5.jar


            Kind Regards.



          • /
  • Hi Eng Swee,


    Thanks for the journey and forcing us to do the work 🙂

    I think I have all the external libraries loaded in eclipse, 10 in total, all retrieved from CPI.

    Now I get this error:

    Caught: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.runtime.InvokerHelper$1.processData() is applicable for argument types: ( values: []
    groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.runtime.InvokerHelper$1.processData() is applicable for argument types: ( values: []


    Is there still something I am missing? Below is what I have now




    • Hi Tom


      I'm glad you enjoyed learning how to fish!


      Your libraries look fine, so I don't think there's any missing there. Can you show a screenshot of your project structure as well as the code for GroovyScriptTester.groovy?



      Eng Swee

        • When I try to run it in the groovy console I get this error:

          groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.runtime.InvokerHelper$1.processData() is applicable for argument types: ( values: []



  • Hi, I have tried pretty much everything, google, blog search and could the package for below import.

    It is not part of SAP API JAR.

    Any help.


  • The reason I need this JAR is to be able to create a message for testing. Unfortunately there is no other way to test the script in eclipse unless I am able to create a new message and pass it to the function.

    Any help is appreciated.




  • Hi Eng,

    Really enjoyed this post, and thought about automating the approach to create the template based on real values. We have added the functionality to the Figaf IRT tool that allow you to test CPI also. So now you can just select a step and then export the content in your format.

    I have chosen to add a mock class for the message implementation to avoid having to go thru all the libraries as you outline here.

    I did though find that instead of using the "Dark Side", you can just have a look into the SCA file for CPI on the PI, here I would imagine that you will find all the relevant jars. It is the one starting with SAPXIIGWAPPL

  • /
  • Hi @Eng Swee Yeoh;

    Great blog and it was working well for me two weeks ago. Unfortunately I didn't download all the required jar files then. It seems like in one of the recent updates the library structure has changed. Now looking for the jara file for returns following

    JAR file containing class file" jar:bundle://561.0:0/!/ instead of the actual jar. Do you know of another way to get the jar files?



      • Hi Eng Swee;

        Thanks for the quick reply and your suggestion. I created a similar script based on Vadim's blog

        import java.util.HashMap;
        def Message processData(Message message) {
        String dirInstanceRootPath = "/usr/sap/ljs/";
        StringBuilder builder = new StringBuilder();
        File dirInstanceRoot = new File(dirInstanceRootPath);
        dirInstanceRoot.eachDirRecurse { 
            builder << "${it.absolutePath}\n";
            try {
                File dirPlugins = new File("${it.absolutePath}");
                dirPlugins.eachFileMatch(~/.*\.jar/) { 
                try {
                    builder << "${}\n"; 
                catch (Exception ex) {
                    builder << "can't find file";    
            catch (Exception ex)

        Looks like they are not using the individual jar files anymore 🙁



        • It looks like it's just a different way of packaging the libraries. You still can get to them in a slightly different manner.


          From the earlier response "jar:bundle://561.0:0/!/", it is located in bundle 561.


          So you just go to the following location for bundle 561, and extract its JAR file.


          • Hi Eng Swee and colleagues,

            It seems that the location of the cache folder mentioned above has changed in the Cloud Foundry version of CPI (at least for the Trial version). I could find the bundle folders at:





  • Hi Thomas,

    Once you got the new path for the .jar files /usr/sap/ljs/data/cache/bundle561/version0.0/bundle.jar, how did you get the files?



  • Hi Eng,


    I followed Vadim's post and I was able to get the jar location successfully but when I tried the Jar content, I am having issues.


    To start with I was trying your blog to modify the header values. And I got stuck here with class not found exception for ""



    So then I started to dig into the Jar using Vadim's post for retrieving the Jar content using the following iflow and the groovy script

    Groovy Script


    When I try to fetch the base 64 encoding of the JAR by doing a GET query from the POSTMAN this is what I get. "An internal server error occured: java.lang.IllegalArgumentException: URI is not hierarchical" I am struggling to understand what this error means. Please let me know if you have any suggestions?




    • Hi Kaylan,

      if you still need some help I'd recommend to replace the line

       File classFile = new File(classFilePath);

      with the following line of code:

       File classFile = new File("/usr/sap/ljs/data/cache/bundleXXX/version0.0/bundle.jar");

      Just replace bundleXXX with the one, where the class "" is contained.





  • Dear All

    From the time this blog is written, the information provided can now be considered obsolete.

    Please follow the below instructions on the SAP Development Tools site, and the library errors will disappear in Eclipse.

    The pre-requisite for all the script libraries to work is to install the additional oxygen plugin.

    To download the most recent Eclipse version, as of April 2021 - the most recent available Eclipse version is 2021-03 -link-

    SelectEclipse IDE for Java Developers as the software option to install.

    Install and Launch the software.

    On the next screen, you will find the help menu, where you will also get the option to install new software. Paste the oxygen URL here as per the SAP Tools Development site.

    Follow the instructions in the procedure section to finish the installation of the oxygen software.

    The next step is to download the generic and the script API from the script API section. Note that these libraries have to be a part of the Groovy project for CPI and hence have to be loaded within the groovy project.

    Download both JAR files and follow the below steps.

    1. Create a new groovy project. Select File - Project - Groovy -Input Project Name and add the location of the  folder where you intend to save your groovy scripts
    2. Click on next
    3. In the build path, select libraries and add new external JAR files in the classpath section.

    Most CPI Libraries issues will be fixed with the above, including errors that are due to the lack of oxygen software installation.