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

7. Set up the ability to access the subcategory, as in http://localhost/pet/subcategory.jsp?id=222. Add another Web-testing controller as follows:
? Set the name to SubcategoryWebTest.
? Set the domain to localhost.
? Leave the port at 80.
? Set the path to pet/subcategory.jsp (as in
8. Add the "id" parameter and set it to a valid subcategory id. Note that 222 should be a valid subcategory identifier, but we need to check the DB just in case we deleted it. To add an "id" parameter, click on Add in the Web-controller configuration pane. Type "id" for the name and "222" for the value. The pane should look like Figure 10.4. Figure 10.5 shows the corresponding browser view of the same URL defined in Figure 10.4.
Figure 10.4: SubcategoryWebTest Configuration Pane.
| 3;AAA P«i. Lrsrl ? HcmcidE Infnnrl E xpbrni HCTnl
-'*r Edi VWrt f/rriftti lo&t B
? O Q (3 iSfcSiiSft rSnFavrrtgp Hidjrji [^j- [^] -J jR
jJ |^6o Lrfki ¹
AAA Pets
C.«"pJ=>l t4sE0 Shoppy fift Luifc:
?l''SI all fij;____________ Wdr cmjJrji
tr-fl ¹
I tti *iC3Cftfifc-n
ask if .ate t

_ 'rcrDYTuhl. MU Fbck Hutto»*! 1 I
nil L'lcsi rtiflr^
Figure 10.5: Browser Equivalent to the Subcategory Web Test in Figure 10.4.
9. Repeat the last step for the product page test. That is, set up the ability to access the product, as in http://localhost/pet/product.jsp?id=2221. Add another Web-testing controller as follows:
? Set the name to ProductWebTest.
? Set the domain to localhost.
? Leave the port at 80.
? Set the path to pet/product.jsp (as in http://localhost/pet/product.jsp?id=2221).
? Add an "id" parameter set to "2221".
10. Now that the Web controllers are set up, we'll set up a timer. For this example, we will use a constant timer. Go to the Navigation ThreadGroup node, right-click it, and choose Add, Timer, Constant Timer from the pop-up menu. When we are setting up a test, we like to slow down the timer so we can see if the test is really doing what we expect it to. To set the timer interval to 3 seconds, use a value of 3000 (the timer works with milliseconds).
11. We need a way to view our results. Right-click the Navigation ThreadGroup, and choose Add, Listener, Graph Results from the pop-up menu. As we stated earlier, the first time a test runs, it is good to see the real HTML flying by; so, add a View Results listener, as well (select Add, Listener, View Results from the pop-up menu).
Now that we can see the results, let's run the test. Select the Navigation ThreadGroup and then select Run, Start from the main menu bar.
There are two ways to know the test is working: We can look at the View Results listener and see the pages of HTML, or we can look at the data being spit out to the console by JMeter, as follows:
Sampling url: http://localhost:80/pet
Original location=http://localhost/pet/
Modified location=http://localhost/pet/
Sampling url: http://localhost:80/pet/
Sampling url: http://localhost:80/pet/subcategory.jsp?id=222
The console indicates test errors on the product.jsp because the current subcategory is in the Web application session information. We have not set up JMeter to track session information. The error when trying to load product.jsp is as follows:
Sampling url: http://localhost:80/pet/product.jsp?id=2221
at (Unknown Source)
at (Unknown Source)
at org.apache.jmeter.protocol.http.sampler.HTTPSampler.getError-
This happened quite by mistake. Remember, we said the pet store Web application was not robust. Well, we did not lie; as it happens, the pet store Web application needs session data to traverse to the products correctly. You don't want this feature in a real Web application, but this Web application is non-robust by design.
However, a real Web application may hold important session information like user id, preferences, affiliations, and so on. This information may provide a customized view or provide some filtering on a per-user/per-session basis. Therefore, this snafu lends an excellent opportunity to show you how JMeter can track session information.
The default behavior of many JSP and Servlet engines is to send a special cookie to the client to track session information. A cookie is a name/value pair that is stored on the client's machine. The cookie is associated with a particular URL, and it's sent when you access pages under that URL. Thus, we must set up JMeter to receive and transmit the cookie back to the Web application server. Fortunately, this is easy to do with JMeter: All we have to do is add a cookie manager to the thread navigation ThreadGroup (Add, Config Element,
Cookie Manager), and JMeter does the rest. When we rerun the test, it will work this time.
Previous << 1 .. 93 94 95 96 97 98 < 99 > 100 101 102 103 104 105 .. 159 >> Next