public class PageTester extends Object
org.apache.tapestry:tapestry-test-constants
module as a dependency.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONTEXT_PATH |
Constructor and Description |
---|
PageTester(String appPackage,
String appName)
Initializes a PageTester without overriding any services and assuming that the context root
is in
src/main/webapp.
|
PageTester(String appPackage,
String appName,
String contextPath,
Class... moduleClasses)
Initializes a PageTester that acts as a browser and a servlet container to test drive your
Tapestry pages.
|
Modifier and Type | Method and Description |
---|---|
Document |
clickLink(Element linkElement)
Simulates a click on a link.
|
TestableResponse |
clickLinkAndReturnResponse(Element linkElement)
Simulates a click on a link.
|
Document |
clickSubmit(Element submitButton,
Map<String,String> fieldValues)
Simulates a submission of the form by clicking the specified submit button.
|
TestableResponse |
clickSubmitAndReturnResponse(Element submitButton,
Map<String,String> fieldValues)
Simulates a submission of the form by clicking the specified submit button.
|
Registry |
getRegistry()
Returns the Registry that was created for the application.
|
<T> T |
getService(Class<T> serviceInterface)
Allows a service to be retrieved via its service interface.
|
protected ModuleDef[] |
provideExtraModuleDefs()
Overridden in subclasses to provide additional module definitions beyond those normally
located.
|
Document |
renderPage(String pageName)
Renders a page specified by its name.
|
TestableResponse |
renderPageAndReturnResponse(String pageName)
Renders a page specified by its name and returns the response.
|
void |
setPreferedLanguage(Locale preferedLanguage)
Sets the simulated browser's preferred language, i.e., the value returned from
Request.getLocale() . |
void |
setupRequestFromURI(String URI) |
void |
shutdown()
Invoke this method when done using the PageTester; it shuts down the internal
Registry used by the tester. |
Document |
submitForm(Element form,
Map<String,String> parameters)
Simulates a submission of the form specified.
|
TestableResponse |
submitFormAndReturnResponse(Element form,
Map<String,String> parameters)
Simulates a submission of the form specified.
|
public static final String DEFAULT_CONTEXT_PATH
public PageTester(String appPackage, String appName)
public PageTester(String appPackage, String appName, String contextPath, Class... moduleClasses)
appPackage
- The same value you would specify using the tapestry.app-package context parameter.
As this
testing environment is not run in a servlet container, you need to specify it.appName
- The same value you would specify as the filter name. It is used to form the name
of the
module class for your app. If you don't have one, pass an empty string.contextPath
- The path to the context root so that Tapestry can find the templates (if they're
put
there).moduleClasses
- Classes of additional modules to loadprotected ModuleDef[] provideExtraModuleDefs()
public void shutdown()
Registry
used by the tester.public Registry getRegistry()
public <T> T getService(Class<T> serviceInterface)
getRegistry()
for
more complicated
queries.serviceInterface
- used to select the servicepublic Document renderPage(String pageName)
pageName
- The name of the page to be rendered.public TestableResponse renderPageAndReturnResponse(String pageName)
pageName
- The name of the page to be rendered.public Document clickLink(Element linkElement)
linkElement
- The Link object to be "clicked" on.public TestableResponse clickLinkAndReturnResponse(Element linkElement)
linkElement
- The Link object to be "clicked" on.public void setupRequestFromURI(String URI)
public Document submitForm(Element form, Map<String,String> parameters)
form
- the form to be submitted.parameters
- the query parameter name/value pairspublic TestableResponse submitFormAndReturnResponse(Element form, Map<String,String> parameters)
form
- the form to be submitted.parameters
- the query parameter name/value pairspublic Document clickSubmit(Element submitButton, Map<String,String> fieldValues)
submitButton
- the submit button to be clicked.fieldValues
- the field values keyed on field names.public TestableResponse clickSubmitAndReturnResponse(Element submitButton, Map<String,String> fieldValues)
submitButton
- the submit button to be clicked.fieldValues
- the field values keyed on field names.public void setPreferedLanguage(Locale preferedLanguage)
Request.getLocale()
.preferedLanguage
- preferred language setting${project.version} - Copyright © 2003-2015 The Apache Software Foundation.