You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by gs...@apache.org on 2007/10/15 23:23:31 UTC
svn commit: r584925 [25/34] - in /wicket/trunk/jdk-1.4/wicket/src:
main/java/org/apache/wicket/ main/java/org/apache/wicket/ajax/
main/java/org/apache/wicket/ajax/calldecorator/
main/java/org/apache/wicket/ajax/form/ main/java/org/apache/wicket/ajax/ma...
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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -66,41 +66,43 @@
import org.slf4j.LoggerFactory;
/**
- * 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>.
- *
+ * 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;
/**
* Constructor.
- *
+ *
* @param page
*/
- private TestPageSource(Page page) {
+ private TestPageSource(Page page)
+ {
this.page = page;
}
- public Page getTestPage() {
+ public Page getTestPage()
+ {
return page;
}
}
@@ -108,16 +110,20 @@
/**
* @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() {
+ protected ISessionStore newSessionStore()
+ {
// Don't use a filestore, or we spawn lots of threads, which makes
// things slow.
return new HttpSessionStore(this);
@@ -125,34 +131,39 @@
}
/**
- * Creates <code>WicketTester</code> and automatically create a
- * <code>WebApplication</code>, 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);
}
/**
- * Creates <code>WicketTester</code> and automatically creates a
- * <code>WebApplication</code>.
- *
+ * 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() {
+ protected ISessionStore newSessionStore()
+ {
// Don't use a filestore, or we spawn lots of threads, which
// makes things slow.
return new HttpSessionStore(this);
@@ -163,55 +174,56 @@
/**
* Creates a <code>WicketTester</code>.
- *
+ *
* @param application
- * a <code>WicketTester</code> <code>WebApplication</code>
- * object
+ * a <code>WicketTester</code> <code>WebApplication</code> object
*/
- public BaseWicketTester(final WebApplication application) {
+ public BaseWicketTester(final WebApplication application)
+ {
this(application, null);
}
/**
* Creates a <code>WicketTester</code> for unit testing.
- *
+ *
* @param application
- * a <code>WicketTester</code> <code>WebApplication</code>
- * object
+ * a <code>WicketTester</code> <code>WebApplication</code> object
* @param path
- * the absolute path on disk to the <code>WebApplication</code>'s
- * contents (e.g. war root) - may be <code>null</code>
- *
+ * 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);
}
/**
- * 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:
- *
+ * 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);
* }
* });
* </pre>
- *
+ *
* @param testPageSource
- * a <code>Page</code> factory that creates a test page
- * instance
+ * 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());
@@ -219,27 +231,27 @@
}
/**
- * Builds and processes a request suitable for invoking a listener. The
- * <code>Component</code> must implement any of the known
- * <code>IListener</code> 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
- * <code>AbstractAjaxBehavior</code>.
- *
+ * Builds and processes a request suitable for executing an <code>AbstractAjaxBehavior</code>.
+ *
* @param behavior
* 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);
@@ -251,70 +263,70 @@
/**
* Renders the <code>Page</code>.
- *
+ *
* @param page
* 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));
}
/**
* Renders a <code>Page</code> from its default constructor.
- *
+ *
* @param pageClass
* 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();
}
/**
- * 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.
- *
+ * 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 <code>FormComponent</code>
- * @return a <code>FormTester</code> instance for testing the
- * <code>Form</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);
}
/**
* Creates a {@link FormTester} for the <code>Form</code> at a given path.
- *
+ *
* @param path
* path to <code>FormComponent</code>
* @param fillBlankString
- * 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>
+ * 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);
}
/**
- * 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.
+ * 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);
* }
@@ -325,48 +337,63 @@
* 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);
}
/**
- * Renders a <code>Panel</code> from a <code>Panel(String id)</code>
- * constructor.
- *
+ * Renders a <code>Panel</code> from a <code>Panel(String id)</code> constructor.
+ *
* @param panelClass
- * a test <code>Panel</code> class with
- * <code>Panel(String id)</code> constructor
+ * 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);
}
}
@@ -377,15 +404,15 @@
/**
* A helper method for starting a component for a test without attaching it to a Page.
- *
+ *
* Components which are somehow dependent on the page structure can not be currently tested with
* this method.
- *
+ *
* Example:
- *
+ *
* UserDataView view = new UserDataView("view", new ListDataProvider(userList));
* tester.startComponent(view); assertEquals(4, view.size());
- *
+ *
* @param component
*/
public void startComponent(Component component)
@@ -399,7 +426,7 @@
/**
* Throw "standard" WicketRuntimeException
- *
+ *
* @param e
* @return RuntimeException
*/
@@ -412,7 +439,7 @@
* Gets the component with the given path from last rendered page. This method fails in case the
* component couldn't be found, and it will return null if the component was found, but is not
* visible.
- *
+ *
* @param path
* Path to component
* @return The component at the path
@@ -436,7 +463,7 @@
/**
* assert the text of <code>Label</code> component.
- *
+ *
* @param path
* path to <code>Label</code> component
* @param expectedLabelText
@@ -451,7 +478,7 @@
/**
* assert <code>PageLink</code> link to page class.
- *
+ *
* @param path
* path to <code>PageLink</code> component
* @param expectedPageClass
@@ -484,7 +511,7 @@
/**
* assert component class
- *
+ *
* @param path
* path to component
* @param expectedComponentClass
@@ -501,7 +528,7 @@
/**
* assert component visible.
- *
+ *
* @param path
* path to component
* @return
@@ -520,7 +547,7 @@
/**
* assert component invisible.
- *
+ *
* @param path
* path to component
* @return
@@ -532,7 +559,7 @@
/**
* assert the content of last rendered page contains(matches) regex pattern.
- *
+ *
* @param pattern
* reqex pattern to match
* @return
@@ -545,7 +572,7 @@
/**
* assert the model of {@link ListView} use expectedList
- *
+ *
* @param path
* path to {@link ListView} component
* @param expectedList
@@ -561,7 +588,7 @@
* Click the {@link Link} in the last rendered Page.
* <p>
* Simulate that AJAX is enabled.
- *
+ *
* @see WicketTester#clickLink(String, boolean)
* @param path
* Click the <code>Link</code> in the last rendered Page.
@@ -589,7 +616,7 @@
* This method is also able to simulate that AJAX (javascript) is disabled on the client. This
* is done by setting the isAjax parameter to false. If you have an AjaxFallbackLink you can
* then check that it doesn't fail when invoked as a normal link.
- *
+ *
* @param path
* path to <code>Link</code> component
* @param isAjax
@@ -627,8 +654,9 @@
// 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();
@@ -642,25 +670,27 @@
}
// 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;
}
}
@@ -680,23 +710,28 @@
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.");
}
@@ -704,51 +739,56 @@
}
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");
}
}
/**
* 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 <code>Component</code> with the given path to
- * be used with the next request.
+ * 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.
- *
+ * NOTE: this method only works when a <code>Page</code> was rendered first.
+ *
* @param componentPath
* 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);
}
@@ -756,108 +796,113 @@
/**
* 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 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();
}
/**
- * Asserts last rendered <code>Page</code> 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 <code>File</code> (relative to
- * <code>clazz</code> package)
+ * used to load the <code>File</code> (relative to <code>clazz</code> package)
* @param filename
* 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);
}
/**
- * Asserts last rendered <code>Page</code> against an expected HTML
- * document as a <code>String</code>.
- *
+ * Asserts last rendered <code>Page</code> against an expected HTML document as a
+ * <code>String</code>.
+ *
* @param expectedDocument
* 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));
}
/**
* Asserts no error-level feedback messages.
- *
+ *
* @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());
}
/**
* Asserts no info-level feedback messages.
- *
+ *
* @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());
}
/**
* Retrieves <code>FeedbackMessages</code>.
- *
+ *
* @param level
* level of feedback message, for example:
* <code>FeedbackMessage.DEBUG or FeedbackMessage.INFO.. etc</code>
* @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;
}
@@ -865,55 +910,55 @@
/**
* Dumps the source of last rendered <code>Page</code>.
*/
- public void dumpPage() {
+ public void dumpPage()
+ {
log.info(getServletResponse().getDocument());
}
/**
* Dumps the <code>Component</code> trees.
*/
- public void debugComponentTrees() {
+ public void debugComponentTrees()
+ {
debugComponentTrees("");
}
/**
- * Dumps the <code>Component</code> trees to log. Show only the
- * <code>Component</code>s whose paths contain the filter
- * <code>String</code>.
- *
+ * 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
* 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 + "]");
}
}
}
/**
- * 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.
+ * 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
- * <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.
- *
+ * 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 <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);
@@ -926,7 +971,8 @@
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;
}
@@ -936,38 +982,40 @@
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);
}
/**
* Simulates the firing of an Ajax event.
- *
+ *
* @see #executeAjaxEvent(Component, String)
- *
+ *
* @since 1.2.3
* @param componentPath
* the <code>Component</code> path
* @param event
- * the event which we simulate being fired. If <code>event</code>
- * is <code>null</code>, 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);
}
/**
- * Simulates the firing of an Ajax event. You add an Ajax event to a
- * <code>Component</code> by using:
- *
+ * Simulates the firing of an Ajax event. You add an Ajax event to a <code>Component</code> by
+ * using:
+ *
* <pre>
* ...
* component.add(new AjaxEventBehavior("ondblclick") {
@@ -975,34 +1023,34 @@
* });
* ...
* </pre>
- *
- * You can then test that the code inside <code>onEvent</code> actually
- * does what it's supposed to, using the <code>WicketTester</code>:
- *
+ *
+ * You can then test that the code inside <code>onEvent</code> actually does what it's
+ * supposed to, using the <code>WicketTester</code>:
+ *
* <pre>
* ...
* tester.executeAjaxEvent(component, "ondblclick");
* // Test that the code inside onEvent is correct.
* ...
* </pre>
- *
- * This also works with <code>AjaxFormSubmitBehavior</code>, where it
- * will "submit" the <code>Form</code> 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
- * <code>Component</code> 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 <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.
+ * 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 to simulate being fired. If <code>event</code> is
- * <code>null</code>, 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);
@@ -1013,14 +1061,17 @@
// 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;
}
}
@@ -1028,24 +1079,27 @@
// If there haven't been found any event behaviors on the component
// which matches 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
// 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);
}
@@ -1056,64 +1110,66 @@
}
/**
- * 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.
- *
+ * 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 <code>wicket:id</code> to search for
- * @return the <code>TagTester</code> for the tag which has the given
- * <code>wicket:id</code>
+ * @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);
}
/**
- * 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.
- *
+ * 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 <code>TagTester</code> for the tag which has the given DOM
- * id
+ * @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 Ajax call should submit an
- * associated <code>Form</code>.
- *
+ * Helper method for all the places where an Ajax call should submit an associated
+ * <code>Form</code>.
+ *
* @param behavior
- * The <code>AjaxFormSubmitBehavior</code> with the
- * <code>Form</code> 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();
@@ -1121,7 +1177,8 @@
// modify an existing
// request parameter explicitly set using
// FormTester.setValue()
- if (getServletRequest().getParameterMap().get(name) == null) {
+ if (getServletRequest().getParameterMap().get(name) == null)
+ {
getServletRequest().setParameter(name, value);
}
}
@@ -1131,13 +1188,15 @@
/**
* Retrieves the content type from the response header.
- *
+ *
* @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;
@@ -1145,13 +1204,15 @@
/**
* Retrieves the content length from the response header.
- *
+ *
* @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);
@@ -1159,56 +1220,68 @@
/**
* Retrieves the last-modified value from the response header.
- *
+ *
* @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 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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -44,8 +44,7 @@
}
/**
- * Sets the <code>TestPageSource</code> for this
- * <code>DummyHomePage</code>.
+ * Sets the <code>TestPageSource</code> for this <code>DummyHomePage</code>.
*
* @param testPageSource
* an <code>ITestPageSource</code> instance
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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -26,9 +26,9 @@
import java.util.List;
/**
- * <code>ExternalPageViewer</code> class. 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
@@ -38,7 +38,8 @@
{
private static final List browserPaths = new ArrayList();
- // TODO Post 1.2: General: We could use JNLP to launch browser (see http://www.croftsoft.com/library/tutorials/browser/), but why not use Swing HTMLArea??
+ // TODO Post 1.2: General: We could use JNLP to launch browser (see
+ // http://www.croftsoft.com/library/tutorials/browser/), but why not use Swing HTMLArea??
static
{
registerBrowserPath("C:/Program Files/Mozilla Firefox/firefox.exe");
@@ -48,7 +49,7 @@
private final WicketTester tester;
/**
- *
+ *
* @param tester
*/
public ExternalPageViewer(final WicketTester tester)
@@ -58,7 +59,7 @@
/**
* register additional browser path for viewInBrowser()
- *
+ *
* @param path
*/
public static final void registerBrowserPath(String path)
@@ -124,7 +125,7 @@
}
/**
- *
+ *
* @return path
*/
private String getBrowserPath()
@@ -142,9 +143,9 @@
}
/**
- * define a temporary file name that stores source of last rendered page.
- * This file is used by external browser
- *
+ * define a temporary file name that stores source of last rendered page. This file is used by
+ * external browser
+ *
* @return String
*/
protected String getTemperaryDumpHtmlFileName()
@@ -155,7 +156,7 @@
/**
* set default encoding for writing temporary file.
- *
+ *
* @return String
*/
protected String getHtmlEncoding()
@@ -164,7 +165,7 @@
}
/**
- *
+ *
* @return URL
*/
private URL getThisClassFileURL()
@@ -175,7 +176,7 @@
}
/**
- *
+ *
* @param e
* @return RuntimeException
*/
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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -49,8 +49,7 @@
/**
- * A helper class for testing validation and submission of
- * <code>FormComponent</code>s.
+ * A helper class for testing validation and submission of <code>FormComponent</code>s.
*
* @author Ingram Chen
* @author Frank Bille (frankbille)
@@ -59,9 +58,9 @@
public class FormTester
{
/**
- * 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.
+ * 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
{
@@ -101,8 +100,9 @@
/**
* Constructor.
- *
- * @param formComponent a <code>FormComponent</code>
+ *
+ * @param formComponent
+ * a <code>FormComponent</code>
*/
protected ChoiceSelector(FormComponent formComponent)
{
@@ -121,7 +121,7 @@
/**
* Selects a given index in a selectable <code>FormComponent</code>.
- *
+ *
* @param index
*/
protected final void doSelect(final int index)
@@ -132,8 +132,7 @@
new SearchOptionByIndexVisitor(index));
if (foundRadio == null)
{
- fail("RadioGroup " + formComponent.getPath() + " does not have index:"
- + index);
+ fail("RadioGroup " + formComponent.getPath() + " does not have index:" + index);
}
assignValueToFormComponent(formComponent, foundRadio.getValue());
}
@@ -143,8 +142,7 @@
new SearchOptionByIndexVisitor(index));
if (foundCheck == null)
{
- fail("CheckGroup " + formComponent.getPath() + " does not have index:"
- + index);
+ fail("CheckGroup " + formComponent.getPath() + " does not have index:" + index);
}
assignValueToFormComponent(formComponent, foundCheck.getValue());
@@ -211,8 +209,8 @@
}
/**
- * A factory that creates an appropriate <code>ChoiceSelector</code> based
- * on type of <code>FormComponent</code>.
+ * A factory that creates an appropriate <code>ChoiceSelector</code> based on type of
+ * <code>FormComponent</code>.
*/
private class ChoiceSelectorFactory
{
@@ -223,21 +221,22 @@
{
/**
* Constructor.
- *
- * @param formComponent a <code>FormComponent</code>
+ *
+ * @param formComponent
+ * a <code>FormComponent</code>
*/
protected MultipleChoiceSelector(FormComponent formComponent)
{
super(formComponent);
if (!allowMultipleChoice(formComponent))
{
- fail("Component:'" + formComponent.getPath()
- + "' Does not support multiple selection.");
+ fail("Component:'" + formComponent.getPath() +
+ "' Does not support multiple selection.");
}
}
/**
- *
+ *
* @see org.apache.wicket.util.tester.FormTester.ChoiceSelector#assignValueToFormComponent(org.apache.wicket.markup.html.form.FormComponent,
* java.lang.String)
*/
@@ -255,8 +254,9 @@
{
/**
* Constructor.
- *
- * @param formComponent a <code>FormComponent</code>
+ *
+ * @param formComponent
+ * a <code>FormComponent</code>
*/
protected SingleChoiceSelector(FormComponent formComponent)
{
@@ -288,8 +288,8 @@
fail("Trying to select on null component.");
}
- if (formComponent instanceof RadioGroup || formComponent instanceof DropDownChoice
- || formComponent instanceof RadioChoice)
+ if (formComponent instanceof RadioGroup || formComponent instanceof DropDownChoice ||
+ formComponent instanceof RadioChoice)
{
return new SingleChoiceSelector(formComponent);
}
@@ -299,8 +299,8 @@
}
else
{
- fail("Selecting on the component:'" + formComponent.getPath()
- + "' is not supported.");
+ fail("Selecting on the component:'" + formComponent.getPath() +
+ "' is not supported.");
return null;
}
}
@@ -322,21 +322,20 @@
*
* @param formComponent
* a <code>FormComponent</code>
- * @return <code>true</code> if the given FormComponent allows
- * multiple choice
+ * @return <code>true</code> if the given FormComponent allows multiple choice
*/
private boolean allowMultipleChoice(FormComponent formComponent)
{
- return formComponent instanceof CheckGroup
- || formComponent instanceof ListMultipleChoice;
+ return formComponent instanceof CheckGroup ||
+ formComponent instanceof ListMultipleChoice;
}
}
private final ChoiceSelectorFactory choiceSelectorFactory = new ChoiceSelectorFactory();
/**
- * An instance of <code>FormTester</code> 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;
@@ -357,19 +356,18 @@
* @param workingForm
* <code>FormComponent</code> to be tested
* @param wicketTester
- * <code>WicketTester</code> that creates
- * <code>FormTester</code>
+ * <code>WicketTester</code> that creates <code>FormTester</code>
* @param fillBlankString
- * specifies whether to fill child <code>TextComponent</code>s
- * with blank <code>String</code>s
+ * 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)
{
this.path = path;
this.workingForm = workingForm;
- this.baseWicketTester = wicketTester;
- this.baseWicketTester.setupRequestAndResponse();
+ baseWicketTester = wicketTester;
+ baseWicketTester.setupRequestAndResponse();
// fill blank String for Text Component.
workingForm.visitFormComponents(new FormComponent.AbstractVisitor()
@@ -398,7 +396,7 @@
setFormComponentValue(formComponent, formComponent.getValue());
}
}
- else if ( (formComponent instanceof DropDownChoice) ||
+ else if ((formComponent instanceof DropDownChoice) ||
(formComponent instanceof RadioChoice) ||
(formComponent instanceof CheckBox))
{
@@ -406,7 +404,8 @@
}
else if (formComponent instanceof ListMultipleChoice)
{
- final String[] modelValues = formComponent.getValue().split(FormComponent.VALUE_SEPARATOR);
+ final String[] modelValues = formComponent.getValue().split(
+ FormComponent.VALUE_SEPARATOR);
for (int i = 0; i < modelValues.length; i++)
{
addFormComponentValue(formComponent, modelValues[i]);
@@ -414,14 +413,14 @@
}
else if (formComponent instanceof CheckGroup)
{
- final Collection checkGroupValues = (Collection) formComponent.getModelObject();
+ final Collection checkGroupValues = (Collection)formComponent.getModelObject();
formComponent.visitChildren(Check.class, new IVisitor()
{
public Object component(Component component)
{
if (checkGroupValues.contains(component.getModelObject()))
{
- addFormComponentValue(formComponent, ((Check) component).getValue());
+ addFormComponentValue(formComponent, ((Check)component).getValue());
}
return CONTINUE_TRAVERSAL;
}
@@ -443,8 +442,7 @@
}
/**
- * Gets the value for an <code>AbstractTextComponent</code> with the
- * provided id.
+ * Gets the value for an <code>AbstractTextComponent</code> with the provided id.
*
* @param id
* <code>Component</code> id
@@ -461,13 +459,12 @@
}
/**
- * 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.
+ * 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 <code>Form</code>) to the selectable
@@ -478,18 +475,21 @@
public void select(String formComponentId, int index)
{
checkClosed();
- FormComponent component = (FormComponent)workingForm
- .get(formComponentId);
+ FormComponent component = (FormComponent)workingForm.get(formComponentId);
ChoiceSelector choiceSelector = choiceSelectorFactory.create(component);
choiceSelector.doSelect(index);
- if (component instanceof DropDownChoice) {
+ if (component instanceof DropDownChoice)
+ {
try
{
- Method wantOnSelectionChangedNotificationsMethod = DropDownChoice.class.getDeclaredMethod("wantOnSelectionChangedNotifications", new Class[0]);
+ Method wantOnSelectionChangedNotificationsMethod = DropDownChoice.class
+ .getDeclaredMethod("wantOnSelectionChangedNotifications", new Class[0]);
wantOnSelectionChangedNotificationsMethod.setAccessible(true);
- boolean wantOnSelectionChangedNotifications = ((Boolean)wantOnSelectionChangedNotificationsMethod.invoke(component, new Object[0])).booleanValue();
- if (wantOnSelectionChangedNotifications) {
+ boolean wantOnSelectionChangedNotifications = ((Boolean)wantOnSelectionChangedNotificationsMethod
+ .invoke(component, new Object[0])).booleanValue();
+ if (wantOnSelectionChangedNotifications)
+ {
((DropDownChoice)component).onSelectionChanged();
}
}
@@ -501,9 +501,8 @@
}
/**
- * A convenience method to select multiple options for the
- * <code>FormComponent</code>. The method only support multiple
- * selectable <code>FormComponent</code>s.
+ * 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)
*
@@ -518,7 +517,7 @@
checkClosed();
ChoiceSelector choiceSelector = choiceSelectorFactory
- .createForMultiple((FormComponent)workingForm.get(formComponentId));
+ .createForMultiple((FormComponent)workingForm.get(formComponentId));
for (int i = 0; i < indexes.length; i++)
{
@@ -548,8 +547,8 @@
*
* @param formComponentId
* relative path (from <code>Form</code>) to the selectable
- * <code>FormComponent</code>. The <code>FormComponent</code>
- * must be of a type <code>FileUploadField</code>.
+ * <code>FormComponent</code>. The <code>FormComponent</code> must be of a type
+ * <code>FileUploadField</code>.
* @param file
* the <code>File</code> to upload.
* @param contentType
@@ -563,9 +562,9 @@
if (formComponent instanceof FileUploadField == false)
{
- throw new IllegalArgumentException("'" + formComponentId + "' is not "
- + "a FileUploadField. You can only attach a file to form "
- + "component of this type.");
+ throw new IllegalArgumentException("'" + formComponentId + "' is not " +
+ "a FileUploadField. You can only attach a file to form " +
+ "component of this type.");
}
MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
@@ -573,8 +572,7 @@
}
/**
- * Submits the <code>Form</code>. Note that <code>submit</code> can be
- * executed only once.
+ * Submits the <code>Form</code>. Note that <code>submit</code> can be executed only once.
*/
public void submit()
{
@@ -618,11 +616,10 @@
}
/**
- * A convenience method for submitting the <code>Form</code> with an
- * alternate button.
+ * 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:
+ * 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");
@@ -639,9 +636,8 @@
}
/**
- * Adds an additional <code>FormComponent</code>'s value into request
- * parameter -- this method retains existing parameters but removes any
- * duplicate 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>
@@ -668,27 +664,24 @@
}
/**
- * <code>FormTester</code> must only be used once. Create a new instance
- * of <code>FormTester</code> 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()
{
if (closed)
{
- throw new IllegalStateException("'" + path
- + "' already sumbitted. Note that FormTester "
- + "is allowed to submit only once");
+ throw new IllegalStateException("'" + path +
+ "' already sumbitted. Note that FormTester " + "is allowed to submit only once");
}
}
/**
- * Returns <code>true</code> if the parameter exists in the
- * <code>FormComponent</code>.
+ * Returns <code>true</code> if the parameter exists in the <code>FormComponent</code>.
*
* @param formComponent
* a <code>FormComponent</code>
- * @return <code>true</code> if the parameter exists in the
- * <code>FormComponent</code>
+ * @return <code>true</code> if the parameter exists in the <code>FormComponent</code>
*/
private boolean parameterExist(FormComponent formComponent)
{
@@ -698,8 +691,7 @@
}
/**
- * Set formComponent's value into request parameter, this method overwrites
- * existing parameters.
+ * Set formComponent's value into request parameter, this method overwrites existing parameters.
*
* @param formComponent
* a <code>FormComponent</code>
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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -28,8 +28,7 @@
public interface ITestPageSource extends IClusterable
{
/**
- * Defines a <code>Page</code> instance source for
- * <code>WicketTester</code>.
+ * Defines a <code>Page</code> instance source for <code>WicketTester</code>.
*
* @return a <code>Page</code> instance for testing
*/
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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -27,14 +27,14 @@
/**
- * 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 don't fail when the generated markup changes just a little bit.
+ * 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 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 precisely how the markup looks instead of which
- * attributes exists on the given tags, and what values they have.
+ * It also gives a more programmatic way of testing the generated output, by not 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:
*
@@ -59,9 +59,12 @@
/**
* Constructor.
*
- * @param parser an <code>XmlPullParser</code>
- * @param openTag an opening XML tag
- * @param closeTag a closing XML tag
+ * @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)
{
@@ -81,13 +84,12 @@
}
/**
- * 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.
+ * 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
* an attribute to look for in the tag
- * @return <code>true</code> if the tag has the attribute,
- * <code>false</code> if not.
+ * @return <code>true</code> if the tag has the attribute, <code>false</code> if not.
*/
public boolean hasAttribute(String attribute)
{
@@ -102,13 +104,12 @@
}
/**
- * Gets the value for a given attribute. Please note that this is non
- * case-sensitive, because attributes in HTML may be non case-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
* an attribute to look for in the tag
- * @return the value of the attribute or <code>null</code> if it isn't
- * found.
+ * @return the value of the attribute or <code>null</code> if it isn't found.
*/
public String getAttribute(String attribute)
{
@@ -116,11 +117,11 @@
IValueMap attributeMap = openTag.getAttributes();
- if (attributeMap != null)
+ if (attributeMap != null)
{
for (Iterator iter = attributeMap.keySet().iterator(); iter.hasNext();)
{
- String attr = (String) iter.next();
+ String attr = (String)iter.next();
if (attr.equalsIgnoreCase(attribute))
{
@@ -156,8 +157,7 @@
* the attribute to test on
* @param partialValue
* the partial value to test if the attribute value contains it
- * @return <code>true</code> if the attribute value contains the partial
- * value
+ * @return <code>true</code> if the attribute value contains the partial value
*/
public boolean getAttributeContains(String attribute, String partialValue)
{
@@ -186,8 +186,7 @@
* an attribute to test
* @param expected
* 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
+ * @return <code>true</code> if the attribute's value is the same as the given value
*/
public boolean getAttributeIs(String attribute, String expected)
{
@@ -210,8 +209,7 @@
* an attribute to test
* @param expected
* the expected value
- * @return <code>true</code> if the attribute's value ends with the
- * expected value
+ * @return <code>true</code> if the attribute's value ends with the expected value
*/
public boolean getAttributeEndsWith(String attribute, String expected)
{
@@ -238,8 +236,7 @@
*
* @param tagName
* the tag name to search for
- * @return <code>true</code> if this tag has a child with the given
- * <code>tagName</code>.
+ * @return <code>true</code> if this tag has a child with the given <code>tagName</code>.
*/
public boolean hasChildTag(String tagName)
{
@@ -249,10 +246,10 @@
{
throw new IllegalArgumentException("You need to provide a not empty/not null argument.");
}
-
+
if (openTag.isOpen())
{
- try
+ try
{
// Get the content of the tag
int startPos = openTag.getPos() + openTag.getLength();
@@ -265,7 +262,7 @@
p.parse(markup);
XmlTag tag = null;
- while((tag = (XmlTag) p.nextTag()) != null)
+ while ((tag = (XmlTag)p.nextTag()) != null)
{
if (tagName.equalsIgnoreCase(tag.getName()))
{
@@ -287,8 +284,8 @@
}
/**
- * Gets a child tag for testing. If this tag contains child tags, you can
- * get one of them as a {@link TagTester} instance.
+ * 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
* an attribute on the child tag to search for
@@ -315,8 +312,8 @@
}
/**
- * Gets the markup for this tag. This includes all markup 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 all the markup between the open tag and the close tag
*/
@@ -330,28 +327,26 @@
}
/**
- * 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.
+ * 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
- * <code>TagTester</code> 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
* @param value
* 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
+ * @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)
{
TagTester tester = null;
- if (Strings.isEmpty(markup) == false && Strings.isEmpty(attribute) == false
- && Strings.isEmpty(value) == false)
+ if (Strings.isEmpty(markup) == false && Strings.isEmpty(attribute) == false &&
+ Strings.isEmpty(value) == false)
{
try
{
@@ -374,8 +369,8 @@
for (Iterator iter = attributeMap.keySet().iterator(); iter.hasNext();)
{
- String attr = (String) iter.next();
-
+ String attr = (String)iter.next();
+
if (attr.equals(attribute) && value.equals(attributeMap.get(attr)))
{
if (xmlTag.isOpen())
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=584925&r1=584924&r2=584925&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 Mon Oct 15 14:21:25 2007
@@ -28,14 +28,12 @@
public interface TestPanelSource extends IClusterable
{
/**
- * Defines a <code>Panel</code> instance source for
- * <code>WicketTester</code>.
+ * Defines a <code>Panel</code> instance source for <code>WicketTester</code>.
*
* @param panelId
* <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>.
+ * @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);
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTester.java Mon Oct 15 14:21:25 2007
@@ -46,17 +46,20 @@
/**
- * A helper class to ease unit testing of Wicket applications without the need
- * for a servlet container. To start a test, either use <code>startPage</code>
- * or <code>startPanel</code>:
+ * A helper class to ease unit testing of Wicket applications without the need for a servlet
+ * container. To start a test, either use <code>startPage</code> or <code>startPanel</code>:
*
* <pre>
* // production page
- * public class MyPage extends WebPage {
- * public MyPage() {
+ * public class MyPage extends WebPage
+ * {
+ * public MyPage()
+ * {
* add(new Label("myMessage", "Hello!"));
- * add(new Link("toYourPage") {
- * public void onClick() {
+ * add(new Link("toYourPage")
+ * {
+ * public void onClick()
+ * {
* setResponsePage(new YourPage("Hi!"));
* }
* });
@@ -68,11 +71,13 @@
* // test code
* private WicketTester tester;
*
- * public void setUp() {
+ * public void setUp()
+ * {
* tester = new WicketTester();
* }
*
- * public void testRenderMyPage() {
+ * public void testRenderMyPage()
+ * {
* //start and render the test page
* tester.startPage(MyPage.class);
* //assert rendered page class
@@ -82,21 +87,23 @@
* }
* </pre>
*
- * The above example is straight forward: start <code>MyPage.class</code> and
- * assert <code>Label</code> it rendered. Next, we try to navigate through a
- * <code>Link</code>:
+ * The above example is straight forward: start <code>MyPage.class</code> and assert
+ * <code>Label</code> it rendered. Next, we try to navigate through a <code>Link</code>:
*
* <pre>
* // production page
- * public class YourPage extends WebPage {
- * public YourPage(String message) {
+ * public class YourPage extends WebPage
+ * {
+ * public YourPage(String message)
+ * {
* add(new Label("yourMessage", message));
* info("Wicket Rocks ;-)");
* }
* }
*
* //test code
- * public void testLinkToYourPage() {
+ * public void testLinkToYourPage()
+ * {
* tester.startPage(MyPage.class);
* //click link and render
* tester.clickLink("toYourPage");
@@ -105,17 +112,19 @@
* }
* </pre>
*
- * <code>tester.clickLink(path);</code> will simulate user click on the
- * component (in this case, it's a <code>Link</code>) and render the response
- * page <code>YourPage</code>. Ok, unit test of <code>MyPage</code> is
- * completed. Now we test <code>YourPage</code> standalone:
+ * <code>tester.clickLink(path);</code> will simulate user click on the component (in this case,
+ * it's a <code>Link</code>) and render the response page <code>YourPage</code>. Ok, unit test
+ * of <code>MyPage</code> is completed. Now we test <code>YourPage</code> standalone:
*
* <pre>
* //test code
- * public void testRenderYourPage() {
+ * public void testRenderYourPage()
+ * {
* // provide page instance source for WicketTester
- * tester.startPage(new TestPageSource() {
- * public Page getTestPage() {
+ * tester.startPage(new TestPageSource()
+ * {
+ * public Page getTestPage()
+ * {
* return new YourPage("mock message");
* }
* });
@@ -127,11 +136,10 @@
* </pre>
*
* Instead of <code>tester.startPage(pageClass)</code>, we define a
- * {@link org.apache.wicket.util.tester.ITestPageSource} to provide testing page
- * instance for <code>WicketTester</code>. This is necessary because
- * <code>YourPage</code> uses a custom constructor, which is very common for
- * transferring model data, but cannot be instantiated by reflection. Finally,
- * we use <code>assertInfoMessages</code> to assert there is a feedback
+ * {@link org.apache.wicket.util.tester.ITestPageSource} to provide testing page instance for
+ * <code>WicketTester</code>. This is necessary because <code>YourPage</code> uses a custom
+ * constructor, which is very common for transferring model data, but cannot be instantiated by
+ * reflection. Finally, we use <code>assertInfoMessages</code> to assert there is a feedback
* message "Wicket Rocks ;-)" at the INFO level.
*
* TODO General: Example usage of FormTester
@@ -144,8 +152,8 @@
public class WicketTester extends BaseWicketTester
{
/**
- * Default dummy web application for testing. Uses {@link HttpSessionStore}
- * to store pages and the <code>Session</code>.
+ * Default dummy web application for testing. Uses {@link HttpSessionStore} to store pages and
+ * the <code>Session</code>.
*/
public static class DummyWebApplication extends WebApplication
{
@@ -179,9 +187,8 @@
}
/**
- * Dummy web application that does not support back button support but is
- * cheaper to use for unit tests. Uses {@link SecondLevelCacheSessionStore}
- * with a noop {@link IPageStore}.
+ * Dummy web application that does not support back button support but is cheaper to use for
+ * unit tests. Uses {@link SecondLevelCacheSessionStore} with a noop {@link IPageStore}.
*/
public static class NonPageCachingDummyWebApplication extends DummyWebApplication
{
@@ -228,8 +235,8 @@
private static final Logger log = LoggerFactory.getLogger(WicketTester.class);
/**
- * Creates a <code>WicketTester</code> and automatically creates a
- * <code>WebApplication</code>, but the tester will have no home page.
+ * Creates a <code>WicketTester</code> and automatically creates a <code>WebApplication</code>,
+ * but the tester will have no home page.
*/
public WicketTester()
{
@@ -237,8 +244,7 @@
}
/**
- * Creates a <code>WicketTester</code> and automatically creates a
- * <code>WebApplication</code>.
+ * Creates a <code>WicketTester</code> and automatically creates a <code>WebApplication</code>.
*
* @param homePage
* a home page <code>Class</code>
@@ -278,8 +284,7 @@
* Creates a <code>WicketTester</code>.
*
* @param application
- * a <code>WicketTester</code> <code>WebApplication</code>
- * object
+ * a <code>WicketTester</code> <code>WebApplication</code> object
*/
public WicketTester(final WebApplication application)
{
@@ -290,11 +295,10 @@
* Creates a <code>WicketTester</code> to help unit testing.
*
* @param application
- * a <code>WicketTester</code> <code>WebApplication</code>
- * object
+ * a <code>WicketTester</code> <code>WebApplication</code> object
* @param path
- * the absolute path on disk to the web application's contents
- * (e.g. war root) - may be <code>null</code>
+ * the absolute path on disk to the web application'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)
@@ -350,16 +354,13 @@
}
/**
- * 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.
+ * 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
- * <code>Component</code> in the client DOM tree, using Javascript. But it
- * shouldn't be needed because you just have to trust that Wicket Ajax
- * Javascript works.
+ * 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 just have to trust that
+ * Wicket Ajax Javascript works.
*
* @param component
* a <code>Component</code> to be tested
@@ -371,16 +372,13 @@
}
/**
- * 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.
+ * 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
- * <code>Component</code> in the client DOM tree, using Javascript. But it
- * shouldn't be needed because you just have to trust that Wicket Ajax
- * Javascript works.
+ * 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 just have to trust that
+ * Wicket Ajax Javascript works.
*
* @param componentPath
* a <code>Component</code> path to test
@@ -391,8 +389,7 @@
}
/**
- * Asserts the content of last rendered page contains (matches) a given
- * regex pattern.
+ * Asserts the content of last rendered page contains (matches) a given regex pattern.
*
* @param pattern
* a reqex pattern to match
@@ -462,8 +459,7 @@
* @param path
* path to a {@link ListView} <code>Component</code>
* @param expectedList
- * expected <code>List</code> in the model of the given
- * {@link ListView}
+ * expected <code>List</code> in the model of the given {@link ListView}
*/
public void assertListView(String path, List expectedList)
{
@@ -516,15 +512,14 @@
}
/**
- * Asserts last-rendered <code>Page</code> 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.
*
* @param clazz
- * <code>Class</code> used to load the file (relative to
- * <code>clazz</code> package)
+ * <code>Class</code> used to load the file (relative to <code>clazz</code>
+ * package)
* @param filename
* expected output filename <code>String</code>
* @throws Exception
@@ -537,8 +532,8 @@
}
/**
- * Asserts last-rendered <code>Page</code> against an expected HTML
- * document as a <code>String</code>
+ * Asserts last-rendered <code>Page</code> against an expected HTML document as a
+ * <code>String</code>
*
* @param expectedDocument
* expected output <code>String</code>
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java Mon Oct 15 14:21:25 2007
@@ -58,9 +58,8 @@
}
/**
- * Gets recursively all <code>Component</code>s of a given
- * <code>Page</code>, extracts the information relevant to us, and adds
- * them to a <code>List</code>.
+ * Gets recursively all <code>Component</code>s of a given <code>Page</code>, extracts the
+ * information relevant to us, and adds them to a <code>List</code>.
*
* @param page
* the <code>Page</code> to analyze
@@ -133,8 +132,8 @@
*/
public static void failWithVerboseMessage(final Collection expects, final Collection actuals)
{
- Assert.fail("\nexpect (" + expects.size() + "):\n" + asLined(expects) + "\nbut was ("
- + actuals.size() + "):\n" + asLined(actuals));
+ Assert.fail("\nexpect (" + expects.size() + "):\n" + asLined(expects) + "\nbut was (" +
+ actuals.size() + "):\n" + asLined(actuals));
}
/**
@@ -142,8 +141,7 @@
*
* @param objects
* a <code>Collection</code> object
- * @return a <code>String</code> representation of the
- * <code>Collection</code>
+ * @return a <code>String</code> representation of the <code>Collection</code>
*/
public static String asLined(final Collection objects)
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Lock.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Lock.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Lock.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/thread/Lock.java Mon Oct 15 14:21:25 2007
@@ -17,8 +17,7 @@
package org.apache.wicket.util.thread;
/**
- * Type-safe monitor class to be used in place of <code>Object</code> for
- * readability.
+ * Type-safe monitor class to be used in place of <code>Object</code> for readability.
*
* @author Jonathan Locke
* @since 1.2.6