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'saction
attribute.Retrieves the content of this form'sclass
attribute.Retrieves the JSoup element that this form corresponds to.getId()
Retrieves the content of this form'sid
attribute.Retrieves the content of this form'smethod
attribute.getName()
Retrieves the content of this form'sname
attribute.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 newMockRequest
that contains the method, the parameters and the files of this form.getTitle()
Retrieves the content of this form'stitle
attribute.boolean
hasParameter
(String name) Checks whether a named parameter is present in this form.Sets a parameter in this form.Sets a parameter in this form.void
setFile
(String name, MockFileUpload file) Sets a file in this form.void
setFiles
(String name, MockFileUpload[] files) Sets files in this request.void
setParameter
(String name, String value) Sets a parameter in this form.void
setParameter
(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
Retrieves the JSoup element that this form corresponds to.- Returns:
- the corresponding JSoup element
- Since:
- 1.0
-
getRequest
Creates a newMockRequest
that 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
Map
of 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
Collection
of 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:
true
if the parameter is present; orfalse
otherwise- 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
null
if 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
null
if 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
MockForm
instance - 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
MockForm
instance - 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
MockForm
instance - 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
MockForm
instance - Since:
- 1.0
- See Also:
-
getId
Retrieves the content of this form'sid
attribute.- Returns:
- the content of the
id
attribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getClassName
Retrieves the content of this form'sclass
attribute.- Returns:
- the content of the
class
attribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getTitle
Retrieves the content of this form'stitle
attribute.- Returns:
- the content of the
title
attribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getAction
Retrieves the content of this form'saction
attribute.- Returns:
- the content of the
action
attribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getMethod
Retrieves the content of this form'smethod
attribute.- Returns:
- the content of the
method
attribute; ornull if no such attribute could be found
- Since:
- 1.0
-
getName
Retrieves the content of this form'sname
attribute.- Returns:
- the content of the
name
attribute; ornull if no such attribute could be found
- Since:
- 1.0
-