Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 15. Testing JSF applications > Performance testing for your JSF applica...

15.7. Performance testing for your JSF application

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.

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>


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial