Join Wintertainment 2021 to share your stories, have fun, earn community badges, and more!

Pre-installed Script Libraries

Applies to ReadyAPI 3.10, last modified on November 23, 2021

ReadyAPI is shipped with a number of Java and Groovy libraries that you can use in your scripts right away. Some of the libraries are imported in all the editors by default; others have to be imported first.

Libraries imported by default

A number of basic Java and Groovy classes are imported by default in all the scripting editors in ReadyAPI. They are ready to be used at all times. These are:

  • java.io.*
  • java.lang.*
  • java.math.BigDecimal
  • java.math.BigInteger
  • java.net.*
  • java.util.*
  • groovy.lang.*
  • groovy.util.*

Libraries ready for import

There are more libraries that are shipped with ReadyAPI but not imported to the scripting editors by default. You can import them by using the import <library> command. Here are some of the libraries:

  • java.nio.* – Used for low-level I/O operations.
  • javax.jms.* – A common way to work with JMS.
  • groovy.json.* – Used for parsing and generating JSONs.
  • groovy.xml.* – Used for parsing and generating XMLs.
  • groovy.sql.* – Used for working with JDBC.
  • org.apache.activemq.* – Used for actions with ActiveMQ JMS.
  • org.apache.commons.* – Contains many reusable Java components.
  • org.apache.http.* – Used for working with HTTP.

Here is a simple example of a script that uses ready-for-import libraries to copy a file. You can run it in the Groovy Script test step editor:

Groovy

//Import libraries for working with files
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;

//Create objects for the copied file and the target file
Path source = Paths.get("C:\\Users\\elle.stevenson\\Desktop\\test.xlsx");
Path target = Paths.get("C:\\Users\\elle.stevenson\\Desktop\\out\\copied.xlsx");

//Copy the file
Files.copy(source, target)

See Also

Script Libraries
Scripting

Highlight search results