Using Java Code for Load Testing

The Silk Performer Java Framework allows you to model virtual users in Java code, access useful functionality from Silk Performer's runtime environment, and it helps you to generate the necessary BDL stub code where necessary.

There are a number of ways to integrate your Java code. The diagram below shows the options you have:

  • Your first option is to script Java code within your preferred Java IDE.
    • When you work with Eclipse, you can use the Silk Performer Eclipse plugin. It lets you export your code wrapped in a Silk Performer Java Framework project and open it in the Workbench.
    • When you work with another Java IDE, first build .jar files from your source files. Then use Silk Performer's import tools: the JUnit import tool for JUnit tests and the Java Class import tool for generic Java code. This way Silk Performer generates all necessary stub code for you.
  • Your second option is to write Java code directly within the Workbench. Create a Java Framework project and write your code into the .java file, which is automatically created, using Silk Performer's editor. Silk Performer offers syntax highlighting and allows to compile the Java code using the configured Java Development Kit within the Workbench.
  • Your third option is to create Java code within Java Explorer. Java Explorer lets you create code visually, so you do not have to write your code manually. Transferring the Java code from Java Explorer to the Silk Performer Workbench is easy due to the seamless integration of the two solutions.

Depending on how you import Java code to the Workbench, Silk Performer creates different sets of files within the Java Framework project. This results in different call sequences. The diagram below shows three types of call sequences:

  • Sequence 1 is the default call sequence. Note that the communication between BDL and the Java wrapper is bidirectional. This means that you can call Java code from the .bdf script and Silk Performer functionality from the .java script. Code within the .java file can then call code from further classes or .jar files.
  • Sequence 2A applies when Java code is imported using the Java Class Import tool. In this case, Java code that is part of the .jar files is directly called from BDL.
  • Sequence 2B applies when JUnit tests are imported using the JUnit Import tool. Java code within .jar files is called from BDL - just like in sequence 2 A. However, in this case the .jar file consists of the unit test (which itself is a .jar file), which again can call Java code from other .jar files.