Java Reference
In-Depth Information
rows is six (we have five rows for the hardcoded albums and one for the header).
From the table we retrieve the second row, the first cell out of it, and an HTMLAnchor
out of the cell F . Again, we assert that the link isn't null G , and we click it H . The
last assertion I compares the title of the page that we got from clicking the link
object; we want to make sure that we're taken to the new page.
15.7
Performance testing for your JSF application
JSFU nit provides the option to test the performance of an application. Going back to
our MusicStore application, we'd like to ensure that the purchase method of our
AlbumDetailsBeam is always executed in less than a second and a half. Although JU nit
4.5 provides the @Test annotation timeout parameter, when it comes to testing web
applications this parameter isn't sufficient. In most cases, we want to time different
phases of the application. JSFU nit provides the JSFTimer class to time the execution of
a given phase of an application, as demonstrated in listings 15.14 and 15.15.
Listing 15.14
Enabling the JSFTimer for our application
//web.xml
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/timer-config.xml</param-value>
</context-param>
//timer-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
" http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<lifecycle>
<phase-listener>
org.jboss.jsfunit.framework.JSFTimerPhaseListener
</phase-listener>
</lifecycle>
</faces-config>
We declare a new context parameter with a value pointing to the timer-config.xml
file, which holds the declaration for the timer.
Listing 15.15 shows how to use the timer.
Listing 15.15
Performance test for purchasing an album
[...]
public class TestPerformanceOfPurchaseBean extends ServletTestCase {
B
C
public void testPerformance() throws IOException {
JSFSession jsfSession = new JSFSession( "/album_details.jsp" );
D
E
JSFClientSession client = jsfSession.getJSFClientSession();
F
client.click( "PurchaseButton" );
 
 
 
 
 
Search WWH ::




Custom Search