org.jboss.jsfunit.jsfsession
Class JSFServerSession

java.lang.Object
  extended by org.jboss.jsfunit.jsfsession.JSFServerSession
All Implemented Interfaces:
RequestListener

public class JSFServerSession
extends Object
implements RequestListener

The JSFServerSession provides a simplified API that wraps parts of the JSF API for things that you would commonly do in testing.

Since:
1.0
Author:
Stan Silvert

Method Summary
 void afterRequest(com.gargoylesoftware.htmlunit.WebResponse webResponse)
          This is called after the request is over.
 void beforeRequest(com.gargoylesoftware.htmlunit.WebRequest webRequest)
          This is called before HtmlUnit makes a request to the server.
 javax.faces.component.UIComponent findComponent(String componentID)
          Find a component in the JSF component tree.
 ClientIDs getClientIDs()
          Get the immutable ClientIDs object.
 Object getComponentValue(String componentID)
          Find a component in the JSF component tree and return its value.
 String getCurrentViewID()
          Return the current view ID from the component tree.
 javax.faces.context.FacesContext getFacesContext()
          Get the FacesContext object used in the last request.
 Iterator<javax.faces.application.FacesMessage> getFacesMessages()
          Return all the FacesMessages generated with the last JSF request.
 Iterator<javax.faces.application.FacesMessage> getFacesMessages(String componentID)
          Return all the FacesMessages generated for a component in the last JSF request.
 Object getManagedBeanValue(String elExpression)
          Evaluate an EL ValueExpression and return the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClientIDs

public ClientIDs getClientIDs()
Get the immutable ClientIDs object. This is typically used only by JSFUnit.

Returns:
The ClientIDs object
See Also:
ClientIDs

getCurrentViewID

public String getCurrentViewID()
Return the current view ID from the component tree.

Returns:
The current View ID.

getFacesContext

public javax.faces.context.FacesContext getFacesContext()
Get the FacesContext object used in the last request.

Returns:
The FacesContext object used in the last request.

findComponent

public javax.faces.component.UIComponent findComponent(String componentID)
Find a component in the JSF component tree.

Parameters:
componentID - The JSF component ID or client ID suffix.
Returns:
The component.
Throws:
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the componentID suffix

getComponentValue

public Object getComponentValue(String componentID)
Find a component in the JSF component tree and return its value. Note that the found component must implement ValueHolder.

Parameters:
componentID - The JSF component ID or client ID suffix.
Returns:
The value contained in the component.
Throws:
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the componentID suffix
ClassCastException - if the found component does not implement ValueHolder

getManagedBeanValue

public Object getManagedBeanValue(String elExpression)
Evaluate an EL ValueExpression and return the value.

Parameters:
elExpression - The expression.
Returns:
The value. Return null if the managed bean is request, session, or application scope and does not yet exist.

getFacesMessages

public Iterator<javax.faces.application.FacesMessage> getFacesMessages()
Return all the FacesMessages generated with the last JSF request.

Parameters:
componentID - The JSF component ID or client ID suffix.
Returns:
The FacesMessages

getFacesMessages

public Iterator<javax.faces.application.FacesMessage> getFacesMessages(String componentID)
Return all the FacesMessages generated for a component in the last JSF request.

Parameters:
componentID - The JSF component ID or client ID suffix.
Returns:
the FacesMessages.
Throws:
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the componentID suffix

beforeRequest

public void beforeRequest(com.gargoylesoftware.htmlunit.WebRequest webRequest)
Description copied from interface: RequestListener
This is called before HtmlUnit makes a request to the server.

Specified by:
beforeRequest in interface RequestListener
Parameters:
webRequest - The settings for the request.

afterRequest

public void afterRequest(com.gargoylesoftware.htmlunit.WebResponse webResponse)
Description copied from interface: RequestListener
This is called after the request is over. In the case that the request throws an IOException, the webResponse will be null.

Specified by:
afterRequest in interface RequestListener
Parameters:
webResponse - The response, or null if the request threw an IOException.


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