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 .. 95 96 97 98 99 100 < 101 > 102 103 104 105 106 107 .. 159 >> Next

Wtii rt bimy
rMibufc: ó-----------------------------
floe at unPS * 1
Ewruin __________________________
hnl I
?bfihps ? POSi N smt
в tiC. 00

222 Bu*
Figure 10.8: Adding a Product Using JMeter.
We can run this test now, but we will only be able to run it oncethe test is essentially hard-coding the primary key of the product, which must be unique. To run the test many times, we need to create another test to delete the product we set up in this test. So, we add another Web-testing controller to delete the one we just added.
The form we are trying to simulate is the backend subcategory form
(http://localhost/pet/mgmt/subcategory.jsp?id=222), shown in Figure 10.9. The HTML for the form we are tying to simulate is as follows:
<form method="POST" action="subcat_sys.jsp">
<table border="1" width="100%">
<td width="9%">
<input type="checkbox" name="delete_2221" value="OFF">delete</td>
<td width="86%">
<a href="product.jsp?id=2221" target="_blank">Calico</a>

f. IciLi'g
ijfcusafikiniiom I m Vrtrr RMiJs ? QOff j YVtak&H-ifc
<td width="9%">
<input type="checkbox" name="delete_2222" value="OFF">delete</td>
<td width="86%">
<a href="product.jsp?id=2222" target="_blank">Jaguar</a> <br>
<td width="9%">
<input type="checkbox" name="delete_2223" value="OFF">delete</td>
<td width="86%">
<a href="product.jsp?id=2223" target="_blank">Siamese</a> <br>
<td width="9%">
<input type="checkbox" name="delete_22299999" value="OFF">delete</td>
<td width="86%">
<a href="product.jsp?id=22299999" target="_blank">testpet</a> <br>
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="Reset">
<input type="submit" value="Add" name="add"></p>
Figure 10.9: Backend Subcategory Form.
If we examine the JSP code to which we need to submit this form, we see that the id is embedded in the name of the check box in bold, as follows:
<input type-'checkbox" name="delete_22299999"
We need to add a parameter to our Web testing controller, as follows:
? Set the name to "Delete product".
? Set the domain to localhost.
? Leave the port at 80.
? Set the path to pet/mgmt/subcat_sys.jsp.
? Change the method to POST (default is GET).
? Add a parameter to delete_22299999 and set the value to "ON". When we are done, the configuration panel looks like Figure 10.10.
A|Mi:hr JMrln
free Hin Krpuil Options
1 Rwt
? ? Wffcn
9 C 'tttVKXVSf
MH crodMrf DeWaprwiuct
? jfapi Hunt!
* vtawRiMut
^ ifc in r*sj
~i VMBa&t
Nam* ?ftlfrlfe irbducl Qrf&n Pjf i
hilft Qt HOPS * HTTP
OunMcn EotHhwt______________________
li 'pct'mgrrtoubciE snisp
Gfcl * 51
PVdrltffM T?Uti
HlfWi I____
a^isras' [TvT
Figure 10.10: Using JMeter to Delete a Product in the Pet Store Application.
Finally, for completeness, let's add the ability to test editing a product. We'll set up two of these tests: one to edit a product and one to change it back. To set up the editing test, we add a new Web-controller tester and configure it as follows:
? Set the name to "Edit product".
? Set the domain to localhost.
? Leave the port at 80.
? Set the path to pet/mgmt/prod_sys.jsp.
? Change the method to post (default is get).
? Add the following name/value pairs to the parameter list:
o "name"="Calico" o "price"="$500" o "qty"="5"
o "subcategoryID'='222" o "newProduct"="false" o "productNum"="0"
o "description"="Calico data has been edited!"
one in Figure 10.11.
Figure 10.11: Using JMeter to Edit a Product.
We recommend setting the thread count to 1 and then using the timer to adjust the frequency of edits, because these tests should execute in order. Before running the test, add some listeners and a timer as in the last example. Go ahead and run the test and examine the results.
Notice that we can save any node. Let's save this test and create or reload the last test, and then save it at the ThreadGroup node. Then we can load both the front-end browsing and the backend product management into the test case by selecting Open from the popup-menu, and they will run at the same time.
Because the nodes are saved as XML, we could write a program that reads the test data or that generates it
we just created as displayed in Internet Explorer.
Figure 10.12: XML Text for Testing Forms in IE.
JMeter has other ways of creating the setup XML for tests. We can set up a proxy server that listens to requests and records them in an XML text that we can use for test cases. Refer to the user guide under Recording Browser Activity to learn how to do this. This technique can shave off some of the time it takes to create tests. In the next section, we will create a JDBC test.
E 1 ^ï ? ? -*f Vf* nr.: ^ ˲̲
Previous << 1 .. 95 96 97 98 99 100 < 101 > 102 103 104 105 106 107 .. 159 >> Next