通过JVM参数挂钩

最后编辑了

概述

默认通过提供自定义的Java VM共享库,默认浏览到Java应用程序,Quish Java VM。

The Squish Java VM (in SQUISHDIR\bin\jvm.dll on Windows) is used for hooking Java applications transparently with Eclipse-based applications and for applications which are being run via java..exe, java.w.exe, etc.

If this hooking method does not work (because the launcher does not offer an option to specify the Squish Java VM directory (for Eclipse the -vm option is used) hooking can usually also be managed by providing additional Java VM parameters to the custom launcher.

对于Java或Java.exe

For applications starting java. or java..exe via scripts or batch files you can try to get hooking to work “manually”. In the script or batch file that runs java. (or java..exe on Windows) do the following:

Step 1 - Unset the environment variables JDK_ALTERNATE_VM and _JAVA_OPTIONS before executing Java

适用于Windows:

set JDK_ALTERNATE_VM=
set _JAVA_OPTIONS=

对于UNIX系统上的BASH壳:

unset JDK_ALTERNATE_VM
unset _JAVA_OPTIONS

第2步 - 修改Java如何调用

如果调用如下所示:

java. <all_the_other_parameters>

在Windows上,将其更改为:

java. "%SQUISH_JAVA_DEF_1%" "%SQUISH_JAVA_DEF_2%" "%SQUISH_JAVA_DEF_3%" "%SQUISH_JAVA_DEF_4%" "%SQUISH_JAVA_DEF_5%" "%SQUISH_JAVA_DEF_6%" "-Dsquish.bcel=%SQUISH_PREFIX%\lib\bcel.jar" <all_the_other_parameters>

在UNIX系统上,将其更改为:

java. "$SQUISH_JAVA_DEF_1" "$SQUISH_JAVA_DEF_2" "$SQUISH_JAVA_DEF_3" "$SQUISH_JAVA_DEF_4" "$SQUISH_JAVA_DEF_5" "$SQUISH_JAVA_DEF_6" "-Dsquish.bcel=$SQUISH_PREFIX/lib/bcel.jar" <all_the_other_parameters>

对于Eclipse创建的Eclipse或发射器

创建类似于此的批处理文件或shell脚本:

Windows批处理文件:

set JDK_ALTERNATE_VM=
set _JAVA_OPTIONS=
cd "C:\Program Files\MyApp"
eclipse -vmargs "%SQUISH_JAVA_DEF_1%" "%SQUISH_JAVA_DEF_2%" "%SQUISH_JAVA_DEF_3%" "%SQUISH_JAVA_DEF_4%" "%SQUISH_JAVA_DEF_5%" "%SQUISH_JAVA_DEF_6%" "-Dsquish.bcel=%SQUISH_PREFIX%\lib\bcel.jar"

UNIX shell脚本:

unset JDK_ALTERNATE_VM
unset _JAVA_OPTIONS
cd "/opt/MyApp"
eclipse -vmargs "$SQUISH_JAVA_DEF_1" "$SQUISH_JAVA_DEF_2" "$SQUISH_JAVA_DEF_3" "$SQUISH_JAVA_DEF_4" "$SQUISH_JAVA_DEF_5" "$SQUISH_JAVA_DEF_6" "-Dsquish.bcel=$SQUISH_PREFIX/lib/bcel.jar"

You can also provide these -vmargs in the eclipse.ini file (or in the application’s own myapp..ini file), but some people consider this to be intrusive.

对于NetBeans和Install4J创建的发射器

第1步:创建批处理文件或脚本

在Windows上:

Create a file called myapp._squish.bat and save it in the same directory as the .exe file of your application (e.g. “C:\Program Files\MyApp\bin\myapp_squish.bat”.

该文件应具有以下内容:

myapp..exe "-J%SQUISH_JAVA_DEF_1%" "-J%SQUISH_JAVA_DEF_2%" "-J%SQUISH_JAVA_DEF_3%" "-J%SQUISH_JAVA_DEF_4%" "-J%SQUISH_JAVA_DEF_5%" "-J%SQUISH_JAVA_DEF_6%" "-J-Dsquish.bcel=%SQUISH_PREFIX%\lib\bcel.jar"

当然,您需要更换“myapp”使用启动应用程序的实际文件名。

在Unix上:

Create a file called myapp._squish.sh and save it in the same directory as the file that starts your application (e.g. “\opt\myapp\bin\myapp_squish.sh”.

该文件应具有以下内容:

myapp. "-J$SQUISH_JAVA_DEF_1" "-J$SQUISH_JAVA_DEF_2" "-J$SQUISH_JAVA_DEF_3" "-J$SQUISH_JAVA_DEF_4" "-J$SQUISH_JAVA_DEF_5" "-J$SQUISH_JAVA_DEF_6" "-Dsquish.bcel=$SQUISH_PREFIX/lib/bcel.jar"

当然,您需要更换“myapp”使用启动应用程序的实际文件名。

步骤2:将AUT设置为批处理文件或shell脚本

在测试套件’s settings set myapp._squish.bat or myapp._squish.sh as the Application Under Test.

另外,确保你跑来啜饮’s setup program (SQUISHDIR/bin/squishconfig), and point it to the folder of the JRE that your application is using.

当挂钩仍然失败时

挂钩申请仍然失败时,请检查您的应用程序使用的JRE(参见 查找执行Java应用程序的JRE),跑鳞状’S Setup程序再次并确切地指定它中的JRE。

If hooking still fails please contact froglogic support and attach the .bat file/shell script as well as the file server.ini (Windows: %appdata%\froglogic\Squish\ver1; Unix: $HOME/.squish/ver1) to your email.