Parameters in LoadRunner Java protocol scripts
When working with any kind of LoadRunner Java-based vuser type, any string that appears within the script may be parameterised. This differs significantly from all of the C-based vuser types, where only functions that are labelled as “parameterizable” may be parameterised without explicitly calling lr_eval_string().
This is a simple example of parameterisation with a Java-based script:
lr.save_string("jumped", "myParam");
String message = "the quick brown fox <myParam> over the lazy dog";
lr.output_message(message);
Rather than trying to do something that is theoretically impossible such as overloading the String class to handle this extra functionality, the LoadRunner developers did the simplest thing that could possibly work. They added a pre-compilation step that does a simple find-and-replace, with every <Parameter> automatically replaced with “+lr.eval_string(“<Parameter>”)+”.
lr.save_string("jumped", "myParam");
String message = "the quick brown fox "+lr_eval_string("<myParam>")+" over the lazy dog";
lr.output_message(message);
The only unintended side-effect of this is that it now makes it possible to get a stack overflow while “compiling” (see my Introduction to LoadRunner CORBA Vusers for a work-around).
May 3rd, 2005 at 7:21 pm
Now that I think about it, you could easily implement the same thing with a preprocessor macro for C-based LoadRunner scripts.
July 19th, 2007 at 12:46 am
Great Detail Stuart, Very useful info:-) appreciate your putting the article.
Thanks
July 19th, 2007 at 12:46 am
Great Detail Stuart, Very useful info:-) appreciate your putting the article.
Thanks
October 8th, 2008 at 9:19 pm
Does LR9.1 supports JDK1.4.2_08? As my Java Cleint Server application is developed in JDK1.4.2_08 environment.