com.uwyn.rife.test
Class MockForm

java.lang.Object
  extended by com.uwyn.rife.test.MockForm

public class MockForm
extends Object

Corresponds to a form in a HTML document after it has been parsed with ParsedHtml.parse(com.uwyn.rife.test.MockResponse).

Since:
1.1
Version:
$Revision: 3634 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)

Method Summary
 MockForm file(String name, MockFileUpload file)
          Sets a file in this form.
 MockForm files(String name, MockFileUpload[] files)
          Sets files in this request.
 String getAction()
          Retrieves the content of this form's action attribute.
 String getClassName()
          Retrieves the content of this form's class attribute.
 String getId()
          Retrieves the content of this form's id attribute.
 String getMethod()
          Retrieves the content of this form's method attribute.
 String getName()
          Retrieves the content of this form's name attribute.
 Node getNode()
          Retrieves the DOM XML node that this form corresponds to.
 Collection<String> getParameterNames()
          Retrieves all the parameter names of this form.
 Map<String,String[]> getParameters()
          Retrieves all the parameters of this form.
 String 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.
 MockRequest getRequest()
          Creates a new MockRequest that contains the method, the parameters and the files of this form.
 String getTitle()
          Retrieves the content of this form's title attribute.
 boolean hasParameter(String name)
          Checks whether a named parameter is present in this form.
 MockForm parameter(String name, String value)
          Sets a parameter in this form.
 MockForm parameter(String name, String[] values)
          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.
 MockResponse submit()
          Submit this form with its current parameters and files; and returns the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNode

public Node getNode()
Retrieves the DOM XML node that this form corresponds to.

Returns:
the corresponding DOM XML node
Since:
1.0

getRequest

public MockRequest getRequest()
Creates a new MockRequest that contains the method, the parameters and the files of this form.

Returns:
the created MockRequest
Since:
1.0

submit

public MockResponse submit()
Submit this form with its current parameters and files; and returns the response.

Returns:
the resulting MockResponse
Since:
1.0

getParameters

public Map<String,String[]> 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.1
See Also:
getParameterNames(), hasParameter(java.lang.String), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[]), setParameter(String, String)

getParameterNames

public Collection<String> getParameterNames()
Retrieves all the parameter names of this form.

Returns:
a Collection of the parameter names
Since:
1.1
See Also:
getParameters(), hasParameter(java.lang.String), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[]), setParameter(String, String)

hasParameter

public boolean hasParameter(String name)
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; or

false otherwise

Since:
1.1
See Also:
getParameters(), getParameterNames(), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[]), setParameter(String, String)

getParameterValue

public String getParameterValue(String name)
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.1
See Also:
getParameters(), getParameterNames(), hasParameter(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[]), setParameter(String, String)

getParameterValues

public String[] getParameterValues(String name)
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.1
See Also:
getParameters(), getParameterNames(), hasParameter(java.lang.String), getParameterValue(java.lang.String), setParameter(String, String[]), setParameter(String, String)

setParameter

public void setParameter(String name,
                         String value)
Sets a parameter in this form.

Parameters:
name - the name of the parameter
value - the value of the parameter
Since:
1.1
See Also:
getParameters(), getParameterNames(), hasParameter(java.lang.String), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[])

parameter

public MockForm parameter(String name,
                          String value)
Sets a parameter in this form.

Parameters:
name - the name of the parameter
value - the value of the parameter
Returns:
this MockForm instance
Since:
1.1
See Also:
getParameters(), getParameterNames(), hasParameter(java.lang.String), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[]), setParameter(String, String)

setParameter

public void setParameter(String name,
                         String[] values)
Sets a parameter in this form.

Parameters:
name - the name of the parameter
values - the value array of the parameter
Since:
1.1
See Also:
getParameters(), getParameterNames(), hasParameter(java.lang.String), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String)

parameter

public MockForm parameter(String name,
                          String[] values)
Sets a parameter in this form.

Parameters:
name - the name of the parameter
values - the value array of the parameter
Returns:
this MockForm instance
Since:
1.1
See Also:
getParameters(), getParameterNames(), hasParameter(java.lang.String), getParameterValue(java.lang.String), getParameterValues(java.lang.String), setParameter(String, String[]), setParameter(String, String)

setFile

public void setFile(String name,
                    MockFileUpload file)
Sets a file in this form.

Parameters:
name - the parameter name of the file
file - the file specification that will be uploaded
Since:
1.1
See Also:
setFiles(String, MockFileUpload[])

file

public MockForm file(String name,
                     MockFileUpload file)
Sets a file in this form.

Parameters:
name - the parameter name of the file
file - the file specification that will be uploaded
Returns:
this MockForm instance
Since:
1.1
See Also:
setFiles(String, MockFileUpload[])

setFiles

public void setFiles(String name,
                     MockFileUpload[] files)
Sets files in this request.

Parameters:
name - the parameter name of the file
files - the file specifications that will be uploaded
Since:
1.1
See Also:
setFile(String, MockFileUpload)

files

public MockForm files(String name,
                      MockFileUpload[] files)
Sets files in this request.

Parameters:
name - the parameter name of the file
files - the file specifications that will be uploaded
Returns:
this MockForm instance
Since:
1.1
See Also:
setFile(String, MockFileUpload)

getId

public String getId()
Retrieves the content of this form's id attribute.

Returns:
the content of the id attribute; or

null if no such attribute could be found

Since:
1.0

getClassName

public String getClassName()
Retrieves the content of this form's class attribute.

Returns:
the content of the class attribute; or

null if no such attribute could be found

Since:
1.0

getTitle

public String getTitle()
Retrieves the content of this form's title attribute.

Returns:
the content of the title attribute; or

null if no such attribute could be found

Since:
1.0

getAction

public String getAction()
Retrieves the content of this form's action attribute.

Returns:
the content of the action attribute; or

null if no such attribute could be found

Since:
1.0

getMethod

public String getMethod()
Retrieves the content of this form's method attribute.

Returns:
the content of the method attribute; or

null if no such attribute could be found

Since:
1.0

getName

public String getName()
Retrieves the content of this form's name attribute.

Returns:
the content of the name attribute; or

null if no such attribute could be found

Since:
1.0


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.