Java Tutorial - Java Script : Using the Proxy to Build a Web Test

Java Tutorial - Java Script :

Using the Proxy to Build a Web Test

jMeter also provides a tool that allows it to quickly build a test plan for a Web site. The tool is a proxy server that captures the entire conversation between the browser and the server. To configure the proxy server, select the Workbench node and click Add Non-Test Element HTTP Proxy Server to the node. By default, the proxy is configured to listen to port 8080; however, port 8080 is also the default port for standalone Tomcat installations. (John normally changes the port setting to 8088.)

There are lists in the panel for patterns to include and patterns to exclude. These lists determine which requests will be added to the test plan. Most of the time, we want to ignore requests for images and style sheets. For example, to ignore GIF and JPEG images, you would add:

.*\.gif
.*\.jpg
.*\.jpeg

as patterns to the exclude list. These are also Perl-style regular expressions. If  you were only interested in requests for HTM documents, you could add an include pattern such as:

.*\.html

The Start button at the bottom starts the proxy server.After the proxy has been configured, you must also configure the browser to use the proxy. In Internet Explorer, this can be done by choosing Tools Internet Options and then selecting the Connections tab. Select LAN Settings, and then check the Use a proxy server... box. Use localhost and 8088 for the address and port. On other browsers, you will have to look for the settings that allow you to manually configure your proxy settings. Netscape and Mozilla users will typically find this under Edit Preferences Advanced Proxies.After the browser is configured and the proxy server has been started, browse to the Tomcat application (make sure Tomcat is running too). Click the Servlet Examples link, then select Execute beside the cookies sample line. Fill in the form, and press Submit.

Now, look at your test plan. The pages that you visited have been added as HTTP Request nodes to the test plan. The values entered into the forms have also been entered into each node. Now when the test is executed, all of these pages will be visited and the post requests will send the data captured during  the browsing session.

 When your are finished, do not forget to reset the browser and turn off the proxy server.

We have demonstrated how jMeter can be used for load testing. Asserts can also be used to verify the information returned on a Web page, providing an effective means of functional testing as well. jMeter is not currently as powerful as commercial tools such as Load Runner, but jMeter can be a useful tool when Load Runner or another commercial tool is not available and load testing must be done. jMeter also has some limitations. Currently, the proxy does not support browsing to pages served with the secure HTTPS protocol. This may limit some of its functionality to preproduction testing purposes. jMeter is easy to extend. Developers are encouraged to add listeners, samplers, and other elements to jMeter by writing new Java classes. The stated goal of the jMeter project is to become one of the best functional-testing tools for Web applications. It appears as if the product has a good start.