Random Order controller

It executes the samples under it randomly at most once.

Add a Random Order Controller to the thread group.Put 4 samples under it named 1, 2, 3, and 4 . Run and see the order of execution of samples are randomly generated each time.



Include Controller

The include controller is designed to use an external jmx file. To use it, add samples to a simple controller, then save the simple controller as a jmx file. The file can then be used in a test plan.

Open a new file.Under workbench add a Simple controller, to that add an Http request element sampler. Fill the values as follows

Name: external
Server name: www.google.co.in

Now select the simple controller and save it as (right click-> save selection as) external.jmx.


Now open a new test file and add an HTTP request under thread group .Name it as A. Add an Include controller to the thread group. And there give the filename as external.jmx with full path (include test plan).ic2

Now run the script and see that both A and External samples have been generated.ic3

Webservices testing with Jmeter

Webservice: Web service is a method of making various applications communicates with each other automatically over the Internet.

The term Web services describes a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. XML is used to tag the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available.

Web Services have three basic platform elements: SOAP, WSDL and UDDI.

SOAP (Simple Object Access Protocol): SOAP is a simple XML-based protocol to let applications exchange information over HTTP.

WSDL (Web Services Description Language): WSDL is an XML-based language for describing Web services and how to access them.

UDDI (Universal Description, Discovery and Integration): UDDI is a directory service where businesses can register and search for Web services.

Webservice you can use:
http://www50.brinkster.com/vbfacileinpt/np.asmx?wsdl (prime number)

http://wso2.org/library/3862 http://mattharrah.com/blog/software-development/jmeter-and-web-services-part-i/
http://javaboutique.internet.com/tutorials/JMeter/index-9.html http://www.testingminded.com/2009/01/tutorial-on-testing-webservices-with.html

SOAP Client:

SOAPUI tool is specifically built to test webservices.

Getting Memory usage of a server in Jmeter


1. The first step is to add a Thread Group element.

The Thread Group tells JMeter the number of threads you want. Always use 1, since we are using JMeter as a monitor. This is very important for those not familiar with server monitors. As a general rule, using multiple threads for a single server is bad and can create significant stress.

Change the loop count to forever (or some large number) so that enough samples are generated.

2. Add the HTTP Authorization Manager to the Thread Group element (Add –> Config element –> HTTP Authorization Manager). Enter the username and password for your webserver. Important note: the monitor only works with Tomcat5 build 5.0.19 and newer.

1.       leave the base URL blank

2.       enter the username

3.       enter the password

3. Add the HTTP Request to the Thread Group element (Add –> Sampler –> HTTP Request). Then, select the HTTP Request element in the tree and edit the following properties):

1.       Change the Name field to “Server Status”.

2.       Enter the IP address or Hostname

3.       Enter the port number

4.       Set the Path field to “/manager/status” if you’re using Tomcat.

5.       Add a request parameter named “XML” in uppercase. Give it a value of “true” in lowercase.

6.       Check “Use as Monitor” at the bottom of the sampler

4. Add a Constant timer to this thread group (Add –> Timer –> Constant Timer). Enter 5000 milliseconds in the “Thread Delay” box. In general, using intervals shorter than 5 seconds will add stress to your server. Find out what is an acceptable interval before you deploy the monitor in your production environment.

5. Add the Monitor Results Listener by selecting the test plan element (Add –> Listener — > Monitor Results). There are two tabs in the monitor results listener. The first is the “Health”, which displays the status of the last sample the monitor received. The second tab is “Performance”, which shows a historical view of the server’s performance.

6. Run the test and see the result in view listener tree.

The free memory and total memory is in response data for that sample.

Note: If you run out of memory

Negative-effect of Jmeter is they consume a lot of memory. If your JVM is running out of heap memory, you need to edit your Jmeter.bat and increase the heap memory size by editing the following line:

>> HEAP=”-Xms256m -Xmx1024m”

Change the jmeter.bat HEAP=-Xms1024m -Xmx1024m

If you have a system RAM of 2GB then edit jmeter.bat to increase heap memory size “Xms1536m-xmx1536m”.

XPath Assertion in Jmeter

The XPath Assertion tests a document for well formedness, has the option of validating against a DTD, or putting the document through JTidy and testing for an XPath. If that XPath exists, the Assertion is true. Using “/” will match any well-formed document, and is the default XPath Expression. The assertion also supports Boolean expressions, such as “count(//*error)=2”.

You can also go through the previous tutorial: xml assertions .


1. We record a file shiporder.xml (http://tomhanks.9ix.net/xml/shiporder.xml) and will assert if the elements and attributes are correct. The shiporder.xml file is like this.


<shiporder orderid=”889923″ xsi:noNamespaceSchemaLocation=”shiporder.xsd”>

<orderperson>John Smith</orderperson>


<name>Ola Nordmann</name>

<address>Langgt 23</address>

<city>4000 Stavanger</city>




<title>Empire Burlesque</title>

<note>Special Edition</note>





<title>Hide your heart</title>





2. Add an XPath Assertions Element to the sample. (Add->Assertions->XPath assertions). Add Assertion results to the sample. (Add->Listener->Assertion Results).Also add a view results tree.


Now to assert an XPath we need to provide path expressions in the XPath Assertion field. Here we put


Run the script. The result will be shown in green in the View Listener tree if the assertion is true.xpath2

Now put the XPath as: /shiporder/item[2]/note

Run the script and the assertion will fail since there is no note in second item. The following message will come.

Assertion failure message: No Nodes Matched /shiporder/item[2]/note


In Location Path Expression you can also use XPath Axes, functions and operators.

HTTP URL Re-writing Modifier

For web applications that use URL Re-writing to store session ids instead of cookies, this element can be attached at the ThreadGroup level, much like the HTTP Cookie Manager. Simply give it the name of the session id parameter and it will find it on the page and add the argument to every request of that ThreadGroup.

Correlation with HTTP URL Re-writing Modifier:

To use HTTP URL Re-writing Modifier we have to record a scenario where session ids are created. This element will grab the parameter values from previous response. It will find the parameter anywhere it exists on the page, and grab the value assigned to it, whether it’s in an HREF or a form.


1. Record the site.


When you run the script it will show session expired in the listener. (View result tree->response data in Html rendered).The result may appear in red as failure.

Check the sample which sends session ids as requests to the server. (Look in the send parameter with request field of the sample). There are two variables- BV_SessionID and BV_EngineID. The values of these session IDs comes from the server in the previous request. So these values are sent back again to the server by the browser as request in this sample. For each run these values change. So we have to replace them dynamically. We will add HTTP URL Re-writing Modifier (pre processor) to this sample which will fetch the session ids from previous sample.


2. Select the sample. Add a HTTP URL Re-writing Modifier (add-> pre processor-> HTTP URL Re-writing Modifier).

In this example there are two session ids as shown in send parameter with request field. Put the session Variable name (here BV_SessionID) in Session Argument Name.


Here we add another HTTP URL Re-writing Modifier for the second session ID. Don’t forget to select the Cache Session Id? Option in the URL re-writing Modifier.

3. Now change the variable values to * in the sample.


4. Save and run the script. The result will be successful.


HTTP User Parameter Modifier

The User Parameter Modifier uses an XML file get values for HTTP arguments. Any HTTP Request that this modifier modifies will be checked for the existence of the specified arguments. If found, the values for those arguments will be replaced by the values found in the xml file. The XML file can have multiple sets of the same values. This modifier will iterate through these values in a round-robin style, thus each request will get a different set of values until the last set of values is reached, at which point it will begin again at the first set.

We can use HTTP User Parameter Modifier to parameterize a sample. In this example we will parameterize a search query to Google.


1. Record the Google site with a search entry “Jmeter”. Add a Listener. (Add->Listener->View results tree).


The Send Parameter with request in search sample looks like below picture. The variable name for search query is q and value is Jmeter. We will parameterize that value from an external file for two persons.


2. Now to generalize the value for parameter q we have to get values from data.xml file. The search queries put in the data.xml file are proxy and Blogs. Copy the contents the contents of the below two files in a note pad and save them as data.xml and sample.dtd in bin directory.


<?xml version=”1.0″?>
<!DOCTYPE allthreads SYSTEM “sample.dtd”>


<!ELEMENT allthreads (thread+)>
<!ELEMENT thread (parameter+)>
<!ELEMENT parameter (paramname,paramvalue) >
<!ELEMENT paramname (#PCDATA) >
<!ELEMENT paramvalue (#PCDATA) >

3. Add HTTP User parameter modifier to search sample. (Add->preprocessor->HTTP User parameter modifier).In that element change the File Name value to data.xml (the default file is users.xml).


4. In Search sample replace the value of parameter q with *. Make sure to give number of threads (users) to 2 in Thread Group.


5. Now run the test. In view results tree the response data will be shown. See the result of search response in Render HTML view. The values have been passed from the file.hum_5