1
votes

I have a SoapUI project, and an external custom Java library of utility methods that I've written for using in Groovy scripts.

In the Java library, I have a particular utility class, com.custom.acmeproject.ContextProperties, that has utility methods for changing the values of properties in the context of groovy scripts. Using this class, I can do the following in a groovy script file:

import com.custom.acmeproject.ContextProperties;

ContextProperties.increment(context, "messageId");
  • However, I'd like to be able to write that script without the import statement. Is there a way I can setup my SoapUI project to automatically import this class into all of my Groovy scripts?

    I would prefer to be able to do this just for this one SoapUI project, without affecting other SoapUI projects; however, if this is not possible, I'll take a solution that will affect all my projects.

  • Because this SoapUI project is automated using a maven build run in
    Jenkins, I need this solution to work both for running the tests in
    the SoapUI IDE (I'm using SoapUI NG Pro), and for running the tests
    using the soapui-pro-maven-plugin.

  • Preferably, any solution should also work without having to
    manually configure Groovy settings outside of SoapUI across multiple environments.

Is what I want to do possible?

1
Have a look at this: mrhaki.blogspot.ca/2011/06/groovy-goodness-add-imports.html You might be able to do that as part of the Project setup script. - SiKing

1 Answers

0
votes

I understand that you completely aware that how an external library is written, compile, build jar file and placed under SoapUI Pro and same is the procedure for SoapUI Open Source edition too.

I also understand that you also know how to code it in java, and aware of package for organizing the class files better, as well as that also convey by whom (individual or an organization) the library was created, and standard practice. But that can be optional.

However, I'd like to be able to write that script without the import statement. Is there a way I can setup my SoapUI project to automatically import this class into all of my Groovy scripts?

So as you mentioned in the question, in order to avoid import in the Groovy Scripts, use one of the blow:

  1. do not use any package for the library classes, and recompile, build jar and place under soapUI, and restart to take effect. Then you should be able to call ContextProperties.increment(context, "messageId")
  2. use fully qualified class which does not need an explicit import like com.custom.acmeproject.ContextProperties.increment(context, "messageId")

I would prefer to be able to do this just for this one SoapUI project, without affecting other SoapUI projects; however, if this is not possible, I'll take a solution that will affect all my projects.

The libraries are loaded into SoapUI, and that is not specific / limited to a project and is applicable for all the project. But I am sure, there will not effect unless those are used in multiple project and not changing as per the updates. Otherwise, it should be ok.

Because this SoapUI project is automated using a maven build run in Jenkins, I need this solution to work both for running the tests in the SoapUI IDE (I'm using SoapUI NG Pro), and for running the tests using the soapui-pro-maven-plugin.

Yes, if you place the library files under required location, it works the same way. Have you tried and found any issue in doing so?

Preferably, any solution should also work without having to manually configure Groovy settings outside of SoapUI across multiple environments.

What changes do you feel to configure Groovy settings? There isn't any thing like that. If you find so, just update it. If the SoapUI project is running smooth in the tool which has Groovy scripts, then the same should be running smoothly from all the channels i.e., running command line, using ant, maven, jenkins etc.

Does it sound good?