[Jsptest-svn-commits] SF.net SVN: jsptest: [213] trunk/jsptest-generic/jsptest-framework/src/main /
Status: Alpha
Brought to you by:
lkoskela
From: <lko...@us...> - 2008-04-09 21:07:57
|
Revision: 213 http://jsptest.svn.sourceforge.net/jsptest/?rev=213&view=rev Author: lkoskela Date: 2008-04-09 14:07:55 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Added javadocs Modified Paths: -------------- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/HtmlTestCase.java trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/JspTestCase.java trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/PageAssertion.java trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java Modified: trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/HtmlTestCase.java =================================================================== --- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/HtmlTestCase.java 2008-04-09 20:02:28 UTC (rev 212) +++ trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/HtmlTestCase.java 2008-04-09 21:07:55 UTC (rev 213) @@ -51,16 +51,30 @@ private DocumentBuilder documentBuilder; + /** + * Simulate an HTTP request to a JSP, parsing the rendered output as HTML. + * + * @param path + * The path to the JSP to execute. + * @param httpMethod + * "GET" or "POST". + */ protected void request(String path, String httpMethod) throws Exception { super.request(path, httpMethod); parseRenderedHtml(); } + /** + * Returns the rendered HTML as an <tt>org.w3c.dom.Document</tt>. + */ protected Document getRenderedHtml() { return renderedDocument; } + /** + * Returns the path to the rendered (and pretty-printed) HTML document. + */ protected String getRenderedHtmlPath() { return renderedDocumentPath; } Modified: trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/JspTestCase.java =================================================================== --- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/JspTestCase.java 2008-04-09 20:02:28 UTC (rev 212) +++ trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/JspTestCase.java 2008-04-09 21:07:55 UTC (rev 213) @@ -54,6 +54,10 @@ log = Logger.getLogger(getClass()); } + /** + * The standard JUnit <tt>setUp()</tt> method. <b>Remember to invoke + * <tt>super.setUp()</tt> if you override this!</b> + */ protected void setUp() throws Exception { requestAttributes = new HashMap(); sessionAttributes = new HashMap(); @@ -116,6 +120,14 @@ request(path, "POST"); } + /** + * Simulate an HTTP request to a JSP. + * + * @param path + * The path to the JSP to execute. + * @param httpMethod + * "GET" or "POST". + */ protected void request(String path, String httpMethod) throws Exception { validatePath(path); @@ -142,6 +154,9 @@ return "target/jsptest"; } + /** + * Returns a handle to a file containing the rendered output. + */ protected File getRenderedResponse() { return execution.getRenderedResponse(); } Modified: trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java =================================================================== --- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java 2008-04-09 20:02:28 UTC (rev 212) +++ trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java 2008-04-09 21:07:55 UTC (rev 213) @@ -1,22 +1,42 @@ package net.sf.jsptest.assertion; /** + * Provides assertion methods related to raw text output. + * * @author Lasse Koskela */ public class OutputAssertion extends AbstractAssertion { private final String content; + /** + * @param content + * The raw output to perform assertions on. + */ public OutputAssertion(String content) { this.content = content; } + /** + * Assert that the output should contain the given text. + * + * @param text + * The (partial) content that should be found from the + * output. + */ public void shouldContain(String text) { String msg = "Rendered output did not contain the expected text <" + text + ">:\n" + content; assertContains(msg, content, text); } + /** + * Assert that the output should not contain the given text. + * + * @param text + * The (partial) content that shouldn't be found from the + * output. + */ public void shouldNotContain(String text) { String msg = "Rendered output contained unexpected text <" + text + ">:\n" + content; Modified: trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/PageAssertion.java =================================================================== --- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/PageAssertion.java 2008-04-09 20:02:28 UTC (rev 212) +++ trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/PageAssertion.java 2008-04-09 21:07:55 UTC (rev 213) @@ -7,14 +7,26 @@ import org.w3c.dom.Document; /** + * Provides assertion methods related to an HTML page. + * * @author Lasse Koskela */ public class PageAssertion extends DOMAssertion { + /** + * @param content + * The DOM tree to interpret as an HTML page. + */ public PageAssertion(Document content) { this.context = content.getDocumentElement(); } + /** + * Assert that the page should have the specified title. + * + * @param expectedTitle + * The expected title. + */ public void shouldHaveTitle(String expectedTitle) { try { String title = new DOMXPath("/HTML/HEAD/TITLE/text()") @@ -25,6 +37,9 @@ } } + /** + * Returns a handle for making assertions related to link elements. + */ public LinkAssertion shouldHaveLink() { return new LinkAssertion(context); } Modified: trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java =================================================================== --- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java 2008-04-09 20:02:28 UTC (rev 212) +++ trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java 2008-04-09 21:07:55 UTC (rev 213) @@ -3,21 +3,41 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; +/** + * Representation of an HTML form. + * + * @author Lasse Koskela + */ public class Form { private Element element; private NodeList fields; + /** + * Build a <tt>Form</tt> from an HTML element. + * + * @param element + * The HTML form element to represent. + */ public Form(Element element) { this.element = element; fields = element.getElementsByTagName("INPUT"); } + /** + * Returns the name of the HTML form. + */ public String getName() { return element.getAttribute("NAME"); } + /** + * Indicates whether the form has an input field by the given name. + * + * @param name + * The name of the input field. + */ public boolean hasInputField(String name) { if (getInputField(name) != null) { return true; @@ -25,6 +45,13 @@ return false; } + /** + * Returns the specified input field or <tt>null</tt> if no such field + * exists on the form. + * + * @param name + * The name of the input field. + */ public FormField getInputField(String name) { for (int i = 0; i < fields.getLength(); i++) { FormField field = new FormField((Element) fields.item(i)); @@ -35,6 +62,12 @@ return null; } + /** + * Indicates whether the form has a submit button by the given name. + * + * @param name + * The name of the submit button. + */ public boolean hasSubmitButton(String name) { NodeList elems = element.getElementsByTagName("INPUT"); for (int i = 0; i < elems.getLength(); i++) { @@ -52,6 +85,9 @@ return false; } + /** + * Indicates whether the form has a submit button. + */ public boolean hasSubmitButton() { NodeList elems = element.getElementsByTagName("INPUT"); for (int i = 0; i < elems.getLength(); i++) { Modified: trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java =================================================================== --- trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java 2008-04-09 20:02:28 UTC (rev 212) +++ trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java 2008-04-09 21:07:55 UTC (rev 213) @@ -2,20 +2,36 @@ import org.w3c.dom.Element; +/** + * Representation of a form input field. + * + * @author Lasse Koskela + */ public class FormField { private Element element; + /** + * Build an input field from the given HTML element. + * + * @param element + * The HTML input element. + */ public FormField(Element element) { this.element = element; } - public String getValue() { - return element.getAttribute("VALUE"); - } - + /** + * Returns the name of the field. + */ public String getName() { return element.getAttribute("NAME"); } + /** + * Returns the value of the field. + */ + public String getValue() { + return element.getAttribute("VALUE"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |