| || |
User Bradley, Kelly (firstname.lastname@example.org) posted:
I'm new to the mailing group so please excuse me if this is a FAQ.
I've tried using the JDC (Java Direct Connection) example in the book.
I tried it when I had WinRunner 6.0 and couldn't get it to work and
thought maybe it was a new feature that would work when I upgraded to
7.0. I now have 7.0 with the Web Test and Java plug-ins and still no
Can anyone provide me with a working example? (Full Java class source
and full WinRunner script to eliminate any error on my part please.)
In order to work with JDC you need three things
1. A running Java AUT (application under test).
2. A class implementing your static methods (That should be loaded in the bootstrap classloader using -Xbootclasspath).
3. WinRunner script to perform JDC registration and calls.
Attached is a (very) simple application (#1) and the sample class and script from the Java Add-In online guide (#2 and #3)
Just launch the sample app using java.exe -Xbootclasspath/p:. MyApp (Assuming the JdcExample class is in the same folder)
and run the script.
# define "extern" declaration
extern int jdc_simple_call( in string str);
extern int jdc_out_par_call( in string str1, out string str2<256>);
# register JDC classes
# make sure the classes are in the classpath
# connect to the AUT
if (rc != E_OK)
pause (" Error: Couldn’t connect to AUT\ n Check that the AUT is loaded!");
# call JDC functions - this will print the parameter to the Java console
r1= jdc_simple_call(" my string");
r2= jdc_simple_call( 256);
# this will put the Upper Case form of the parameter in the UpperCaseParam var.
r3= jdc_out_par_call(" my string", UpperCaseParam);
I spent a day getting JDC (Java Direct Calls) to work. At the end the key to making it work turned out to be to put *all* classes into the bootclasspath.
Since WinRunner 7.0 Java Add-In java_activate_method is much more flexible then previous versions and allows calling methods with complex objects and not just simple variables (and get complex return values as well), I find JDC less useful then it used to be in the past.