You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2007/07/24 22:22:44 UTC

[Myfaces Wiki] Update of "PerformanceTestingWithJMeter" by GregReddin

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by GregReddin:
http://wiki.apache.org/myfaces/PerformanceTestingWithJMeter

The comment on the change is:
Added JMeter testing page.

New page:
#format wiki
#language en

= Testing a JSF Application with JMeter =

[http://jakarta.apache.org/jmeter/ JMeter] is an open-source performance testing tool that is useful for stress-testing web applications. !JavaServer Faces presents interesting challenges with scripted testing because of the special request parameters needed and the requirement for POST requests. This document attempts to boil the requirements down in a simple fashion. 

There are two main requirements to scripting a JSF application. First, you must simulate the JSF !ViewState request parameter. Second, you must include all form elements in a POST request. The easiest way to create the initial script is to set up JMeter to record your request/response streams and use the scripts JMeter creates  as a starting point.

== ViewState Extractor ==

To simulate the !ViewState parameter create a JMeter !RegEx Extractor. The best approach is to apply the extractor to the Thread Group so it applies across the whole test script. Use the following parameters:

|| '''Reference Name''' || jsfViewState ||
|| '''Regular Expression''' || {{{<input type="hidden" name="javax\.faces\.ViewState" id="javax\.faces\.ViewState" value="(.+?)" />}}} ||
|| '''Template''' || $1$ ||
|| '''Match No.''' || 0 ||

This extractor will find the !ViewState parameter and store it in a JMeter variable called jsfViewState so it can be passed down in future requests.

== The First Request ==

The first request to most applications will be a GET request and will not contain any JSF information. Script this request as you would any initial request for a non-JSF web application.

== Subsequent Requests ==

Create an HTTP Request using the POST method for all JSF requests. Again, the best way to approach this is to record a session with the web application and change the dynamic variables. All JSF requests will have a few request parameters that need to be part of the request. All of these parameter names will start with the  name of the form, then a "%3A", then the parameter name. For example if the form is named "myForm" you will see at least the following parameters:

|| '''Parameter Name''' || '''Parameter Value''' ||
|| myForm%3A_SUBMIT || 1 ||
|| myForm%3A_link_hidden_ || (No value) ||
|| myForm%3A_idcl || Hard to script. Best to use the recorded value, but you can figure it out if you have to. ||
|| javax.faces.!ViewState || ${jsfViewState} ||

In addition to the above "standard" variables you will need to add parameters in the same format for all form elements that are part of your request.