|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.jsfunit.facade.JSFClientSession
public class JSFClientSession
The JSFClientSession provides a simplified API that wraps HttpUnit. With a single JSFClientSession object, you can simulate an entire user session as you set parameters and submit data using submit() and clickCommandLink() methods.
| Constructor Summary | |
|---|---|
JSFClientSession(String initialPage)
Creates a new client interface for testing the JSF application. |
|
JSFClientSession(WebConversation webConversation,
String initialPage)
Creates a new client interface for testing a JSF application using a customized WebConversation. |
|
| Method Summary | |
|---|---|
void |
clickCommandLink(String componentID)
Finds the named command link and uses the link to submit its form. |
void |
clickLink(String componentID)
Finds the named link and clicks it. |
void |
doWebRequest(WebRequest request)
The method submits the WebRequest to the server using the WebConversation of this JSFClientSession instance. |
ClientIDs |
getClientIDs()
Get the ClientIDs helper class which provides useful information and lookups for the components in the server-side component tree. |
WebForm |
getForm(String componentID)
Package-private method to get the WebForm that contains the given component. |
Document |
getUpdatedDOM()
Get the current state of the DOM including any changes made through the setParameter() method. |
WebConversation |
getWebConversation()
Get the HttpUnit WebConversation used by this instance. |
WebResponse |
getWebResponse()
Get the HttpUnit WebResponse object from the latest request. |
void |
setCheckbox(String componentID,
boolean state)
Set a checkbox value on a form. |
void |
setParameter(String componentID,
String value)
Set a parameter value on a form. |
void |
setParameter(String clientID,
String inputID,
String inputName,
String value)
Sets a parameter on a rendered input component. |
void |
submit()
Finds the lone form on the page and submits the form. |
void |
submit(String componentID)
Finds the named submit button on a form and submits the form. |
void |
submitNoButton(String componentID)
Submits a form without pressing a button. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JSFClientSession(String initialPage)
throws MalformedURLException,
IOException,
SAXException
initialPage - The page used to start a client session with JSF. Example: "/index.jsf"
MalformedURLException - If the initialPage cannot be used to create a URL for the JSF app
IOException - If there is an error calling the JSF app
SAXException - If the response from the JSF app cannot be parsed as HTML
public JSFClientSession(WebConversation webConversation,
String initialPage)
throws MalformedURLException,
IOException,
SAXException
WebConversation webConv = WebConversationFactory.makeWebConversation();
webConv.setAuthorization("myuser", "mypassword");
webConv.setHeaderField("Accept-Language", "es-mx,es");
JSFClientSession client = new JSFClientSession(webConv, "/index.jsf");
webConversation - A WebConversation object with "custom" attributes.initialPage - The page used to start a client session with JSF. Example: "/index.jsf"
IllegalArgumentException - if the WebConversation did not come from the
WebConversationFactory.
MalformedURLException - If the initialPage cannot be used to create a URL for the JSF app
IOException - If there is an error calling the JSF app
SAXException - If the response from the JSF app cannot be parsed as HTML| Method Detail |
|---|
public ClientIDs getClientIDs()
public WebForm getForm(String componentID)
throws SAXException
componentID - The ID of the component contained by the form, or the
ID of the form itself.
SAXException - if the current response page can not be parsed
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
FormNotFoundException - if no form parameter can be found matching
the componentID
public void doWebRequest(WebRequest request)
throws SAXException,
IOException
request - The WebRequest
IOException - If there is an error calling the JSF app
SAXException - If the response from the JSF app cannot be parsed as
HTMLpublic WebResponse getWebResponse()
public Document getUpdatedDOM()
public WebConversation getWebConversation()
public void setParameter(String componentID,
String value)
throws SAXException
componentID - The JSF component ID or a suffix of the client ID.value - The value to set before the form is submitted.
SAXException - if the current response page can not be parsed
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
public void setParameter(String clientID,
String inputID,
String inputName,
String value)
throws SAXException
clientID - The fully-qualified JSF client ID of the component.inputID - The value of the id attribute of the extra input tag.inputName - The value of the name attribute of the extra input tag.value - The value to set before the form is submitted.
SAXException - if the current response page can not be parsed
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
public void setCheckbox(String componentID,
boolean state)
throws SAXException
componentID - The JSF component ID or a suffix of the client ID.value - The value to set before the form is submitted.
SAXException - if the current response page can not be parsed
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
IllegalArgumentException - if the componentID does not resolve to a
checkbox control
public void submit()
throws SAXException,
IOException
IllegalStateException - if page does not contain exactly one form.
IOException - if there is a problem submitting the form.
SAXException - if the response page can not be parsed
public void submit(String componentID)
throws SAXException,
IOException
componentID - The JSF component id (or a suffix of the client ID) of
the submit button to be "pressed".
IOException - if there is a problem submitting the form.
SAXException - if the response page can not be parsed
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
ComponentTypeException - if the componentID does reference an
HtmlCommandButton JSF component.
public void submitNoButton(String componentID)
throws SAXException,
IOException
componentID - The JSF component id (or a suffix of the client ID) of
a component on the form to be submitted. This can also
be the ID of the form itself.
IOException - if there is a problem submitting the form.
SAXException - if the response page can not be parsed
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
public void clickLink(String componentID)
throws SAXException,
IOException
componentID - The JSF component id (or a suffix of the client ID) of
the link to be "clicked".
IOException - if there is a problem clicking the link.
SAXException - if the response page can not be parsed.
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
ComponentTypeException - if the componentID does reference an
HtmlOutputLink JSF component.
public void clickCommandLink(String componentID)
throws SAXException,
IOException
componentID - The JSF component id (or a suffix of the client ID) of
the link to be "clicked".
IOException - if there is a problem clicking the link.
SAXException - if the response page can not be parsed.
ComponentIDNotFoundException - if the component can not be found
DuplicateClientIDException - if more than one client ID matches the
componentID suffix
ComponentTypeException - if the componentID does reference an
HtmlCommandLink JSF component.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||