Parameterization in Java Vuser Protocol in LoadRunner: LoadRunner is currently acquired by MicroFocus, LR is one most popular licensed performance testing tools. This tool is used to do performance testing for all kinds of applications which are designed for Mobile apps, Web, TCP/IP or UDP, Database, Java, and Web sockets testing.

Parameterization in Java Vuser Protocol in LoadRunner

LoadRunner has 3 components which are Vugen, Controller, and Analysis.

These 3 components help us to do end-to-end testing.

  • Vugen is a virtual user generator used to capture actions or traffic which passes from client to server and modify the captured traffic to handle different data and send it to the server and validate the response received from the server and decide whether it is valid or invalid content
  • The 2nd component is the Controller, which helps us in generating multiple users in a similar pattern to how real users use the application and continue to put load consistently for the desired amount of time. And it also checks the server capacity
  • 3rd component is called Analysis, which helps users to get metrics like response times, throughputs, success or failed requests, and Hits per second which are some of the main metrics which are used to identify the performance of your applications.

All the above 3 components depend on each other.

Vugen supports multiple protocols like HTTP, Java Vuser, ODBC, SMTP, POP3, Dev web, Oracle, etc, Depends on the scripting requirement and how server and client communicate we decide which protocol needs to be used for creating virtual users in Vugen.

If you want to create scripts for web applications will be using HTML/web, Dev web protocol which is the right protocol to replicate multiple users without complications.

If we want to create DB scripts then will be using ODBC/Java Vuser protocol for communicating with queues and then Java Vuser/ Web services.

As per requirement will be choosing the right protocol and creating scripts.

In this post, you will see where to use the Java Vuser protocol and how to handle Parameterization in Java protocol.

We can use the Java Vuser protocol for executing DB queries or communicating with message brokers like Kafka, Rabbit MQ, Active MQ, or creating EJB beans.

In this example will be executing DB queries and passing where condition values using parametrization

  • Create a new Java Vuser script
  • Created script to query the database

  • Reading query from file and Query in the file is
select * from users
  • The above query does not have anywhere condition
  • After applying where condition it will be like
select * from users where firstName ='<strong>{P_firstName}</strong>'
  • We need to use as general way as we use in web/HTTP like variable surrounding with {} as shown above
  • After updating the Query with parameters then we need to call lr.eval_string method to substitute parameters with values
  • To above code will be adding a new line as shown below

Parameterization in Java Vuser Protocol

  • We have added a new line which is highlighted above before actual usage
  • Values in the parameter file as shown below

Parameterization in Java Vuser Protocol in LoadRunner

  • we will be printing String after the eval_string method is called below is the output

Starting action vuser_init.
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Actions.
System.out: updated Query: select * from users where firstName = 'Test'
System.out: Executed Successfully
Ending action Actions.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

  • After the value is replaced printed query is
    select * from users where firstName = 'Test' 

Note: Parameters should be created and when we are using in script  need to use {} before and after the variable name

Parameterization in Java Vuser Protocol in LoadRunner

Leave a Reply

Your email address will not be published. Required fields are marked *