You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2007/10/14 23:31:35 UTC
svn commit: r584613 [1/2] -
/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/
Author: ivaynberg
Date: Sun Oct 14 14:31:34 2007
New Revision: 584613
URL: http://svn.apache.org/viewvc?rev=584613&view=rev
Log:
WICKET-1053: Wicket Javadoc Standardization: org.apache.wicket.util.tester
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ExternalPageViewer.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/Result.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/package.html
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java Sun Oct 14 14:31:34 2007
@@ -65,43 +65,42 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
- * A helper to ease unit testing of Wicket applications without the need for a servlet container.
- * See javadoc of WicketTester for example usage. This class can be used as is, but JUnit users
- * should use derived class WicketTester.
+ * A helper class to ease unit testing of Wicket applications without the need
+ * for a servlet container. See javadoc of <code>WicketTester</code> for
+ * example usage. This class can be used as is, but JUnit users should use
+ * derived class <code>WicketTester</code>.
*
* @see WicketTester
*
* @author Ingram Chen
* @author Juergen Donnerstag
* @author Frank Bille
+ * @since 1.2.6
*/
-public class BaseWicketTester extends MockWebApplication
-{
+public class BaseWicketTester extends MockWebApplication {
/** log. */
- private static final Logger log = LoggerFactory.getLogger(BaseWicketTester.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(BaseWicketTester.class);
/**
* @author jcompagner
*/
- private static final class TestPageSource implements ITestPageSource
- {
+ private static final class TestPageSource implements ITestPageSource {
private final Page page;
+
private static final long serialVersionUID = 1L;
/**
- * Construct.
+ * Constructor.
*
* @param page
*/
- private TestPageSource(Page page)
- {
+ private TestPageSource(Page page) {
this.page = page;
}
- public Page getTestPage()
- {
+ public Page getTestPage() {
return page;
}
}
@@ -109,59 +108,53 @@
/**
* @author frankbille
*/
- public static class DummyWebApplication extends WebApplication
- {
- public Class getHomePage()
- {
+ public static class DummyWebApplication extends WebApplication {
+ public Class getHomePage() {
return DummyHomePage.class;
}
- protected void outputDevelopmentModeWarning()
- {
+ protected void outputDevelopmentModeWarning() {
// Do nothing.
}
- protected ISessionStore newSessionStore()
- {
- // Don't use a filestore, or we spawn lots of threads, which makes things slow.
+ protected ISessionStore newSessionStore() {
+ // Don't use a filestore, or we spawn lots of threads, which makes
+ // things slow.
return new HttpSessionStore(this);
}
}
/**
- * Create WicketTester and automatically create a WebApplication, but the tester will have no
- * home page.
+ * Creates <code>WicketTester</code> and automatically create a
+ * <code>WebApplication</code>, but the tester will have no home page.
*/
- public BaseWicketTester()
- {
+ public BaseWicketTester() {
this(new DummyWebApplication(), null);
}
/**
- * Create WicketTester and automatically create a WebApplication.
+ * Creates <code>WicketTester</code> and automatically creates a
+ * <code>WebApplication</code>.
*
* @param homePage
+ * a home page <code>Class</code>
*/
- public BaseWicketTester(final Class homePage)
- {
- this(new WebApplication()
- {
+ public BaseWicketTester(final Class homePage) {
+ this(new WebApplication() {
/**
* @see org.apache.wicket.Application#getHomePage()
*/
- public Class getHomePage()
- {
+ public Class getHomePage() {
return homePage;
}
- protected void outputDevelopmentModeWarning()
- {
+ protected void outputDevelopmentModeWarning() {
// Do nothing.
}
- protected ISessionStore newSessionStore()
- {
- // Don't use a filestore, or we spawn lots of threads, which makes things slow.
+ protected ISessionStore newSessionStore() {
+ // Don't use a filestore, or we spawn lots of threads, which
+ // makes things slow.
return new HttpSessionStore(this);
}
@@ -169,43 +162,42 @@
}
/**
- * Create WicketTester
+ * Creates a <code>WicketTester</code>.
*
* @param application
- * The wicket tester object
+ * a <code>WicketTester</code> <code>WebApplication</code>
+ * object
*/
- public BaseWicketTester(final WebApplication application)
- {
+ public BaseWicketTester(final WebApplication application) {
this(application, null);
}
/**
- * Create WicketTester to help unit testing
+ * Creates a <code>WicketTester</code> for unit testing.
*
* @param application
- * The wicket tester object
+ * a <code>WicketTester</code> <code>WebApplication</code>
+ * object
* @param path
- * The absolute path on disk to the web application contents (e.g. war root) - may be
- * null
+ * the absolute path on disk to the <code>WebApplication</code>'s
+ * contents (e.g. war root) - may be <code>null</code>
*
* @see org.apache.wicket.protocol.http.MockWebApplication#MockWebApplication(
* org.apache.wicket.protocol.http.WebApplication, String)
*/
- public BaseWicketTester(final WebApplication application, final String path)
- {
+ public BaseWicketTester(final WebApplication application, final String path) {
super(application, path);
}
/**
- * Render a page defined in <code>TestPageSource</code>. This is usually used when a page
- * does not have default constructor. For example, a <code>ViewBook</code> page requires a
- * <code>Book</code> instance:
+ * Renders a <code>Page</code> defined in <code>TestPageSource</code>.
+ * This is usually used when a page does not have default constructor. For
+ * example, a <code>ViewBook</code> page requires a <code>Book</code>
+ * instance:
*
* <pre>
- * tester.startPage(new TestPageSource()
- * {
- * public Page getTestPage()
- * {
+ * tester.startPage(new TestPageSource() {
+ * public Page getTestPage() {
* Book mockBook = new Book("myBookName");
* return new ViewBook(mockBook);
* }
@@ -213,13 +205,13 @@
* </pre>
*
* @param testPageSource
- * a page factory that creating test page instance
- * @return Page rendered page
+ * a <code>Page</code> factory that creates a test page
+ * instance
+ * @return the rendered Page
*/
- public final Page startPage(final ITestPageSource testPageSource)
- {
+ public final Page startPage(final ITestPageSource testPageSource) {
startPage(DummyHomePage.class);
- DummyHomePage page = (DummyHomePage)getLastRenderedPage();
+ DummyHomePage page = (DummyHomePage) getLastRenderedPage();
page.setTestPageSource(testPageSource);
executeListener(page.getTestPageLink());
@@ -227,27 +219,27 @@
}
/**
- * Builds and processes a request suitable for invoking a listener. The component must implement
- * any of the known *Listener interfaces.
+ * Builds and processes a request suitable for invoking a listener. The
+ * <code>Component</code> must implement any of the known
+ * <code>IListener</code> interfaces.
*
* @param component
* the listener to invoke
*/
- public void executeListener(Component component)
- {
+ public void executeListener(Component component) {
setupRequestAndResponse();
getServletRequest().setRequestToComponent(component);
processRequestCycle();
}
/**
- * Builds and processes a request suitable for executing an ajax behavior.
+ * Builds and processes a request suitable for executing an
+ * <code>AbstractAjaxBehavior</code>.
*
* @param behavior
- * the ajax behavior to execute
+ * an <code>AbstractAjaxBehavior</code> to execute
*/
- public void executeBehavior(final AbstractAjaxBehavior behavior)
- {
+ public void executeBehavior(final AbstractAjaxBehavior behavior) {
// setupRequestAndResponse();
WebRequestCycle cycle = createRequestCycle();
CharSequence url = behavior.getCallbackUrl(false);
@@ -258,71 +250,71 @@
}
/**
- * Render the page
+ * Renders the <code>Page</code>.
*
* @param page
- * @return The page rendered
+ * a <code>Page</code> to render
+ * @return the rendered <code>Page</code>
*/
- public final Page startPage(final Page page)
- {
+ public final Page startPage(final Page page) {
return startPage(new TestPageSource(page));
}
/**
- * Render a page from its default constructor.
+ * Renders a <code>Page</code> from its default constructor.
*
* @param pageClass
- * a test page class with default constructor
- * @return Page Rendered Page
+ * a test <code>Page</code> class with default constructor
+ * @return the rendered <code>Page</code>
*/
- public final Page startPage(Class pageClass)
- {
+ public final Page startPage(Class pageClass) {
processRequestCycle(pageClass);
return getLastRenderedPage();
}
/**
- * create a {@link FormTester} for the form at path, and fill all child
- * {@link org.apache.wicket.markup.html.form.FormComponent}s with blank String initially.
+ * Creates a {@link FormTester} for the <code>Form</code> at a given path,
+ * and fills all child
+ * {@link org.apache.wicket.markup.html.form.FormComponent}s with blank
+ * <code>String</code>s.
*
* @param path
- * path to {@link Form} component
- * @return FormTester A FormTester instance for testing form
+ * path to <code>FormComponent</code>
+ * @return a <code>FormTester</code> instance for testing the
+ * <code>Form</code>
* @see #newFormTester(String, boolean)
*/
- public FormTester newFormTester(String path)
- {
+ public FormTester newFormTester(String path) {
return newFormTester(path, true);
}
/**
- * create a {@link FormTester} for the form at path.
+ * Creates a {@link FormTester} for the <code>Form</code> at a given path.
*
* @param path
- * path to {@link Form} component
+ * path to <code>FormComponent</code>
* @param fillBlankString
- * specify whether fill all child
- * {@link org.apache.wicket.markup.html.form.FormComponent}s with blankString
- * initially.
- * @return FormTester A FormTester instance for testing form
+ * specifies whether to fill all child <code>FormComponent</code>s
+ * with blank <code>String</code>s
+ * @return a <code>FormTester</code> instance for testing the
+ * <code>Form</code>
* @see FormTester
*/
- public FormTester newFormTester(String path, boolean fillBlankString)
- {
- return new FormTester(path, (Form)getComponentFromLastRenderedPage(path), this,
+ public FormTester newFormTester(String path, boolean fillBlankString) {
+ return new FormTester(path,
+ (Form) getComponentFromLastRenderedPage(path), this,
fillBlankString);
}
/**
- * Render a panel defined in <code>TestPanelSource</code>. The usage is similar with
- * {@link #startPage(ITestPageSource)}. Please note that testing panel must use supplied
- * <code>panelId<code> as component id.
+ * Renders a <code>Panel</code> defined in <code>TestPanelSource</code>.
+ * The usage is similar to {@link #startPage(ITestPageSource)}. Please note
+ * that testing <code>Panel</code> must use the supplied
+ * <code>panelId<code> as a <code>Component</code> id.
*
* <pre>
- * tester.startPanel(new TestPanelSource()
- * {
- * public Panel getTestPanel(String panelId)
- * {
+ * tester.startPanel(new TestPanelSource() {
+ * public Panel getTestPanel(String panelId) {
* MyData mockMyData = new MyData();
* return new MyPanel(panelId, mockMyData);
* }
@@ -330,66 +322,51 @@
* </pre>
*
* @param testPanelSource
- * a panel factory that creating test panel instance
- * @return Panel rendered panel
+ * a <code>Panel</code> factory that creates test <code>Panel</code> instances
+ * @return a rendered <code>Panel</code>
*/
- public final Panel startPanel(final TestPanelSource testPanelSource)
- {
- return (Panel)startPage(new ITestPageSource()
- {
+ public final Panel startPanel(final TestPanelSource testPanelSource) {
+ return (Panel) startPage(new ITestPageSource() {
private static final long serialVersionUID = 1L;
- public Page getTestPage()
- {
+ public Page getTestPage() {
return new DummyPanelPage(testPanelSource);
}
}).get(DummyPanelPage.TEST_PANEL_ID);
}
/**
- * Render a panel from <code>Panel(String id)</code> constructor.
+ * Renders a <code>Panel</code> from a <code>Panel(String id)</code>
+ * constructor.
*
* @param panelClass
- * a test panel class with <code>Panel(String id)</code> constructor
- * @return Panel rendered panel
+ * a test <code>Panel</code> class with
+ * <code>Panel(String id)</code> constructor
+ * @return a rendered <code>Panel</code>
*/
- public final Panel startPanel(final Class panelClass)
- {
- return (Panel)startPage(new ITestPageSource()
- {
+ public final Panel startPanel(final Class panelClass) {
+ return (Panel) startPage(new ITestPageSource() {
private static final long serialVersionUID = 1L;
- public Page getTestPage()
- {
- return new DummyPanelPage(new TestPanelSource()
- {
+ public Page getTestPage() {
+ return new DummyPanelPage(new TestPanelSource() {
private static final long serialVersionUID = 1L;
- public Panel getTestPanel(String panelId)
- {
- try
- {
- Constructor c = panelClass.getConstructor(new Class[] { String.class });
- return (Panel)c.newInstance(new Object[] { panelId });
- }
- catch (SecurityException e)
- {
+ public Panel getTestPanel(String panelId) {
+ try {
+ Constructor c = panelClass
+ .getConstructor(new Class[] { String.class });
+ return (Panel) c
+ .newInstance(new Object[] { panelId });
+ } catch (SecurityException e) {
throw convertoUnexpect(e);
- }
- catch (NoSuchMethodException e)
- {
+ } catch (NoSuchMethodException e) {
throw convertoUnexpect(e);
- }
- catch (InstantiationException e)
- {
+ } catch (InstantiationException e) {
throw convertoUnexpect(e);
- }
- catch (IllegalAccessException e)
- {
+ } catch (IllegalAccessException e) {
throw convertoUnexpect(e);
- }
- catch (InvocationTargetException e)
- {
+ } catch (InvocationTargetException e) {
throw convertoUnexpect(e);
}
}
@@ -650,9 +627,8 @@
// AjaxFallbackLinks is processed like an AjaxLink if isAjax is true
// If it's not handling of the linkComponent is passed through to the
// Link.
- else if (linkComponent instanceof AjaxFallbackLink && isAjax)
- {
- AjaxFallbackLink link = (AjaxFallbackLink)linkComponent;
+ else if (linkComponent instanceof AjaxFallbackLink && isAjax) {
+ AjaxFallbackLink link = (AjaxFallbackLink) linkComponent;
setupRequestAndResponse();
RequestCycle requestCycle = createRequestCycle();
@@ -666,27 +642,25 @@
}
// if the link is an AjaxSubmitLink, we need to find the form
// from it using reflection so we know what to submit.
- else if (linkComponent instanceof AjaxSubmitLink)
- {
+ else if (linkComponent instanceof AjaxSubmitLink) {
// If it's not ajax we fail
- if (isAjax == false)
- {
- fail("Link " + path + "is an AjaxSubmitLink and " +
- "will not be invoked when AJAX (javascript) is disabled.");
+ if (isAjax == false) {
+ fail("Link "
+ + path
+ + "is an AjaxSubmitLink and "
+ + "will not be invoked when AJAX (javascript) is disabled.");
}
- AjaxSubmitLink link = (AjaxSubmitLink)linkComponent;
+ AjaxSubmitLink link = (AjaxSubmitLink) linkComponent;
// We cycle through the attached behaviors and select the
// LAST matching behavior as the one we handle.
List behaviors = link.getBehaviors();
AjaxFormSubmitBehavior ajaxFormSubmitBehavior = null;
- for (Iterator iter = behaviors.iterator(); iter.hasNext();)
- {
+ for (Iterator iter = behaviors.iterator(); iter.hasNext();) {
Object behavior = iter.next();
- if (behavior instanceof AjaxFormSubmitBehavior)
- {
- AjaxFormSubmitBehavior submitBehavior = (AjaxFormSubmitBehavior)behavior;
+ if (behavior instanceof AjaxFormSubmitBehavior) {
+ AjaxFormSubmitBehavior submitBehavior = (AjaxFormSubmitBehavior) behavior;
ajaxFormSubmitBehavior = submitBehavior;
}
}
@@ -706,28 +680,23 @@
requestCycle.getRequestTarget().respond(requestCycle);
}
// if the link is a normal link (or ResourceLink)
- else if (linkComponent instanceof AbstractLink)
- {
- AbstractLink link = (AbstractLink)linkComponent;
+ else if (linkComponent instanceof AbstractLink) {
+ AbstractLink link = (AbstractLink) linkComponent;
/*
- * If the link is a bookmarkable link, then we need to transfer the parameters to the
- * next request.
+ * If the link is a bookmarkable link, then we need to transfer the
+ * parameters to the next request.
*/
- if (link instanceof BookmarkablePageLink)
- {
- BookmarkablePageLink bookmarkablePageLink = (BookmarkablePageLink)link;
- try
- {
+ if (link instanceof BookmarkablePageLink) {
+ BookmarkablePageLink bookmarkablePageLink = (BookmarkablePageLink) link;
+ try {
Field parametersField = BookmarkablePageLink.class
.getDeclaredField("parameters");
parametersField.setAccessible(true);
- PageParameters parameters = (PageParameters)parametersField
+ PageParameters parameters = (PageParameters) parametersField
.get(bookmarkablePageLink);
setParametersForNextRequest(parameters);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
fail("Internal error in WicketTester. "
+ "Please report this in Wickets Issue Tracker.");
}
@@ -735,223 +704,216 @@
}
executeListener(link);
- }
- else
- {
- fail("Link " + path + " is not a Link, AjaxLink, AjaxFallbackLink or AjaxSubmitLink");
+ } else {
+ fail("Link "
+ + path
+ + " is not a Link, AjaxLink, AjaxFallbackLink or AjaxSubmitLink");
}
}
/**
- * submit the <code>Form</code> in the last rendered Page.
+ * Submits the <code>Form</code> in the last rendered <code>Page</code>.
*
* @param path
* path to <code>Form</code> component
*/
- public void submitForm(String path)
- {
- Form form = (Form)getComponentFromLastRenderedPage(path);
+ public void submitForm(String path) {
+ Form form = (Form) getComponentFromLastRenderedPage(path);
executeListener(form);
}
/**
- * Sets a parameter for the component with the given path to be used with the next request.
- * NOTE: this method only works when a page was rendered first.
+ * Sets a parameter for the <code>Component</code> with the given path to
+ * be used with the next request.
+ * <p>
+ * NOTE: this method only works when a <code>Page</code> was rendered
+ * first.
*
* @param componentPath
- * path of the component
+ * path to the <code>Component</code>
* @param value
* the parameter value to set
*/
- public void setParameterForNextRequest(String componentPath, Object value)
- {
- if (getLastRenderedPage() == null)
- {
+ public void setParameterForNextRequest(String componentPath, Object value) {
+ if (getLastRenderedPage() == null) {
fail("before using this method, at least one page has to be rendered");
}
Component c = getComponentFromLastRenderedPage(componentPath);
- if (c == null)
- {
+ if (c == null) {
fail("component " + componentPath + " was not found");
return;
}
- if (c instanceof FormComponent)
- {
- getParametersForNextRequest().put(((FormComponent)c).getInputName(), value);
- }
- else
- {
+ if (c instanceof FormComponent) {
+ getParametersForNextRequest().put(
+ ((FormComponent) c).getInputName(), value);
+ } else {
getParametersForNextRequest().put(c.getPath(), value);
}
}
/**
- * assert last rendered Page class
+ * Asserts the last rendered <code>Page</code> class.
*
- * FIXME explain why the code is so complicated to compare two classes, or simplify
+ * FIXME explain why the code is so complicated to compare two classes, or
+ * simplify
*
* @param expectedRenderedPageClass
- * expected class of last renered page
- * @return
+ * expected class of last rendered page
+ * @return a <code>Result</code>
*/
- public Result isRenderedPage(Class expectedRenderedPageClass)
- {
+ public Result isRenderedPage(Class expectedRenderedPageClass) {
Page page = getLastRenderedPage();
- if (page == null)
- {
+ if (page == null) {
return Result.fail("page was null");
}
- if (!page.getClass().isAssignableFrom(expectedRenderedPageClass))
- {
- return isEqual(Classes.simpleName(expectedRenderedPageClass), Classes.simpleName(page
- .getClass()));
+ if (!page.getClass().isAssignableFrom(expectedRenderedPageClass)) {
+ return isEqual(Classes.simpleName(expectedRenderedPageClass),
+ Classes.simpleName(page.getClass()));
}
return Result.pass();
}
/**
- * assert last rendered Page against an expected HTML document
+ * Asserts last rendered <code>Page</code> against an expected HTML
+ * document.
* <p>
- * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the
- * expected output file.
+ * Use <code>-Dwicket.replace.expected.results=true</code> to
+ * automatically replace the expected output file.
* </p>
*
* @param pageClass
- * Used to load the file (relative to clazz package)
+ * used to load the <code>File</code> (relative to
+ * <code>clazz</code> package)
* @param filename
- * Expected output
+ * expected output <code>File</code> name
* @throws Exception
*/
- public void assertResultPage(final Class pageClass, final String filename) throws Exception
- {
+ public void assertResultPage(final Class pageClass, final String filename)
+ throws Exception {
// Validate the document
String document = getServletResponse().getDocument();
DiffUtil.validatePage(document, pageClass, filename, true);
}
/**
- * assert last rendered Page against an expected HTML document as a String
+ * Asserts last rendered <code>Page</code> against an expected HTML
+ * document as a <code>String</code>.
*
* @param expectedDocument
- * Expected output
- * @return
+ * expected output
+ * @return a <code>Result</code>
* @throws Exception
*/
- public Result isResultPage(final String expectedDocument) throws Exception
- {
+ public Result isResultPage(final String expectedDocument) throws Exception {
// Validate the document
String document = getServletResponse().getDocument();
- return isTrue("expected rendered page equals", document.equals(expectedDocument));
+ return isTrue("expected rendered page equals", document
+ .equals(expectedDocument));
}
/**
- * assert no error feedback messages
+ * Asserts no error-level feedback messages.
*
- * @return
+ * @return a <code>Result</code>
*/
- public Result hasNoErrorMessage()
- {
+ public Result hasNoErrorMessage() {
List messages = getMessages(FeedbackMessage.ERROR);
- return isTrue("expect no error message, but contains\n" +
- WicketTesterHelper.asLined(messages), messages.isEmpty());
+ return isTrue("expect no error message, but contains\n"
+ + WicketTesterHelper.asLined(messages), messages.isEmpty());
}
/**
- * assert no info feedback messages
+ * Asserts no info-level feedback messages.
*
- * @return
+ * @return a <code>Result</code>
*/
- public Result hasNoInfoMessage()
- {
+ public Result hasNoInfoMessage() {
List messages = getMessages(FeedbackMessage.INFO);
- return isTrue("expect no info message, but contains\n" +
- WicketTesterHelper.asLined(messages), messages.isEmpty());
+ return isTrue("expect no info message, but contains\n"
+ + WicketTesterHelper.asLined(messages), messages.isEmpty());
}
/**
- * get feedback messages
+ * Retrieves <code>FeedbackMessages</code>.
*
* @param level
- * level of feedback message, ex.
+ * level of feedback message, for example:
* <code>FeedbackMessage.DEBUG or FeedbackMessage.INFO.. etc</code>
- * @return List list of messages (in String)
+ * @return <code>List</code> of messages (as <code>String</code>s)
* @see FeedbackMessage
*/
- public List getMessages(final int level)
- {
+ public List getMessages(final int level) {
FeedbackMessages feedbackMessages = Session.get().getFeedbackMessages();
- List allMessages = feedbackMessages.messages(new IFeedbackMessageFilter()
- {
- private static final long serialVersionUID = 1L;
+ List allMessages = feedbackMessages
+ .messages(new IFeedbackMessageFilter() {
+ private static final long serialVersionUID = 1L;
- public boolean accept(FeedbackMessage message)
- {
- return message.getLevel() == level;
- }
- });
+ public boolean accept(FeedbackMessage message) {
+ return message.getLevel() == level;
+ }
+ });
List actualMessages = new ArrayList();
- for (Iterator iter = allMessages.iterator(); iter.hasNext();)
- {
- actualMessages.add(((FeedbackMessage)iter.next()).getMessage());
+ for (Iterator iter = allMessages.iterator(); iter.hasNext();) {
+ actualMessages.add(((FeedbackMessage) iter.next()).getMessage());
}
return actualMessages;
}
/**
- * dump the source of last rendered page
+ * Dumps the source of last rendered <code>Page</code>.
*/
- public void dumpPage()
- {
+ public void dumpPage() {
log.info(getServletResponse().getDocument());
}
/**
- * dump component trees
+ * Dumps the <code>Component</code> trees.
*/
- public void debugComponentTrees()
- {
+ public void debugComponentTrees() {
debugComponentTrees("");
}
-
/**
- * Dump the component trees to log.
+ * Dumps the <code>Component</code> trees to log. Show only the
+ * <code>Component</code>s whose paths contain the filter
+ * <code>String</code>.
*
* @param filter
- * Show only the components, which path contains the filterstring.
+ * a filter <code>String</code>
*/
- public void debugComponentTrees(String filter)
- {
+ public void debugComponentTrees(String filter) {
log.info("debugging ----------------------------------------------");
- for (Iterator iter = WicketTesterHelper.getComponentData(getLastRenderedPage()).iterator(); iter
- .hasNext();)
- {
- WicketTesterHelper.ComponentData obj = (WicketTesterHelper.ComponentData)iter.next();
- if (obj.path.matches(".*" + filter + ".*"))
- {
- log.info("path\t" + obj.path + " \t" + obj.type + " \t[" + obj.value + "]");
+ for (Iterator iter = WicketTesterHelper.getComponentData(
+ getLastRenderedPage()).iterator(); iter.hasNext();) {
+ WicketTesterHelper.ComponentData obj = (WicketTesterHelper.ComponentData) iter
+ .next();
+ if (obj.path.matches(".*" + filter + ".*")) {
+ log.info("path\t" + obj.path + " \t" + obj.type + " \t["
+ + obj.value + "]");
}
}
}
/**
- * Test that a component has been added to a AjaxRequestTarget, using
- * {@link AjaxRequestTarget#addComponent(Component)}. This method actually tests that a
- * component is on the AJAX response sent back to the client.
+ * Tests that a <code>Component</code> has been added to a
+ * <code>AjaxRequestTarget</code>, using
+ * {@link AjaxRequestTarget#addComponent(Component)}. This method actually
+ * tests that a <code>Component</code> is on the Ajax response sent back
+ * to the client.
* <p>
- * PLEASE NOTE! This method doesn't actually insert the component in the client DOM tree, using
- * javascript. But it shouldn't be needed because you have to trust that the Wicket Ajax
+ * PLEASE NOTE! This method doesn't actually insert the
+ * <code>Component</code> in the client DOM tree, using Javascript. But it
+ * shouldn't be needed because you have to trust that the Wicket Ajax
* Javascript just works.
*
* @param component
- * The component to test whether it's on the response.
- * @return
+ * the <code>Component</code> to test
+ * @return a <code>Result</code>
*/
- public Result isComponentOnAjaxResponse(Component component)
- {
+ public Result isComponentOnAjaxResponse(Component component) {
String failMessage = "A component which is null could not have been added to the AJAX response";
notNull(failMessage, component);
@@ -964,8 +926,7 @@
boolean isAjaxResponse = ajaxResponse
.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ajax-response>");
Result result = isTrue(failMessage, isAjaxResponse);
- if (result.wasFailed())
- {
+ if (result.wasFailed()) {
return result;
}
@@ -975,37 +936,37 @@
failMessage = "The component doesn't have a markup id, "
+ "which means that it can't have been added to the AJAX response";
result = isTrue(failMessage, !Strings.isEmpty(markupId));
- if (result.wasFailed())
- {
+ if (result.wasFailed()) {
return result;
}
// Look for that the component is on the response, using the markup id
- boolean isComponentInAjaxResponse = ajaxResponse.matches("(?s).*<component id=\"" +
- markupId + "\" ?>.*");
+ boolean isComponentInAjaxResponse = ajaxResponse
+ .matches("(?s).*<component id=\"" + markupId + "\" ?>.*");
failMessage = "Component wasn't found in the AJAX response";
return isTrue(failMessage, isComponentInAjaxResponse);
}
/**
- * Simulate that an AJAX event has been fired.
+ * Simulates the firing of an Ajax event.
*
* @see #executeAjaxEvent(Component, String)
*
* @since 1.2.3
* @param componentPath
- * The component path.
+ * the <code>Component</code> path
* @param event
- * The event which we simulate is fired. If the event is null, the test will fail.
+ * the event which we simulate being fired. If <code>event</code>
+ * is <code>null</code>, the test will fail.
*/
- public void executeAjaxEvent(String componentPath, String event)
- {
+ public void executeAjaxEvent(String componentPath, String event) {
Component component = getComponentFromLastRenderedPage(componentPath);
executeAjaxEvent(component, event);
}
/**
- * Simulate that an AJAX event has been fired. You add an AJAX event to a component by using:
+ * Simulates the firing of an Ajax event. You add an Ajax event to a
+ * <code>Component</code> by using:
*
* <pre>
* ...
@@ -1015,8 +976,8 @@
* ...
* </pre>
*
- * You can then test that the code inside onEvent actually does what it's supposed to, using the
- * WicketTester:
+ * You can then test that the code inside <code>onEvent</code> actually
+ * does what it's supposed to, using the <code>WicketTester</code>:
*
* <pre>
* ...
@@ -1025,21 +986,23 @@
* ...
* </pre>
*
- * This also works with AjaxFormSubmitBehavior, where it will "submit" the form before executing
- * the command.
+ * This also works with <code>AjaxFormSubmitBehavior</code>, where it
+ * will "submit" the <code>Form</code> before executing the command.
* <p>
- * PLEASE NOTE! This method doesn't actually insert the component in the client DOM tree, using
- * javascript.
+ * PLEASE NOTE! This method doesn't actually insert the
+ * <code>Component</code> in the client DOM tree, using Javascript.
*
*
* @param component
- * The component which has the AjaxEventBehavior we wan't to test. If the component
- * is null, the test will fail.
+ * the <code>Component</code> that has the
+ * <code>AjaxEventBehavior</code> we want to test. If the
+ * <code>Component</code> is <code>null</code>, the test
+ * will fail.
* @param event
- * The event which we simulate is fired. If the event is null, the test will fail.
+ * the event to simulate being fired. If <code>event</code> is
+ * <code>null</code>, the test will fail.
*/
- public void executeAjaxEvent(Component component, String event)
- {
+ public void executeAjaxEvent(Component component, String event) {
String failMessage = "Can't execute event on a component which is null.";
notNull(failMessage, component);
@@ -1050,17 +1013,14 @@
// matches the event parameter.
AjaxEventBehavior ajaxEventBehavior = null;
List behaviors = component.getBehaviors();
- for (Iterator iter = behaviors.iterator(); iter.hasNext();)
- {
- IBehavior behavior = (IBehavior)iter.next();
+ for (Iterator iter = behaviors.iterator(); iter.hasNext();) {
+ IBehavior behavior = (IBehavior) iter.next();
// AjaxEventBehavior is the one to look for
- if (behavior instanceof AjaxEventBehavior)
- {
- AjaxEventBehavior tmp = (AjaxEventBehavior)behavior;
+ if (behavior instanceof AjaxEventBehavior) {
+ AjaxEventBehavior tmp = (AjaxEventBehavior) behavior;
- if (event.equals(tmp.getEvent()))
- {
+ if (event.equals(tmp.getEvent())) {
ajaxEventBehavior = tmp;
}
}
@@ -1068,26 +1028,24 @@
// If there haven't been found any event behaviors on the component
// which maches the parameters we fail.
- failMessage = "No AjaxEventBehavior found on component: " + component.getId() +
- " which matches the event: " + event.toString();
+ failMessage = "No AjaxEventBehavior found on component: "
+ + component.getId() + " which matches the event: "
+ + event.toString();
notNull(failMessage, ajaxEventBehavior);
- // initialize the request only if needed to allow the user to pass request parameters, see
+ // initialize the request only if needed to allow the user to pass
+ // request parameters, see
// WICKET-254
WebRequestCycle requestCycle;
- if (RequestCycle.get() == null)
- {
+ if (RequestCycle.get() == null) {
requestCycle = setupRequestAndResponse();
- }
- else
- {
- requestCycle = (WebRequestCycle)RequestCycle.get();
+ } else {
+ requestCycle = (WebRequestCycle) RequestCycle.get();
}
// If the event is an FormSubmitBehavior then also "submit" the form
- if (ajaxEventBehavior instanceof AjaxFormSubmitBehavior)
- {
- AjaxFormSubmitBehavior ajaxFormSubmitBehavior = (AjaxFormSubmitBehavior)ajaxEventBehavior;
+ if (ajaxEventBehavior instanceof AjaxFormSubmitBehavior) {
+ AjaxFormSubmitBehavior ajaxFormSubmitBehavior = (AjaxFormSubmitBehavior) ajaxEventBehavior;
submitAjaxFormSubmitBehavior(ajaxFormSubmitBehavior);
}
@@ -1098,71 +1056,72 @@
}
/**
- * Get a TagTester based on a wicket:id. If more components exists with the same wicket:id in
- * the markup only the first one is returned.
+ * Retrieves a <code>TagTester</code> based on a <code>wicket:id</code>.
+ * If more <code>Component</code>s exist with the same
+ * <code>wicket:id</code> in the markup, only the first one is returned.
*
* @param wicketId
- * The wicket:id to search for.
- * @return The TagTester for the tag which has the given wicket:id.
+ * the <code>wicket:id</code> to search for
+ * @return the <code>TagTester</code> for the tag which has the given
+ * <code>wicket:id</code>
*/
- public TagTester getTagByWicketId(String wicketId)
- {
- return TagTester.createTagByAttribute(getServletResponse().getDocument(), "wicket:id",
- wicketId);
+ public TagTester getTagByWicketId(String wicketId) {
+ return TagTester.createTagByAttribute(getServletResponse()
+ .getDocument(), "wicket:id", wicketId);
}
/**
- * Get a TagTester based on an dom id. If more components exists with the same id in the markup
- * only the first one is returned.
+ * Retrieves a <code>TagTester</code> based on an DOM id. If more
+ * <code>Component</code>s exist with the same id in the markup, only the
+ * first one is returned.
*
* @param id
- * The dom id to search for.
- * @return The TagTester for the tag which has the given dom id.
+ * the DOM id to search for.
+ * @return the <code>TagTester</code> for the tag which has the given DOM
+ * id
*/
- public TagTester getTagById(String id)
- {
- return TagTester.createTagByAttribute(getServletResponse().getDocument(), "id", id);
+ public TagTester getTagById(String id) {
+ return TagTester.createTagByAttribute(getServletResponse()
+ .getDocument(), "id", id);
}
/**
- * Helper method for all the places where an AjaxCall should submit an associated form.
+ * Helper method for all the places where an Ajax call should submit an
+ * associated <code>Form</code>.
*
* @param behavior
- * The AjaxFormSubmitBehavior with the form to "submit"
+ * The <code>AjaxFormSubmitBehavior</code> with the
+ * <code>Form</code> to "submit"
*/
- private void submitAjaxFormSubmitBehavior(AjaxFormSubmitBehavior behavior)
- {
+ private void submitAjaxFormSubmitBehavior(AjaxFormSubmitBehavior behavior) {
// We need to get the form submitted, using reflection.
// It needs to be "submitted".
Form form = null;
- try
- {
- Field formField = AjaxFormSubmitBehavior.class.getDeclaredField("form");
+ try {
+ Field formField = AjaxFormSubmitBehavior.class
+ .getDeclaredField("form");
formField.setAccessible(true);
- form = (Form)formField.get(behavior);
- }
- catch (Exception e)
- {
+ form = (Form) formField.get(behavior);
+ } catch (Exception e) {
fail(e.getMessage());
}
String failMessage = "No form attached to the submitlink.";
notNull(failMessage, form);
- form.visitFormComponents(new FormComponent.AbstractVisitor()
- {
- public void onFormComponent(FormComponent formComponent)
- {
- if (!(formComponent instanceof Button) && !(formComponent instanceof RadioGroup) &&
- !(formComponent instanceof CheckGroup))
- {
+ form.visitFormComponents(new FormComponent.AbstractVisitor() {
+ public void onFormComponent(FormComponent formComponent) {
+ if (!(formComponent instanceof Button)
+ && !(formComponent instanceof RadioGroup)
+ && !(formComponent instanceof CheckGroup)) {
String name = formComponent.getInputName();
String value = formComponent.getValue();
- // Set request parameter with the field value, but do not modify an existing
- // request parameter explicitly set using FormTester.setValue()
- if (getServletRequest().getParameterMap().get(name) == null)
- {
+ // Set request parameter with the field value, but do not
+ // modify an existing
+ // request parameter explicitly set using
+ // FormTester.setValue()
+ if (getServletRequest().getParameterMap().get(name) == null) {
getServletRequest().setParameter(name, value);
}
}
@@ -1171,97 +1130,85 @@
}
/**
+ * Retrieves the content type from the response header.
*
- * @return
+ * @return the content type from the response header
*/
- public String getContentTypeFromResponseHeader()
- {
- String contentType = ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse())
- .getHeader("Content-Type");
- if (contentType == null)
- {
+ public String getContentTypeFromResponseHeader() {
+ String contentType = ((MockHttpServletResponse) getWicketResponse()
+ .getHttpServletResponse()).getHeader("Content-Type");
+ if (contentType == null) {
throw new WicketRuntimeException("No Content-Type header found");
}
return contentType;
}
/**
+ * Retrieves the content length from the response header.
*
- * @return
+ * @return the content length from the response header
*/
- public int getContentLengthFromResponseHeader()
- {
- String contentLength = ((MockHttpServletResponse)getWicketResponse()
+ public int getContentLengthFromResponseHeader() {
+ String contentLength = ((MockHttpServletResponse) getWicketResponse()
.getHttpServletResponse()).getHeader("Content-Length");
- if (contentLength == null)
- {
+ if (contentLength == null) {
throw new WicketRuntimeException("No Content-Length header found");
}
return Integer.parseInt(contentLength);
}
/**
+ * Retrieves the last-modified value from the response header.
*
- * @return
+ * @return the last-modified value from the response header
*/
- public String getLastModifiedFromResponseHeader()
- {
- return ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse())
- .getHeader("Last-Modified");
+ public String getLastModifiedFromResponseHeader() {
+ return ((MockHttpServletResponse) getWicketResponse()
+ .getHttpServletResponse()).getHeader("Last-Modified");
}
/**
+ * Retrieves the content disposition from the response header.
*
- * @return
+ * @return the content disposition from the response header
*/
- public String getContentDispositionFromResponseHeader()
- {
- return ((MockHttpServletResponse)getWicketResponse().getHttpServletResponse())
- .getHeader("Content-Disposition");
+ public String getContentDispositionFromResponseHeader() {
+ return ((MockHttpServletResponse) getWicketResponse()
+ .getHttpServletResponse()).getHeader("Content-Disposition");
}
- private Result isTrue(String message, boolean condition)
- {
- if (condition)
- {
+ private Result isTrue(String message, boolean condition) {
+ if (condition) {
return Result.pass();
}
return Result.fail(message);
}
- private Result isEqual(Object expected, Object actual)
- {
- if (expected == null && actual == null)
- {
+ private Result isEqual(Object expected, Object actual) {
+ if (expected == null && actual == null) {
return Result.pass();
}
- if (expected != null && expected.equals(actual))
- {
+ if (expected != null && expected.equals(actual)) {
return Result.pass();
}
String message = "expected:<" + expected + "> but was:<" + actual + ">";
return Result.fail(message);
}
- private void notNull(String message, Object object)
- {
- if (object == null)
- {
+ private void notNull(String message, Object object) {
+ if (object == null) {
fail(message);
}
}
- private Result isNull(String message, Object object)
- {
- if (object != null)
- {
+ private Result isNull(String message, Object object) {
+ if (object != null) {
return Result.fail(message);
}
return Result.pass();
}
- private void fail(String message)
- {
+ private void fail(String message) {
throw new WicketRuntimeException(message);
}
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyHomePage.java Sun Oct 14 14:31:34 2007
@@ -20,9 +20,10 @@
import org.apache.wicket.markup.html.link.Link;
/**
- * A dummy homepage required by WicketTester only
+ * A dummy home page, as required by <code>WicketTester</code>.
*
* @author Ingram Chen
+ * @since 1.2.6
*/
public class DummyHomePage extends WebPage
{
@@ -33,7 +34,8 @@
private final Link testPageLink;
/**
- * Construct
+ * Constructor.
+ *
*/
public DummyHomePage()
{
@@ -42,8 +44,11 @@
}
/**
+ * Sets the <code>TestPageSource</code> for this
+ * <code>DummyHomePage</code>.
*
* @param testPageSource
+ * an <code>ITestPageSource</code> instance
*/
public void setTestPageSource(ITestPageSource testPageSource)
{
@@ -51,8 +56,9 @@
}
/**
+ * Retrieves the test page <code>Link</code>.
*
- * @return Link
+ * @return the test page <code>Link</code>
*/
public Link getTestPageLink()
{
@@ -60,24 +66,23 @@
}
/**
- *
+ * <code>TestLink</code> class.
*/
public class TestLink extends Link
{
private static final long serialVersionUID = 1L;
/**
+ * Constructor.
*
* @param id
+ * <code>Component</code> id of the <code>TestLink</code>
*/
public TestLink(String id)
{
super(id);
}
- /**
- *
- */
public void onClick()
{
setResponsePage(testPageSource.getTestPage());
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/DummyPanelPage.java Sun Oct 14 14:31:34 2007
@@ -19,20 +19,23 @@
import org.apache.wicket.markup.html.WebPage;
/**
- * A dummy panel component
+ * A dummy <code>Panel</code> Component.
*
* @author Ingram Chen
+ * @since 1.2.6
*/
public class DummyPanelPage extends WebPage
{
private static final long serialVersionUID = 1L;
- /** The dummy panels component id */
+ /** The dummy <code>Panel</code> <code>Component</code> id */
public static final String TEST_PANEL_ID = "panel";
/**
+ * Constructor.
*
* @param testPanelSource
+ * a <code>TestPanelSource</code>
*/
public DummyPanelPage(final TestPanelSource testPanelSource)
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ExternalPageViewer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ExternalPageViewer.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ExternalPageViewer.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ExternalPageViewer.java Sun Oct 14 14:31:34 2007
@@ -26,9 +26,13 @@
import java.util.List;
/**
- * This class is experimental only and may not yet work in your environment
+ * <code>ExternalPageViewer</code> class. This class is experimental only and
+ * may not yet work in your environment.
+ *
+ * TODO need Javadoc from author.
*
* @author Ingram Chen
+ * @since 1.2.6
*/
public class ExternalPageViewer
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/FormTester.java Sun Oct 14 14:31:34 2007
@@ -49,22 +49,24 @@
/**
- * A helper for testing validation and submission of Form component.
- *
+ * A helper class for testing validation and submission of
+ * <code>FormComponent</code>s.
+ *
* @author Ingram Chen
* @author Frank Bille (frankbille)
+ * @since 1.2.6
*/
public class FormTester
{
/**
- * A selector template for selecting seletable form component via index of
- * option, support RadioGroup, CheckGroup, and AbstractChoice family.
- *
+ * A selector template for selecting selectable <code>FormComponent</code>s
+ * with an index of option -- supports <code>RadioGroup</code>,
+ * <code>CheckGroup</code>, and <code>AbstractChoice</code> family.
*/
protected abstract class ChoiceSelector
{
/**
- * ???
+ * TODO need Javadoc from author.
*/
private final class SearchOptionByIndexVisitor implements IVisitor
{
@@ -98,9 +100,9 @@
private final FormComponent formComponent;
/**
- * Construct.
+ * Constructor.
*
- * @param formComponent
+ * @param formComponent a <code>FormComponent</code>
*/
protected ChoiceSelector(FormComponent formComponent)
{
@@ -108,14 +110,17 @@
}
/**
- * implement whether toggle or cumulate selection
- *
+ * Implements whether toggle or accumulate the selection.
+ *
* @param formComponent
+ * a <code>FormComponent</code>
* @param value
+ * a <code>String</code> value
*/
protected abstract void assignValueToFormComponent(FormComponent formComponent, String value);
/**
+ * Selects a given index in a selectable <code>FormComponent</code>.
*
* @param index
*/
@@ -127,7 +132,7 @@
new SearchOptionByIndexVisitor(index));
if (foundRadio == null)
{
- fail("RadioGroup " + formComponent.getPath() + " does not has index:"
+ fail("RadioGroup " + formComponent.getPath() + " does not have index:"
+ index);
}
assignValueToFormComponent(formComponent, foundRadio.getValue());
@@ -149,7 +154,7 @@
String idValue = selectAbstractChoice(formComponent, index);
if (idValue == null)
{
- fail(formComponent.getPath() + " is not selectable component.");
+ fail(formComponent.getPath() + " is not a selectable Component.");
}
else
{
@@ -159,9 +164,13 @@
}
/**
+ * Selects a given index in a selectable <code>FormComponent</code>.
+ *
* @param formComponent
+ * a <code>FormComponent</code>
* @param index
- * @return xxx
+ * the index to select
+ * @return the id value at the selected index
*/
private String selectAbstractChoice(FormComponent formComponent, final int index)
{
@@ -202,20 +211,20 @@
}
/**
- * A Factory to create appropriate ChoiceSelector based on type of
- * formComponent
+ * A factory that creates an appropriate <code>ChoiceSelector</code> based
+ * on type of <code>FormComponent</code>.
*/
private class ChoiceSelectorFactory
{
/**
- *
+ * <code>MultipleChoiceSelector</code> class.
*/
private final class MultipleChoiceSelector extends ChoiceSelector
{
/**
- * Construct.
+ * Constructor.
*
- * @param formComponent
+ * @param formComponent a <code>FormComponent</code>
*/
protected MultipleChoiceSelector(FormComponent formComponent)
{
@@ -240,14 +249,14 @@
}
/**
- *
+ * <code>SingleChoiceSelector</code> class.
*/
private final class SingleChoiceSelector extends ChoiceSelector
{
/**
- * Construct.
+ * Constructor.
*
- * @param formComponent
+ * @param formComponent a <code>FormComponent</code>
*/
protected SingleChoiceSelector(FormComponent formComponent)
{
@@ -255,7 +264,6 @@
}
/**
- *
* @see org.apache.wicket.util.tester.FormTester.ChoiceSelector#assignValueToFormComponent(org.apache.wicket.markup.html.form.FormComponent,
* java.lang.String)
*/
@@ -267,9 +275,11 @@
}
/**
- *
+ * Creates a <code>ChoiceSelector</code>.
+ *
* @param formComponent
- * @return ChoiceSelector
+ * a <code>FormComponent</code>
+ * @return ChoiceSelector a <code>ChoiceSelector</code>
*/
protected ChoiceSelector create(FormComponent formComponent)
{
@@ -296,9 +306,11 @@
}
/**
- *
+ * Creates a <code>MultipleChoiceSelector</code>.
+ *
* @param formComponent
- * @return ChoiceSelector
+ * a <code>FormComponent</code>
+ * @return ChoiceSelector a <code>ChoiceSelector</code>
*/
protected ChoiceSelector createForMultiple(FormComponent formComponent)
{
@@ -306,9 +318,12 @@
}
/**
- *
+ * Tests if a given <code>FormComponent</code> allows multiple choice.
+ *
* @param formComponent
- * @return boolean
+ * a <code>FormComponent</code>
+ * @return <code>true</code> if the given FormComponent allows
+ * multiple choice
*/
private boolean allowMultipleChoice(FormComponent formComponent)
{
@@ -320,32 +335,33 @@
private final ChoiceSelectorFactory choiceSelectorFactory = new ChoiceSelectorFactory();
/**
- * An instance of FormTester can only be used once. Create a new instance of
- * each test
+ * An instance of <code>FormTester</code> can only be used once. Create a
+ * new instance of each test.
*/
private boolean closed = false;
- /** path to form component */
+ /** path to <code>FormComponent</code> */
private final String path;
- /** baseWicketTester that create FormTester */
+ /** <code>BaseWicketTester</code> that create <code>FormTester</code> */
private final BaseWicketTester baseWicketTester;
- /** form component to be test */
+ /** <code>FormComponent</code> to be tested */
private final Form workingForm;
/**
* @see WicketTester#newFormTester(String)
- *
+ *
* @param path
- * path to form component
+ * path to <code>FormComponent</code>
* @param workingForm
- * form component to be test
+ * <code>FormComponent</code> to be tested
* @param wicketTester
- * wicketTester that create FormTester
+ * <code>WicketTester</code> that creates
+ * <code>FormTester</code>
* @param fillBlankString
- * specify whether filling child Text Components with blank
- * String
+ * specifies whether to fill child <code>TextComponent</code>s
+ * with blank <code>String</code>s
*/
protected FormTester(final String path, final Form workingForm,
final BaseWicketTester wicketTester, final boolean fillBlankString)
@@ -417,7 +433,9 @@
}
/**
- * @return work form
+ * Retrieves the current <code>Form</code> object.
+ *
+ * @return the working <code>Form</code>
*/
public Form getForm()
{
@@ -425,11 +443,12 @@
}
/**
- * Gets value for text component with provided id.
- *
+ * Gets the value for an <code>AbstractTextComponent</code> with the
+ * provided id.
+ *
* @param id
- * Component's id
- * @return value text component
+ * <code>Component</code> id
+ * @return the value of the text component
*/
public String getTextComponentValue(String id)
{
@@ -442,16 +461,19 @@
}
/**
- * simulate selecting an option of a Form Component. Support RadioGroup,
- * CheckGroup, and AbstractChoice family currently. The behavior is similar
- * to interacting on the browser: For single choice, such as Radio or
- * DropDownList, the selection will toggle each other. For multiple choice,
- * such as Checkbox or ListMultipleChoice, the selection will cumulate.
- *
+ * Simulates selecting an option of a <code>FormComponent</code>.
+ * Supports <code>RadioGroup</code>, <code>CheckGroup</code>, and
+ * <code>AbstractChoice</code> family currently. The behavior is similar
+ * to interacting on the browser: For a single choice, such as
+ * <code>Radio</code> or <code>DropDownList</code>, the selection will
+ * toggle each other. For multiple choice, such as <code>Checkbox</code>
+ * or <code>ListMultipleChoice</code>, the selection will accumulate.
+ *
* @param formComponentId
- * relative path (from form) to selectable formComponent
+ * relative path (from <code>Form</code>) to the selectable
+ * <code>FormComponent</code>
* @param index
- * index of selectable option, start from 0
+ * index of the selectable option, starting from 0
*/
public void select(String formComponentId, int index)
{
@@ -479,15 +501,17 @@
}
/**
- * A convenient method to select multiple options for the form component.
- * The method only support multiple selectable form component.
- *
+ * A convenience method to select multiple options for the
+ * <code>FormComponent</code>. The method only support multiple
+ * selectable <code>FormComponent</code>s.
+ *
* @see #select(String, int)
- *
+ *
* @param formComponentId
- * relative path (from form) to selectable formComponent
+ * relative path (from <code>Form</code>) to the selectable
+ * <code>FormComponent</code>
* @param indexes
- * index of selectable option, start from 0
+ * index of the selectable option, starting from 0
*/
public void selectMultiple(String formComponentId, int[] indexes)
{
@@ -503,12 +527,13 @@
}
/**
- * simulate filling a field of a Form.
- *
+ * Simulates filling in a field on a <code>Form</code>.
+ *
* @param formComponentId
- * relative path (from form) to formComponent
+ * relative path (from <code>Form</code>) to the selectable
+ * <code>FormComponent</code>
* @param value
- * field value of form.
+ * the field value
*/
public void setValue(final String formComponentId, final String value)
{
@@ -519,15 +544,16 @@
}
/**
- * Set the file on a {@link FileUploadField}.
- *
+ * Sets the <code>File</code> on a {@link FileUploadField}.
+ *
* @param formComponentId
- * relative path (from form) to formComponent. The form component
- * must be of a type FileUploadField.
+ * relative path (from <code>Form</code>) to the selectable
+ * <code>FormComponent</code>. The <code>FormComponent</code>
+ * must be of a type <code>FileUploadField</code>.
* @param file
- * The file to upload.
+ * the <code>File</code> to upload.
* @param contentType
- * The content type of the file. Must be a correct mimetype.
+ * the content type of the file. Must be a valid mime type.
*/
public void setFile(final String formComponentId, final File file, final String contentType)
{
@@ -547,7 +573,8 @@
}
/**
- * submit the form. note that submit() can be executed only once.
+ * Submits the <code>Form</code>. Note that <code>submit</code> can be
+ * executed only once.
*/
public void submit()
{
@@ -591,18 +618,19 @@
}
/**
- * A convenient method to submit form with alternative button.
- *
- * Note that if the button associates with a model, it's better to use
- * setValue() instead:
- *
+ * A convenience method for submitting the <code>Form</code> with an
+ * alternate button.
+ * <p>
+ * Note that if the button is associated with a model, it's better to use
+ * the <code>setValue</code> method instead:
+ *
* <pre>
* formTester.setValue("to:my:button", "value on the button");
* formTester.submit();
* </pre>
- *
+ *
* @param buttonComponentId
- * relative path (from form) to the button
+ * relative path (from <code>Form</code>) to the button
*/
public void submit(String buttonComponentId)
{
@@ -611,11 +639,14 @@
}
/**
- * add additional formComponent's value into request parameter, this method
- * retain exist parameters but remove any duplicated parameters.
- *
+ * Adds an additional <code>FormComponent</code>'s value into request
+ * parameter -- this method retains existing parameters but removes any
+ * duplicate parameters.
+ *
* @param formComponent
+ * a <code>FormComponent</code>
* @param value
+ * a value to add
*/
private void addFormComponentValue(FormComponent formComponent, String value)
{
@@ -637,8 +668,8 @@
}
/**
- * FormTester must only be used once. Create a new instance of FormTester
- * for each test.
+ * <code>FormTester</code> must only be used once. Create a new instance
+ * of <code>FormTester</code> for each test.
*/
private void checkClosed()
{
@@ -651,9 +682,13 @@
}
/**
- *
+ * Returns <code>true</code> if the parameter exists in the
+ * <code>FormComponent</code>.
+ *
* @param formComponent
- * @return Boolean
+ * a <code>FormComponent</code>
+ * @return <code>true</code> if the parameter exists in the
+ * <code>FormComponent</code>
*/
private boolean parameterExist(FormComponent formComponent)
{
@@ -663,11 +698,13 @@
}
/**
- * set formComponent's value into request parameter, this method overwrites
- * exist parameters.
- *
+ * Set formComponent's value into request parameter, this method overwrites
+ * existing parameters.
+ *
* @param formComponent
+ * a <code>FormComponent</code>
* @param value
+ * a value to add
*/
private void setFormComponentValue(FormComponent formComponent, String value)
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/ITestPageSource.java Sun Oct 14 14:31:34 2007
@@ -20,16 +20,18 @@
import org.apache.wicket.Page;
/**
- * A test page factory for WicketTester
+ * A test <code>Page</code> factory for <code>WicketTester</code>
*
* @author Ingram Chen
+ * @since 1.2.6
*/
public interface ITestPageSource extends IClusterable
{
/**
- * Define a page instance source for WicketTester
+ * Defines a <code>Page</code> instance source for
+ * <code>WicketTester</code>.
*
- * @return Page created page instance for testing
+ * @return a <code>Page</code> instance for testing
*/
Page getTestPage();
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/Result.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/Result.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/Result.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/Result.java Sun Oct 14 14:31:34 2007
@@ -17,7 +17,10 @@
package org.apache.wicket.util.tester;
/**
- *
+ * A <code>Result</code> class.
+ *
+ * @author unknown
+ * @since 1.2.6
*/
public class Result
{
@@ -38,8 +41,11 @@
}
/**
- * @param message the error message for the user
- * @return a Result which failed
+ * Returns a <code>Result</code> which failed.
+ *
+ * @param message
+ * an error message
+ * @return a <code>Result</code> which failed
*/
static Result fail(String message)
{
@@ -47,7 +53,9 @@
}
/**
- * @return a Result which passed
+ * Returns a <code>Result</code> which passed.
+ *
+ * @return a <code>Result</code> which passed
*/
static Result pass()
{
@@ -55,7 +63,9 @@
}
/**
- * @return true if the result was failed
+ * Returns <code>true</code> if the <code>Result</code> was a failure.
+ *
+ * @return <code>true</code> if the <code>Result</code> was a failure
*/
public boolean wasFailed()
{
@@ -63,7 +73,9 @@
}
/**
- * @return the error message for the user
+ * Retrieves the error message.
+ *
+ * @return the error message
*/
public String getMessage()
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TagTester.java Sun Oct 14 14:31:34 2007
@@ -30,11 +30,11 @@
* Tag tester is used to test that a generated markup tag contains the correct
* attributes, values etc. This can be done instead of comparing generated
* markup with some expected markup. The advantage of this is that a lot of
- * tests doesn't fail, when the generated markup changes just a little bit.
+ * tests don't fail when the generated markup changes just a little bit.
* <p>
* It also gives a more programmatic way of testing the generated output, by not
- * having to worry about how the markup looks precisely instead of which
- * attributes exists on the given tags and what values they have.
+ * having to worry about precisely how the markup looks instead of which
+ * attributes exists on the given tags, and what values they have.
* <p>
* Example:
*
@@ -46,6 +46,7 @@
* </pre>
*
* @author Frank Bille (billen)
+ * @since 1.2.6
*/
public class TagTester
{
@@ -56,11 +57,11 @@
private final XmlPullParser parser;
/**
- * Construct.
+ * Constructor.
*
- * @param parser
- * @param openTag
- * @param closeTag
+ * @param parser an <code>XmlPullParser</code>
+ * @param openTag an opening XML tag
+ * @param closeTag a closing XML tag
*/
private TagTester(XmlPullParser parser, XmlTag openTag, XmlTag closeTag)
{
@@ -70,9 +71,9 @@
}
/**
- * Get the tag name.
+ * Gets the tag's name.
*
- * @return Tag name.
+ * @return the tag name
*/
public String getName()
{
@@ -80,12 +81,13 @@
}
/**
- * Does the tag contain the attribute. Please note that this is case
- * in-sensitive, because attributes in HTML may be case in-sensitive.
+ * Tests if the tag contains the given attribute. Please note that this is
+ * non case-sensitive, because attributes in HTML may be non case-sensitive.
*
* @param attribute
- * The attribute to look for in the tag.
- * @return True if the tag has an attribute, false if not.
+ * an attribute to look for in the tag
+ * @return <code>true</code> if the tag has the attribute,
+ * <code>false</code> if not.
*/
public boolean hasAttribute(String attribute)
{
@@ -100,12 +102,13 @@
}
/**
- * Get the attribute value for the given attribute. Please note that this is
- * case in-sensitive, because attributes in HTML may be case in-sensitive.
+ * Gets the value for a given attribute. Please note that this is non
+ * case-sensitive, because attributes in HTML may be non case-sensitive.
*
* @param attribute
- * The attribute to look for in the tag.
- * @return The value of the attribute or null if it isn't found.
+ * an attribute to look for in the tag
+ * @return the value of the attribute or <code>null</code> if it isn't
+ * found.
*/
public String getAttribute(String attribute)
{
@@ -130,7 +133,7 @@
}
/**
- * Check if an attribute contains the specified partial value.
+ * Checks if an attribute contains the specified partial value.
* <p>
* For example:
*
@@ -142,7 +145,7 @@
* </pre>
*
* <p>
- * <b>Test</b>
+ * <b>Test:</b>
*
* <pre>
* TagTester tester = application.getTagByWicketId("helloComp");
@@ -150,10 +153,11 @@
* </pre>
*
* @param attribute
- * The attribute to test on
+ * the attribute to test on
* @param partialValue
- * The partial value to test if the attribute value contains.
- * @return True if the attribute value contains the partial value.
+ * the partial value to test if the attribute value contains it
+ * @return <code>true</code> if the attribute value contains the partial
+ * value
*/
public boolean getAttributeContains(String attribute, String partialValue)
{
@@ -176,13 +180,14 @@
}
/**
- * Check if an attributes value is the exact same as the given parameter.
+ * Checks if an attribute's value is the exact same as the given value.
*
* @param attribute
- * The attribute to test.
+ * an attribute to test
* @param expected
- * The value which should be the same at the attributes value
- * @return True if the attributes value is the same as the parameter.
+ * the value which should be the same at the attribute's value
+ * @return <code>true</code> if the attribute's value is the same as the
+ * given value
*/
public boolean getAttributeIs(String attribute, String expected)
{
@@ -199,11 +204,14 @@
}
/**
- * Check if an attributes value ends with the given parameter.
+ * Checks if an attribute's value ends with the given parameter.
*
* @param attribute
+ * an attribute to test
* @param expected
- * @return True if the attributes value ends with the expected value
+ * the expected value
+ * @return <code>true</code> if the attribute's value ends with the
+ * expected value
*/
public boolean getAttributeEndsWith(String attribute, String expected)
{
@@ -226,11 +234,12 @@
}
/**
- * Check if the tag has a child with the tagName.
+ * Checks if the tag has a child with the given <code>tagName</code>.
*
* @param tagName
- * The tag name to search for.
- * @return True if this tag has a child with the given tagName.
+ * the tag name to search for
+ * @return <code>true</code> if this tag has a child with the given
+ * <code>tagName</code>.
*/
public boolean hasChildTag(String tagName)
{
@@ -278,14 +287,14 @@
}
/**
- * Get a child tag for testing. If this tag contains child tags, you can get
- * one of them as a TagTester.
+ * Gets a child tag for testing. If this tag contains child tags, you can
+ * get one of them as a {@link TagTester} instance.
*
* @param attribute
- * The attribute on the child tag to search for
+ * an attribute on the child tag to search for
* @param value
- * The value that the attribute must have.
- * @return The TagTester for the child tag.
+ * a value that the attribute must have
+ * @return the <code>TagTester</code> for the child tag
*/
public TagTester getChild(String attribute, String value)
{
@@ -306,10 +315,10 @@
}
/**
- * Get markup for this tag. This includes every markup which is between the
- * open tag and the close tag.
+ * Gets the markup for this tag. This includes all markup between the open
+ * tag and the close tag.
*
- * @return The entire markup between the open tag and the close tag.
+ * @return all the markup between the open tag and the close tag
*/
public String getMarkup()
{
@@ -321,20 +330,21 @@
}
/**
- * Static factory method for creating a TagTester based on a tag found by an
- * attribute with a specific value. Please note that it will return the
- * first tag which matches the criteria. It's therefore good for attributes
- * suck as "id" or "wicket:id", but only if "wicket:id" is unique in the
- * specified markup.
+ * Static factory method for creating a <code>TagTester</code> based on a
+ * tag found by an attribute with a specific value. Please note that it will
+ * return the first tag which matches the criteria. It's therefore good for
+ * attributes suck as "id" or "wicket:id", but only if "wicket:id" is unique
+ * in the specified markup.
*
* @param markup
- * The markup to look for the tag to create the TagTester from.
+ * the markup to look for the tag to create the
+ * <code>TagTester</code> from
* @param attribute
- * The attribute which should be on the tag in the markup.
+ * the attribute which should be on the tag in the markup
* @param value
- * The value which the attribute must have.
- * @return The TagTester which matches the tag in the markup, that has the
- * given value on the given attribute.
+ * the value which the attribute must have
+ * @return the <code>TagTester</code> which matches the tag in the markup,
+ * that has the given value on the given attribute
*/
public static TagTester createTagByAttribute(String markup, String attribute, String value)
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java?rev=584613&r1=584612&r2=584613&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/TestPanelSource.java Sun Oct 14 14:31:34 2007
@@ -20,19 +20,22 @@
import org.apache.wicket.markup.html.panel.Panel;
/**
- * A test panel factory for WicketTester
+ * A test <code>Panel</code> factory for <code>WicketTester</code>.
*
* @author Ingram Chen
+ * @since 1.2.6
*/
public interface TestPanelSource extends IClusterable
{
/**
- * Define a panel instance source for WicketTester
+ * Defines a <code>Panel</code> instance source for
+ * <code>WicketTester</code>.
*
* @param panelId
- * panelId of the testing panel
- * @return Panel testing panel instance, note that testing panel's
- * componentId must use supplied <code>panelId</code>.
+ * <code>Component</code> id of the test <code>Panel</code>
+ * @return test <code>Panel</code> instance -- note that the test
+ * <code>Panel</code>'s <code>Component</code> id must use the
+ * given <code>panelId</code>.
*/
Panel getTestPanel(final String panelId);
}