LoadRuner Java programming

772 views
Skip to first unread message

André Castro

unread,
Nov 12, 2010, 8:41:51 AM11/12/10
to LoadRunner
Hey!

I'm used to work with LoadRunner in last year and now we are migrating
our application. We will use DOJO library on the frontend and cause
this, I'm changing the C scripts to Java, since its better to
manipulate JSON objects and access other stuff using XPath.

Have here someone experienced on LR using Java?
I'm using the Eclipse IDE and I'm facing some issues to make the
lrapi work fine. Actually I'm looking for a JAR file of this library.
To import in my project and can use it on the scripts.

I tried to import all class folder but it isn't work like I wanna.

Any help or idea will be appreciated!

Tks

André Castro

James Pulley

unread,
Nov 12, 2010, 8:48:11 AM11/12/10
to lr-loa...@googlegroups.com
Why would you not develop your Java Virtual User Scripts in VUGEN?
What prior art suggests that Eclipse is a better model for LoadRunner
Java Virtual User development versus VUGEN?

James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix

Andr Castro

unread,
Nov 12, 2010, 10:20:29 AM11/12/10
to lr-loa...@googlegroups.com
Hey James!

I'm using Eclipse cause I think it's a better IDE than the vUgen. To develop, test and debug the Java code.
I can to model and code all classes, attributes and all the stuff. Once done and working on the Eclipse, I just need to export it (as a JAR, for example) to vUgen and make simple method calls there to have the posts (since I'm working on a WEB App).

I think it's a smart solution, isn't? :)

Tks!

André Castro





2010/11/12 James Pulley <loadrunn...@jamespulley.com>
--
You received this message because you are subscribed to the Google "LoadRunner" group.
To post to this group, send email to LR-Loa...@googlegroups.com
To unsubscribe from this group, send email to
LR-LoadRunne...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/LR-LoadRunner?hl=en

James Pulley

unread,
Nov 12, 2010, 10:50:53 AM11/12/10
to lr-loa...@googlegroups.com
Don't bother trying to integrate with the LR Java API/classes until you
get to VUGEN. While it seems hypothetically possible to integrate with
inside of eclipse, I have never observed a successful out of VUGEN
integration with the LR Java components. This may mean that you will
need to adjust your code development model based upon what you wish to
time inside of your script with a scant shell of a script in a VUGEN
Java virtual user containing timing markers and then referencing your
externally developed Java code where appropriate.

James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix

Andr Castro

unread,
Nov 12, 2010, 11:01:16 AM11/12/10
to lr-loa...@googlegroups.com
I'm able to use it. But separately. 
I made a Class (called Post) with all LR calls inside it. 
So, this class instantiate the all the others (application classes) that contains the business rules. I was just trying to keep all the classes together on the Eclipse.
But as you said, I thnik the only way is to keep the Post class on the vUgen and all the other in a JAR file as I was doing.

BTW, tks for the informations.

Andr Castro

unread,
Nov 12, 2010, 1:58:41 PM11/12/10
to lr-loa...@googlegroups.com
So, I'm migrating all my classes to LR vUgen. I'm facing an issue regarding the files.
I added the file to Script, but when I try to use it, I'm having the following error:

Report.java file does not contain class Report
Please remove or make sure it appears in the correct subdirectory of the classpath.
private Report report = new Report();
       ^

And "Report.java" have the Class, as you can see here:

public class Report {

private String sQryType = "";
public Report(){
    sQryType = "Test";
}

public String getsQryType() {
return sQryType;
}


Any help will be appreciated.

Tks



2010/11/12 Andr Castro <dedeca...@gmail.com>

John Crunk

unread,
Nov 12, 2010, 3:22:28 PM11/12/10
to lr-loa...@googlegroups.com
You are really going around the world to get the job done. Why are you doing any of this anyway. Are you short on work?

Sent from my iPhone

Andr Castro

unread,
Nov 12, 2010, 3:52:35 PM11/12/10
to lr-loa...@googlegroups.com
Hi John,

Sorry, didn't understand what are you mean?
Have you a better solution? Please, feel free to share with us.

Tks


2010/11/12 John Crunk <jcr...@comcast.net>

John Crunk

unread,
Nov 12, 2010, 4:38:19 PM11/12/10
to lr-loa...@googlegroups.com
Really depends on the app but in all my 20+ years experience I have never seen need for Java protocol. 

Sent from my iPhone

Andr Castro

unread,
Nov 15, 2010, 11:12:15 AM11/15/10
to lr-loa...@googlegroups.com
No, I'm no using the Java Protocol. I'm using the WEB-HTTP.
But I wanna use Java to code the scripts, using the lrapi.
I prefer it  instead the C, cause its easier to work and manipulate JSON and access informations using XPath.
Thats the point. I'm having issues to make all java files work together in the vUGen. 


2010/11/12 John Crunk <jcr...@comcast.net>

James Pulley

unread,
Nov 15, 2010, 12:40:08 PM11/15/10
to lr-loa...@googlegroups.com

Please note that your virtual users will consume more resources than any C virtual user will and you will have the constant challenge of LR and the Java environment (Which version of LoadRunner to which version of java to getting it to work on your VUGEN box and then translating the same to any load generator.)    You _may_ need to license additional virtual user types depending upon your current license.   It may be worth noting why C was chosen years ago, because it was the truly portable cross platform language for the virtual users with substantially low overhead to keep out of the way of the weight of the business process. 

 

I think this may be a generational issue.   (Outside of Basic), C was my ‘primary’ computer language, so when I come to the Java universe I have to both think in C and functional terms and transpose to Java and object terms, so I am much faster in native ansi C than Java.   It sounds like you may be the reverse, thinking ‘natively’ in Java and having to transpose.  No matter which path you head, it’s a myth that you don’t need development skills to be successful with _any_ performance test tool, be it open source or commercial.

 

James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix

John Crunk

unread,
Nov 15, 2010, 5:55:03 PM11/15/10
to lr-loa...@googlegroups.com
Also should be noted that what you are planning is not going to be supported by HP. 

Sent from my iPhone

Andr Castro

unread,
Nov 16, 2010, 5:50:28 AM11/16/10
to lr-loa...@googlegroups.com
Ok, got your point.
So what I was thinking that would be a good change on the Performance area here is not the best choice as you are saying.
So, tell me. I have a lot of correlation data to deal. I was thinking that using java could be better to manipulate JSON and Xpath. Even with most memory consumption.  
Did you use it on your projects? How it going?
Are you developing from the ground all kind of functions to deal with the application data?
I think doing it in C instead Java is so hard do code and keep.

Our application works in some scenarios and some of them we wont be able to knwo in wich state will be the application. The script must be smart to know where it are and change its behavior according whit the application state.  

Any idea will be appreciated.

Tks in advance!

André Castro



2010/11/15 John Crunk <jcr...@comcast.net>

John Crunk

unread,
Nov 16, 2010, 8:04:08 AM11/16/10
to lr-loa...@googlegroups.com
I would have to see the application but sounds like HTTP protocol and lots of correlation is the solution

Sent from my iPhone

James Pulley

unread,
Nov 16, 2010, 10:13:17 AM11/16/10
to lr-loa...@googlegroups.com

Well, before you head down this path and invest all of the time it would be wise to make sure you have the license to support your needs.    Next, you will have the added encumbrances of the pleasure that is working with Java in general with performance test tools which historically has not been the prettiest of situations.   And then there is the resource tradeoff with Java (at its core) significantly higher in resource costs than an equivalent C based virtual user, with the C based user running much closer ‘to the metal’ versus the Java virtual user which has the overhead of the Java Virtual Machine and the constant ‘thunking’ (swiping a Microsoft term here) of calls back and forth from the Java native calls to the OS native calls.

 

Having said that there are some environments I work in where I have to deal with Java, such as writing directly to a binding queue|topic in AMQP environment.   All of the developers are using Java to integrate around the core, so its just easier to swipe the Java code and modify for use rather than be an orphan in the wild trying to reengineer existing work product in C with no one able to assist.   Whenever I have to head down this path I will always run into a Java environment idiosyncrasy which costs me time, such as the version of Java which the developer uses and tests their code with versus the version of Java which is currently being used for the version of LoadRunner, … Of course, you usually find these issues when you run into a “hmmmm, that’s odd…” situation. 

 

So many times the Java app in question can be covered by other protocols which have a more robust environment definition that whenever possible I go to other protocols.   Heck, I’ll even do RM/I in Winsock instead of Java where I can.

 

‘Pulley

Andr Castro

unread,
Nov 16, 2010, 11:04:23 AM11/16/10
to lr-loa...@googlegroups.com
I'm sure about a lot of correlation. And I agree with the HTTP protocol.
But for each HTTP call I'll need to  deal with lot of data. It can come as a simple HTTP parameter, or a huge HTML (to access using XPath as an axample), or an JSON object that must be manipulated (changed, loaded, etc.).

So the point is, in my view, Java is better to work with this kind of data, since there are a lot of libraries ready for use. So I can concentrate my mind in how to model test and the scenarios. In C (and I understand that C is faster than Java) I'll need to code from the ground (or almost) every function. As an example, to parse an HTML source, to get "input text" value. Using Java, I have already done a Class that receive a big string and give me back any kind of information that I would need from there.





2010/11/16 John Crunk <jcr...@comcast.net>

Andr Castro

unread,
Nov 16, 2010, 11:08:12 AM11/16/10
to lr-loa...@googlegroups.com
Really thanks for the clear answers.
I'll check it out the points that you mention. 
But I believe I'll really need to deal with it. I think C won't be able to reach all my needs. Or if yes, I won't be able to coding it, using C. 

Tks
André Castro



2010/11/16 James Pulley <loadrunn...@jamespulley.com>

Venkat P

unread,
Nov 16, 2010, 11:55:40 AM11/16/10
to lr-loa...@googlegroups.com
Andre,

The documentation of  LR 11 talks about support for JSON in form of DFE (Data Format Extensions). It should be relatively simple as one would hope to see the data in XML format.

QUOTE:

Data Format Extension (DFE) - Enhanced data format capabilities for the Web (HTTP/HTML) protocol family. Allows converting raw HTTP traffic into a maintainable and structured XML format and enables correlations by XPATH. Data Format Extension (DFE) - Enhanced data format capabilities for the Web (HTTP / HTML) protocol family. Allows converting raw HTTP traffic into a maintainable and structured XML format and enables correlations by XPATH.

ENDQUOTE
 

I havent really tried this out (in between gigs right now). But you may get some help from HP Support on this. More importantly you probably wont need to have java vusers license for this stuff.  Ofcourse this assumes that you are aready to upgrade to Ver 11

cheers

Venkat

John Crunk

unread,
Nov 16, 2010, 12:49:01 PM11/16/10
to lr-loa...@googlegroups.com
You are in bad need of more research. It is a 5 minute task to get C++ working with LR commands and using them. Not the route I would take but a feasible solution

Sent from my iPhone

Andr Castro

unread,
Nov 16, 2010, 2:49:20 PM11/16/10
to lr-loa...@googlegroups.com
I was just thinking about it.
C++ could have the possibility to use external libraries. And it would be better to deal wiht the JSON and all the stuff.
 
And I believe it must be a quick task for an experienced C/C++ developer.  
I'm researching, believe me. I'm not looking for "ready solutions". I'm only trying to keep the things in the easiest way to code and keep. And from my view Java would a good solution. If haven't the  license and hardware limitations.
As I know, a list is a good place for change experiences.
So, if you have a good reference to give, again, feel free to share.

Otherwise, thanks and sorry for any inconvenience.





2010/11/16 John Crunk <jcr...@comcast.net>

James Pulley

unread,
Nov 16, 2010, 3:16:08 PM11/16/10
to lr-loa...@googlegroups.com

Here’s something which may overlooked which could be of use to you in your search for the ability to integrate third party code, lr_load_dll().

John Crunk

unread,
Nov 16, 2010, 3:15:05 PM11/16/10
to lr-loa...@googlegroups.com
You are picking the language to code in due to your personal preference and not because it does the job best. Wrong approach

Sent from my iPhone

Andr Castro

unread,
Nov 16, 2010, 3:44:40 PM11/16/10
to lr-loa...@googlegroups.com
Sure James. I saw some references about this function.
I think that's the way.
Now I'll need to "think" my scripts in that way.

Tks for the hint!



2010/11/16 James Pulley <loadrunn...@jamespulley.com>

Andr Castro

unread,
Nov 16, 2010, 3:45:08 PM11/16/10
to lr-loa...@googlegroups.com
OK John.
Tks for nothing.
Reply all
Reply to author
Forward
0 new messages