| org.apache.cocoon.HtmlUnitTestCase
All known Subclasses: org.apache.cocoon.WebdavStep3TestCase, org.apache.cocoon.CachingPipelineTestCase, org.apache.cocoon.CalcTestCase, org.apache.cocoon.ReaderMimeTypeTestCase, org.apache.cocoon.Bug36872HttpHeaderActionTestCase, org.apache.cocoon.FlowscriptReloadTestCase, org.apache.cocoon.Bug26186InternalRequestMemoryLeakTestCase, org.apache.cocoon.Bug26571SendPageRedirectTestCase, org.apache.cocoon.FlowscriptDOMDumpTestCase, org.apache.cocoon.HtmlSerializerTestCase, org.apache.cocoon.FlowscriptRecursiveTestCase, org.apache.cocoon.BatikSampleMimeTypesTestCase, org.apache.cocoon.RedirectTestCase, org.apache.cocoon.InternalSendPageTestCase, org.apache.cocoon.XslTalTestCase, org.apache.cocoon.WebdavDavmapTestCase, org.apache.cocoon.SitemapAnnotationsTestCase, org.apache.cocoon.InternalRequestTestCase, org.apache.cocoon.SitemapReloadTestCase, org.apache.cocoon.FormsSharingViewDataTestCase,
HtmlUnitTestCase | abstract public class HtmlUnitTestCase extends TestCase (Code) | | Base class to run test cases on Cocoon samples.
This class extends the JUnit TestCase class to setup an environment which
makes it possible to easily test Cocoon pages.
First call one of the load methods and then assert on the response object,
XML document (@see loadXmlPage), or HTML document (@see loadHtmlPage).
Examples:
public void testStatus() {
loadResponse("/samples/test/status");
assertEquals("Status code", 200, response.getStatusCode());
}
public void testTitle() {
loadHtmlPage("/samples/test/title");
assertXPath("html/head/title"", "The Title");
}
For loading XML and HTML documents currently on GET requests with
optional querystring are supported. Please add POST requests and
request parameters when you need them.
version: $Id: $ |
Field Summary | |
protected URL | baseURL Base URL of the running Cocoon server which is to be tested. | protected Object | document Low-level access to XML document (org.w3c.dom.Document) or HTML document
(com.gargoylesoftware.htmlunit.html.HtmlPage). | protected Logger | logger Logger for informative output by test cases. | protected Map | namespaces Low-level access to namespace mappings for XPath expressions. | protected WebResponse | response Low-level access to WebResponse object. | protected WebClient | webClient Low-level access to WebClient object. |
baseURL | protected URL baseURL(Code) | | Base URL of the running Cocoon server which is to be tested.
Set by property htmlunit.test.baseurl usually as http://localhost:8888/.
|
document | protected Object document(Code) | | Low-level access to XML document (org.w3c.dom.Document) or HTML document
(com.gargoylesoftware.htmlunit.html.HtmlPage).
|
logger | protected Logger logger(Code) | | Logger for informative output by test cases.
The default log level is WARN but may be changed by setting the
property junit.test.loglevel to a different numeric value.
|
namespaces | protected Map namespaces(Code) | | Low-level access to namespace mappings for XPath expressions.
|
response | protected WebResponse response(Code) | | Low-level access to WebResponse object.
|
webClient | protected WebClient webClient(Code) | | Low-level access to WebClient object.
|
addNamespace | protected void addNamespace(String prefix, String uri) throws Exception(Code) | | Add a namespace mapping for XPath expressions.
|
assertXPath | protected void assertXPath(String xpathExpr, String expected) throws Exception(Code) | | Assert that XPath expression result matches exactly expected value.
|
copyWebappFile | protected void copyWebappFile(String filename, String param, String value) throws Exception(Code) | | Copy file from webapp source to deployment area filtering content
to replace parameter by value.
The source and deployment directories are defined by the properties
htmlunit.test.source-dir and htmlunit.test.deploy-dir.
This method is most useful for testing the automatic reloading of
changed files.
|
evalXPath | protected String evalXPath(String xpathExpr) throws Exception(Code) | | Returns XPath expression as string.
Parameters: xpathExpr - XPath expression Value of XPath expression in current document.Empty string if XPath not matched. |
loadDeleteResponse | protected void loadDeleteResponse(String pageURL) throws Exception(Code) | | Sends HTTP DELETE request and loads response object.
|
loadHtmlPage | protected void loadHtmlPage(String pageURL) throws Exception(Code) | | Sends HTTP request and parses response as HTML document.
|
loadPutResponse | protected void loadPutResponse(String pageURL, String content) throws Exception(Code) | | Sends HTTP PUT request and loads response object.
|
loadResponse | protected void loadResponse(String pageURL) throws Exception(Code) | | Sends HTTP GET request and loads response object.
|
loadXmlPage | protected void loadXmlPage(String pageURL) throws Exception(Code) | | Sends HTTP request and parses response as XML document.
|
|
|