Introduction¶
In cases where hooking Java applications fails despite the correct set up of Squish (run Squish's setup and choose the JRE (Java Runtime Environment) which is used by the AUT (Application Under Test) (see Finding the JRE that executes a Java application ) it is worthwhile to try this alternative hooking approach which does not use the Java Agent functionality of the JVM (Java Virtual Machine) and which Squish uses by default.
Hooking without Java Agent¶
Step #0 - Set up Squish
Unzip Squish ZIP package.
Run
<SQUISH_DIR>/bin/squishconfig --java=<JRE>
.Replace
<JRE>
with the directory of the JRE (Java Runtime Environment) of the AUT (Application Under Test) (see Finding the JRE that executes a Java application ).
Step #1 - Recreate <SQUISH_DIR>/lib/squishrt.jar
On Windows:
Start cmd.exe (Start button > Run..., enter "cmd.exe" (without quotes), press RETURN/ENTER).
In cmd.exe execute:
set _aut_jre_path=<AUT_JRE_PATH> cd "<SQUISH_DIR>" java -cp lib\squishjava.jar;lib\bcel.jar com.froglogic.squish.awt.FixMethod --add-awt-classes "%_aut_jre_path%\lib\rt.jar;lib\squishjava.jar" lib\squishrt.jar
In cmd.exe
Step #2 - Ask your developers for a shell script (Unix) or batch file (Windows) to start the AUT via "java"
Such a batch/script file could look similar to these examples:
Unix shell script example:
#!/bin/sh cd "/var/opt/MyApplication" "<AUT_JRE_PATH>/bin/java" -jar myapplication.jar
start_myaut.sh Windows batch file example:
cd "C:\MyApplication" "<AUT_JRE_PATH>\bin\java" -jar myapplication.jar
start_myaut.bat
Step #3 - Modify the shell script/batch file from Step #2 to unset environment variable JDK_ALTERNATE_VM and use environment variables SQUISH_JAVA_DEF_1, SQUISH_JAVA_DEF_2, SQUISH_JAVA_DEF_4
Unix shell script example:
#!/bin/sh unset JDK_ALTERNATE_VM cd "/var/opt/MyApplication" "<AUT_JRE_PATH>/bin/java" "$SQUISH_JAVA_DEF_1" "$SQUISH_JAVA_DEF_2" "$SQUISH_JAVA_DEF_4" -jar myapplication.jar
start_myaut.sh Windows batch file example:
set JDK_ALTERNATE_VM= cd "C:\MyApplication" "<AUT_JRE_PATH>/bin/java" "%SQUISH_JAVA_DEF_1%" "%SQUISH_JAVA_DEF_2%" "%SQUISH_JAVA_DEF_4%" -jar myapplication.jar
start_myaut.bat
Step #4 - Use the batch file/shell script from Step #3 as AUT in the Squish test suite settings.