in black and white
Main menu
Share a book About us Home
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

Java Tools for Extreme programming mastering open source tools including - Hightower R.

Hightower R. Java Tools for Extreme programming mastering open source tools including - Wiley publishing , 2002. - 417 p.
ISBN: 0-471-20708
Download (direct link): javatoolsforextremeprog2002.pdf
Previous << 1 .. 94 95 96 97 98 99 < 100 > 101 102 103 104 105 106 .. 159 >> Next

So far we've been lobbing softballs at our Web application. Now that we know it runs, it's time to play hard ball. Set the thread count to 100 on the Navigation ThreadGroup, and reduce the time to 300 milliseconds on the timer. Save any work in open programs before starting this test. Run the test—let 'er rip! (See Figure 10.6.')
Fie FtJfl MlFpill I Oplnin
9 f »-VW
It hSIcXfeb’Oil
f ftiMUsmebEa!
-?jt.FC-HrflCF iVJr
r ivu. v-
-Con 5t line Trwi ? trapf
f| k
jQrapfl ResuHS
Figure 10.6: Graph of the Test Case Running against the Web Application.
We find the graph useful, but we also like to dump the data out to a file and read it in with a spreadsheet application (Excel) and some Python stats package we wrote. In addition, we find the spline visualizer useful in seeing the runtime performance of the system. Add the spline visualizer to the Navigation ThreadGroup by right-clicking and choosing Add, Listener, Spline Visualizer from the pop-up menu. Now, add the file reporter to the Navigation ThreadGroup (select Add, Listener, File Reporter). Click on the File Reporter element and set the output file location (for example, /tmp/output.log). Now, let's run it again.
After running the spline visualizer, we can see that the average access time is around 444 milliseconds, and we get a very interesting view of the runtime data (see Figure 10.7).
Figure 10.7: Spline Visualizer Running the Navigation Test.
In addition to the data in Figure 10.7 and the graph from the first run, we can import the output data recorded by the File Reporter into our favorite spreadsheet or other analysis software and create a custom report. Here is a sample file listing of the date in verbose mode:
http://localhost:80/pet/productjsp?id=2221 200
http://localhost:80/pet/subcategoryjsp?id=222 220
http://localhost:80/pet/subcategoryjsp?id=222 230
http://localhost:80/pet/ 220 In this example, we set up a ThreadGroup; added Web-test controllers to the ThreadGroup; set up a timer; added a cookie manager; and set up a graph, file reporter, and spline visualizer listener. In the next section, we'll create a script that can simulate form entry.
Using JMeter to Test the Web Application's Form Entry
In this example, we will test the back-end product form entry. In Chapter 7, "Unit Testing with JUnit," we created a case study that added to the pet store example the functionality to add, delete, and edit products. In this section, we will write code that tests this feature. Then, we will combine this test with the last test so we can simulate customers browsing the Web site at the same time we simulate the pet store clerk adding new pets, to see what happens to performance.
First we will add a Web-application test that tests adding products. If we open the backend product page (http://localhost/pet/mgmt/product.jsp?id=2221) in a browser and view the source, the form looks like this:
<form method-'POST" action-'prod_sys.jsp''>
<p>Name: <input type-'text" name-'name" value-"" size-'20''></p>
<p>Price: <input type-'text" name-'price" value-'$0.00" size-'20''></p>
<p>Qty: <input type-'text" name-'qty'' value-'0" size-'20''></p>
<input type-'hidden" name-'subcategoryID'' value-'222" size-"20">
<input type-'hidden" name-'productNum'' value-'4" size-"20">
<input type-'hidden" name-'newProduct" value-'true" size-"20">
<input type-'hidden" name-'productID'' value-'0" size-"20">
<p><textarea rows-'8" name-'description" cols-'84" ></textarea></p> <p>&nbsp;</p>
<p><input type-'submit" value-'Submit" name-"submit"><input type-'reset"
value-'Reset" name-"reset"></p>
All we have to do with JMeter is simulate adding a product with this form. Thus we need to fill in the form parameters:
? "name" is the name of the new product we are creating.
? "price" can be set to any valid price.
? "qty" can be set to any valid quantity.
? "subcategoryID" must be set to a valid subcategory id. Consult the ID field of the subcategory table
to see a valid id. If the test data hasn't changed, "222" is the subcategory id for Cats.
? "productNum" is the number of products in the current subcategory. We don't have to know how
many products are in the subcategory; instead, we just make productNum really large—in this case, "99999".
? "newProduct" should be set to "true", which just means that we are adding a new product rather
than editing an existing product.
? "productID" can be set to "0" because this value simulates adding a new product. (This parameter
really is not used.)
? "description" can be any value.
We add all these parameters to the Web-application controller we added, and then change the method from GET to POST to match the HTML form. We set everything else just as we did in the earlier example, and we set the path to pet/mgmt/prod_sys.jsp to match the "action" attribute in the HTML form. Our Web controller configuration panel looks like the one in Figure 10.8.
Me ftjri Hup ml Oplknw Hdp
Previous << 1 .. 94 95 96 97 98 99 < 100 > 101 102 103 104 105 106 .. 159 >> Next