Package rife.test
Class MockForm
java.lang.Object
rife.test.MockForm
Corresponds to a form in an HTML document after it has been parsed with
ParsedHtml.parse(rife.test.MockResponse).- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionfile(String name, MockFileUpload file) Sets a file in this form.files(String name, MockFileUpload[] files) Sets files in this request.Retrieves the content of this form'sactionattribute.Retrieves the content of this form'sclassattribute.org.jsoup.nodes.ElementRetrieves the JSoup element that this form corresponds to.getId()Retrieves the content of this form'sidattribute.Retrieves the content of this form'smethodattribute.getName()Retrieves the content of this form'snameattribute.Retrieves all the parameter names of this form.Retrieves all the parameters of this form.getParameterValue(String name) Retrieves the first value of a parameter in this form.String[]getParameterValues(String name) Retrieves the values of a parameter in this form.Creates a newMockRequestthat contains the method, the parameters and the files of this form.getTitle()Retrieves the content of this form'stitleattribute.booleanhasParameter(String name) Checks whether a named parameter is present in this form.Sets a parameter in this form.Sets a parameter in this form.voidsetFile(String name, MockFileUpload file) Sets a file in this form.voidsetFiles(String name, MockFileUpload[] files) Sets files in this request.voidsetParameter(String name, String value) Sets a parameter in this form.voidsetParameter(String name, String[] values) Sets a parameter in this form.submit()Submit this form with its current parameters and files; and returns the response.
-
Method Details
-
getElement
public org.jsoup.nodes.Element getElement()Retrieves the JSoup element that this form corresponds to.- Returns:
- the corresponding JSoup element
- Since:
- 1.0
-
getRequest
Creates a newMockRequestthat contains the method, the parameters and the files of this form.- Returns:
- the created
MockRequest - Since:
- 1.0
-
submit
Submit this form with its current parameters and files; and returns the response.- Returns:
- the resulting
MockResponse - Since:
- 1.0
-
getParameters
Retrieves all the parameters of this form.- Returns:
- a
Mapof the parameters with the names as the keys and their value arrays as the values - Since:
- 1.0
- See Also:
-
getParameterNames
Retrieves all the parameter names of this form.- Returns:
- a
Collectionof the parameter names - Since:
- 1.0
- See Also:
-
hasParameter
Checks whether a named parameter is present in this form.- Parameters:
name- the name of the parameter to check- Returns:
trueif the parameter is present; orfalseotherwise- Since:
- 1.0
- See Also:
-
getParameterValue
Retrieves the first value of a parameter in this form.- Parameters:
name- the name of the parameter- Returns:
- the first value of the parameter; or
nullif no such parameter could be found - Since:
- 1.0
- See Also:
-
getParameterValues
Retrieves the values of a parameter in this form.- Parameters:
name- the name of the parameter- Returns:
- the values of the parameter; or
nullif no such parameter could be found - Since:
- 1.0
- See Also:
-
setParameter
Sets a parameter in this form.- Parameters:
name- the name of the parametervalue- the value of the parameter- Since:
- 1.0
- See Also:
-
parameter
Sets a parameter in this form.- Parameters:
name- the name of the parametervalue- the value of the parameter- Returns:
- this
MockForminstance - Since:
- 1.0
- See Also:
-
setParameter
Sets a parameter in this form.- Parameters:
name- the name of the parametervalues- the value array of the parameter- Since:
- 1.0
- See Also:
-
parameter
Sets a parameter in this form.- Parameters:
name- the name of the parametervalues- the value array of the parameter- Returns:
- this
MockForminstance - Since:
- 1.0
- See Also:
-
setFile
Sets a file in this form.- Parameters:
name- the parameter name of the filefile- the file specification that will be uploaded- Since:
- 1.0
- See Also:
-
file
Sets a file in this form.- Parameters:
name- the parameter name of the filefile- the file specification that will be uploaded- Returns:
- this
MockForminstance - Since:
- 1.0
- See Also:
-
setFiles
Sets files in this request.- Parameters:
name- the parameter name of the filefiles- the file specifications that will be uploaded- Since:
- 1.0
- See Also:
-
files
Sets files in this request.- Parameters:
name- the parameter name of the filefiles- the file specifications that will be uploaded- Returns:
- this
MockForminstance - Since:
- 1.0
- See Also:
-
getId
Retrieves the content of this form'sidattribute.- Returns:
- the content of the
idattribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getClassName
Retrieves the content of this form'sclassattribute.- Returns:
- the content of the
classattribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getTitle
Retrieves the content of this form'stitleattribute.- Returns:
- the content of the
titleattribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getAction
Retrieves the content of this form'sactionattribute.- Returns:
- the content of the
actionattribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getMethod
Retrieves the content of this form'smethodattribute.- Returns:
- the content of the
methodattribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getName
Retrieves the content of this form'snameattribute.- Returns:
- the content of the
nameattribute; ornull if no such attribute could be found
- Since:
- 1.0
-