/** * 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) { processRequestCycle(pageClass); return getLastRenderedPage(); }
/** * 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. */ public void clickLink(String path) { clickLink(path, true); }
/** * Dumps the <code>Component</code> trees. */ public void debugComponentTrees() { debugComponentTrees(""); }
/** * assert component invisible. * * @param path * path to component * @return a <code>Result</code> */ public Result isInvisible(String path) { return isNull("component '" + path + "' is visible", getComponentFromLastRenderedPage(path)); }
/** * 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); executeListener(form); }
Component linkComponent = getComponentFromLastRenderedPage(path); checkUsability(linkComponent); fail("Link " + path + "is an AjaxLink and will " + "not be invoked when AJAX (javascript) is disabled."); setupRequestAndResponse(true); WebRequestCycle requestCycle = createRequestCycle(); AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage()); requestCycle.setRequestTarget(target); processRequestCycle(requestCycle); setupRequestAndResponse(true); WebRequestCycle requestCycle = createRequestCycle(); AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage()); requestCycle.setRequestTarget(target); processRequestCycle(requestCycle); fail("Link " + path + "is an AjaxSubmitLink and " + "will not be invoked when AJAX (javascript) is disabled."); notNull(failMessage, ajaxFormSubmitBehavior); WebRequestCycle requestCycle = setupRequestAndResponse(true); setupAjaxSubmitRequestParameters(linkComponent, ajaxFormSubmitBehavior);
Component linkComponent = getComponentFromLastRenderedPage(path); checkUsability(linkComponent, true); for (AjaxEventBehavior behavior : behaviors) executeBehavior(behavior); submitAjaxFormSubmitBehavior(link, (AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link, "click")); executeBehavior(behavior); serializeFormToRequest(submitLink.getForm()); submitForm(submitLink.getForm().getPageRelativePath()); getResponse().sendRedirect(href); recordRequestResponse(); setupNextRequestCycle(); startPage(bookmarkablePageLink.getPageClass(), parameters); getURL.setAccessible(true); CharSequence url = (CharSequence)getURL.invoke(link); executeUrl(url.toString()); executeListener(link);
Component linkComponent = getComponentFromLastRenderedPage(path); fail("Link " + path + "is an AjaxLink and will " + "not be invoked when AJAX (javascript) is disabled."); setupRequestAndResponse(true); RequestCycle requestCycle = createRequestCycle(); callOnBeginRequest(requestCycle); AjaxRequestTarget target = new AjaxRequestTarget(link.getPage()); requestCycle.setRequestTarget(target); setupRequestAndResponse(true); RequestCycle requestCycle = createRequestCycle(); AjaxRequestTarget target = new AjaxRequestTarget(link.getPage()); requestCycle.setRequestTarget(target); fail("Link " + path + "is an AjaxSubmitLink and " + "will not be invoked when AJAX (javascript) is disabled."); notNull(failMessage, ajaxFormSubmitBehavior); setupRequestAndResponse(true); RequestCycle requestCycle = createRequestCycle(); submitAjaxFormSubmitBehavior(ajaxFormSubmitBehavior); getParametersForNextRequest().put(pageRelativePath, "x"); submitForm(submitLink.getForm().getPageRelativePath());
/** * assert component visible. * * @param path * path to component * @return a <code>Result</code> */ public Result isVisible(String path) { Component component = getLastRenderedPage().get(path); if (component == null) { fail("path: '" + path + "' does no exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); } return isTrue("component '" + path + "' is not visible", component.isVisibleInHierarchy()); }
/** * Asserts no info-level feedback messages. * * @return a <code>Result</code> */ public Result hasNoInfoMessage() { List<Serializable> messages = getMessages(FeedbackMessage.INFO); return isTrue( "expect no info message, but contains\n" + WicketTesterHelper.asLined(messages), messages.isEmpty()); }
/** * 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() * { * Book mockBook = new Book("myBookName"); * return new ViewBook(mockBook); * } * }); * </pre> * * @param testPageSource * a <code>Page</code> factory that creates a test page instance * @return the rendered Page */ public final Page startPage(final ITestPageSource testPageSource) { startPage(DummyHomePage.class); DummyHomePage page = (DummyHomePage)getLastRenderedPage(); page.setTestPageSource(testPageSource); executeListener(page.getTestPageLink()); return getLastRenderedPage(); }
public Component assertExists(final String path) { Component component = getComponentFromLastRenderedPage(path); if (component == null) { fail("path: '" + path + "' does not exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); return null; } return component; }
/** * assert component visible. * * @param path * path to component * @return a <code>Result</code> */ public Result isVisible(final String path) { final Result result; Component component = getComponentFromLastRenderedPage(path, false); if (component == null) { result = Result.fail("path: '" + path + "' does not exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); } else { result = isTrue("component '" + path + "' is not visible", component.isVisibleInHierarchy()); } return result; }
/** * assert component invisible. * * @param path * path to component * @return a <code>Result</code> */ public Result isInvisible(final String path) { final Result result; Component component = getComponentFromLastRenderedPage(path, false); if (component == null) { result = Result.fail("path: '" + path + "' does not exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); } else { result = isFalse("component '" + path + "' is visible", component.isVisibleInHierarchy()); } return result; }
/** * assert the text of <code>Label</code> component. * * @param path * path to <code>Label</code> component * @param expectedLabelText * expected label text * @return a <code>Result</code> */ public Result hasLabel(String path, String expectedLabelText) { Label label = (Label)getComponentFromLastRenderedPage(path); return isEqual(expectedLabelText, label.getDefaultModelObjectAsString()); }
/** * 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. */ public void executeAjaxEvent(final String componentPath, final String event) { Component component = getComponentFromLastRenderedPage(componentPath); executeAjaxEvent(component, event); }
/** * Triggers loading of all {@link AjaxLazyLoadPanel}'s content in the last rendered page. * * @param wt * the tester */ public static void executeAjaxLazyLoadPanel(final BaseWicketTester wt) { executeAjaxLazyLoadPanel(wt, wt.getLastRenderedPage()); }
PageLink pageLink = (PageLink)getComponentFromLastRenderedPage(path); try iPageLinkField.setAccessible(true); IPageLink iPageLink = (IPageLink)iPageLinkField.get(pageLink); return isEqual(expectedPageClass, iPageLink.getPageIdentity()); throw convertoUnexpect(e); throw convertoUnexpect(e); throw convertoUnexpect(e);
/** * assert component disabled. * * @param path * path to component * @return a <code>Result</code> */ public Result isDisabled(String path) { Component component = getLastRenderedPage().get(path); if (component == null) { fail("path: '" + path + "' does no exist for page: " + Classes.simpleName(getLastRenderedPage().getClass())); } return isFalse("component '" + path + "' is enabled", component.isEnabledInHierarchy()); }
private void internalExecuteAllTimerBehaviors(final Component component) { List<AbstractAjaxTimerBehavior> behaviors = component .getBehaviors(AbstractAjaxTimerBehavior.class); for (AbstractAjaxTimerBehavior timer : behaviors) { checkUsability(component, true); if (!timer.isStopped()) { if (log.isDebugEnabled()) { log.debug("Triggering AjaxSelfUpdatingTimerBehavior: {}", component.getClassRelativePath()); } executeBehavior(timer); } } }