Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
JSFUnit 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 JUnit 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. JSFUnit provides the JSFTimer class to time the execution of a given phase of an application, as demonstrated in listings 15.14 and 15.15.
//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> |