org.jboss.jsfunit.jsfsession.hellojsf
Class SimplifiedHelloJSFIntegrationTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.cactus.internal.AbstractCactusTestCase
              extended by org.apache.cactus.ServletTestCase
                  extended by org.jboss.jsfunit.jsfsession.hellojsf.SimplifiedHelloJSFIntegrationTest
All Implemented Interfaces:
junit.framework.Test, org.apache.cactus.internal.CactusTestCase

public class SimplifiedHelloJSFIntegrationTest
extends org.apache.cactus.ServletTestCase

This is a simplified version of the HelloJSFIntegrationTest. Instead of using HtmlUnit and JSF API's, it uses JSFUnit's JSFClientSession and JSFServerSession classes to do most of the work. JSFSession maintains your HttpSession, so you can do tests that navigate between views. JSFUnit is designed to allow complete integration testing and debugging of JSF applications at the JSF level. In short, it gives you access to the state of the FacesContext and managed beans after every request. With the FacesContext in hand, you are able to do integration testing of JSF applications at the proper level of abstraction. The typical usage pattern of JSFUnit is to submit a request with JSFSession and then examine both the HTML output and JSF internals. The JSFUnit tests below demonstrate testing: - Navigation: "Did this input take me to the correct view?" - View Components: "Does the JSF component tree contain the correct components?" "Do these components have the expected state?" - Managed Beans: "What is the state of my managed beans?" This can include managed beans in Seam-defined scopes such as conversation scope. The tests below only demonstrate request scope, but you can find anything reachable with the EL. - Validation: "Does invalid input generate the proper FacesMessage and error to the user." Tests not shown below: - EL Expressions: You use the Expression Language (EL) to examine the state of your managed beans. JSFUnit allows you to invoke any EL expression. So, it is also possible to use the EL to invoke actions from JSFUnit without submitting a request. This is not deomonstrated below, but it is relatively easy to do. - Application Config: Because you have access to FacesContext, you can also call FacesContext.getApplication(). From there you can test to make sure your application configuration is correct. This would include tests for proper installation of converters, validators, component types, locales, and resource bundles. This class tests the HelloJSF application. This is a simple Hello World application written in JSF with a single managed bean bound to the name "foo" in request scope.

Author:
Stan Silvert

Field Summary
 
Fields inherited from class org.apache.cactus.ServletTestCase
config, request, response, session
 
Constructor Summary
SimplifiedHelloJSFIntegrationTest()
           
 
Method Summary
 void setUp()
          Start a JSFUnit session by getting the /index.faces page.
static junit.framework.Test suite()
           
 void testGoodbyeButton()
           
 void testInitialPage()
          The initial page was called up in the setUp() method.
 void testInputValidation()
           
 void testValidInput()
          This demonstrates how to test managed beans.
 
Methods inherited from class org.apache.cactus.ServletTestCase
createProtocolHandler
 
Methods inherited from class org.apache.cactus.internal.AbstractCactusTestCase
runBare, runBareServer
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cactus.internal.CactusTestCase
runBareServer
 

Constructor Detail

SimplifiedHelloJSFIntegrationTest

public SimplifiedHelloJSFIntegrationTest()
Method Detail

setUp

public void setUp()
           throws IOException
Start a JSFUnit session by getting the /index.faces page.

Overrides:
setUp in class junit.framework.TestCase
Throws:
IOException

suite

public static junit.framework.Test suite()
Returns:
the suite of tests being tested

testInitialPage

public void testInitialPage()
                     throws IOException
The initial page was called up in the setUp() method. This shows some simple JSFUnit tests you can do on that page.

Throws:
IOException

testInputValidation

public void testInputValidation()
                         throws IOException
Throws:
IOException

testValidInput

public void testValidInput()
                    throws IOException
This demonstrates how to test managed beans.

Throws:
IOException

testGoodbyeButton

public void testGoodbyeButton()
                       throws IOException
Throws:
IOException


Copyright © 2007-2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.