Sometimes, the functionality of pre-installed libraries might prove to be insufficient for your needs. In this case, you can load an external Java library and use classes from it. You can write and compile a library yourself or use a third-party one.
Loading external libraries
To use an external Java library in ReadyAPI:
-
Place your .jar to the <ReadyAPI>\bin\ext folder. The next time you start ReadyAPI, it will load the file as an external Java library that can be called from your scripts.
Tip: If your external Java library references another Java library, put the latter in the <ReadyAPI>\bin\ext folder as well. If you address an external library in a virtual service that will be run in VirtServer, place the library in the <VirtServer>\bin\ext folder.
If you address an external library in a load test that will be run on a LoadUI agent, place the library in the <LoadAgent>\bin\ext folder.
You can use
soapui.ext.libraries
variable to change the path where ReadyAPI searches for external JAR files. Configure it by setting the variable to the selected path in vmoptions. -
Import the class to your script and call the method you need. Here is an example of using a simple class from the imported .jar file:
Groovy
import Sample // Import the Sample class
Sample.add(1, 2) // Use the add method from the Sample class