Editing Java Scripts using Eclipse
- Syntax highlighting
- Code assist — Eclipse suggests and can auto-complete variable, method, and class names as you type
- Automatic building
- Javadoc support — Hover over a variable, method, or class name, and Eclipse shows relevant help documentation in a pop-up window
You can download Eclipse from the Eclipse downloads page. There are several versions available. For developing Web Java VU scripts, we require Eclipse Luna, version 4.4 or later.
In the current version, Eggplant Performance Web Java only supports a 32-bit JVM for running scripts. Users should install the latest Eclipse IDE for Java Developers, then make sure it uses the 32-bit JRE.
Note that if a JRE is already installed on your system, it might be a 64-bit version, which is currently not supported. To ensure a 32-bit JRE is used, update your eclipse.ini, which is located in the Eclipse installation directory, by adding the following to the existing list of arguments:
C:\Program Files (x86)\eggPlant Performance\re\java\jre1.8.0_25\bin
Launching Eclipse from Eggplant Performance Studio
With a project open in Eggplant Performance Studio:
- On the Build menu, click Start IDE, and then click Start Project IDE.
OR click the Start IDE button on the toolbar.
If you did not configure an IDE, a message appears asking you to locate an IDE.
- Click Yes, and then navigate to the directory where you unzipped Eclipse.
- Select eclipse.exe, and then click Open.
Studio installs the Eggplant Performance Eclipse plug-in into the /dropins directory of your Eclipse installation, and launches Eclipse.
If you have previous experience using Eclipse, you might be wondering which workspace directory Eclipse will use. When you launch Eclipse from Studio, Eclipse will use a default workspace, which is located within the Eggplant Performance workspace directory structure.
Managing IDE settings
On the Tools menu, click Preferences.
- In the Eggplant Performance Studio Preferences, select Compilers and IDEs from the list on the left.
- Under Java, specify a direct path to Eclipse, or use the associated browse button to locate the application.
- (Optional) Specify a compiler if necessary.
Creating Eggplant Performance Projects in Eclipse
The Eggplant Performance Eclipse plug-in enables you to edit Web Java VU scripts using Eclipse. An Eclipse project is created, which links to an Eggplant Performance project in your Eggplant Performance workspace, containing the Web Java VU scripts.
- On the Build menu, click Build.
OR on the toolbar click Build.
When you launch Eclipse from Eggplant Performance Studio, an Eclipse project is automatically created for the Eggplant Performance project currently open in Studio. Inside this project you will find the Web Java VU scripts that have been created or generated in Eggplant Performance Studio.
If it doesn't already exist, Eclipse creates a project for the specified Eggplant Performance workspace too. Inside this project you will find code for the custom VUs that exist in the Eggplant Performance workspace.
In the Eggplant Store Demo example workspace, each of the Web Java Virtual User scripts are defined as classes which extend eggPlantStoreDemo_java.MyJavaWebVUScript. In this base class is a method named getVU() which returns an object of type eggPlantStoreDemo_java.MyJavaWebVU. This class defines methods that are useful for interacting with the EggplantStore Demo website, and can be re-used in many scripts, such as findFirstSearchMatch() as used in the Search Virtual User script below. Press F3 while the cursor is in a method name and Eclipse will show the code where that method is defined.
If you hover over an error or a warning in the code editor, Eclipse suggests options for automatically fixing the error or warning. Click the link and the action will be carried out.
Creating Eclipse Projects Manually
In most cases, Eclipse projects are created automatically when you launch them from Eggplant Performance Studio. However, there is a wizard to create Eclipse projects from a specific Eggplant Performance workspace and Eggplant Performance project, which you can use as described below:
- On the File menu, click New, and then click Project.
OR, if the workbench is visible, on the toolbar click New Project.
- In the New Project window, expand Eggplant Performance in the Wizards list, and then click Eggplant Performance Project.
- Click Next.
- Select the Eggplant Performance workspace and Eggplant Performance project from the lists, and then click Finish.
Developing Web Java Virtual User Scripts in Eclipse
Eclipse has content-assist to speed up scripting and reduce typing errors. This means that as you type code, Eclipse suggests variable or method names that you might be trying to use, and you can press Enter for Eclipse to insert the remaining characters automatically. To bring up the content-assist menu when it is not visible, press Ctrl+Space.
Eclipse also shows javadoc documentation for classes, methods, and variables when using content-assist, and also when the cursor is hovered over a class, method or variable name in the code editor.
Building and Running
By default, Eclipse builds the Eggplant Performance project code automatically whenever a script is modified and saved, by using the build.xml Ant file present in the Eclipse project. This means that you don't have to do anything extra before running a test using Eggplant Performance Test Controller.
To disable automatic building in Eclipse:
- On the Project menu, click to remove the check mark by Build Automatically.
In this case, the project must be built manually before a test can be run:
- On the Project menu, click Build Project.