Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Call Java Function in JAR File

Speedy993
Speedy993 Posts: 71

I have a java function outside of the message flow I am testing that takes a string, processes it, and then returns another string. I need to call this function and store the returned string for use in another test. Do I want to use the External Tool, Extension Tool or something else? How do I connect to the jar file?
Thanks!

Comments

  • jakubiak
    jakubiak Posts: 813 admin

    You can add the jar file to the System Properties preferences to register it with SOAtest. Then you would use an Extension Tool to call the Java function. As far as storing the returned string, there are a couple of ways you could do that. One way is to create a test variable in your test scenario, and then in your Extension Tool call the SOAtest Java API method to set the value of the test variable. Another way is to return the value from the Extension Tool method wrapped in XML tags (something like "value to return") and then use an XML Data Bank to store the value.

  • Speedy993
    Speedy993 Posts: 71

    Thanks for your reply @jakubiak. I have added the jar file to the System Properties and reloaded the classes. I have added a data source column as input and added the jar file as the Java class but I am not seeing any of the methods appearing in the dropdown. Is there something I am missing?
    Thanks!

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    I would use Groovy. Just write a small method in Groovy to call the java method and store the result in a test variable.