You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2010/08/07 04:08:18 UTC
[jira] Updated: (WICKET-2898) Wicket Tester does not properly set
the rendered page when setResponsePage(xxx.class) and setRedirect(true) are
called as a result of executeAjaxEvent on an AjaxButton.
[ https://issues.apache.org/jira/browse/WICKET-2898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg updated WICKET-2898:
----------------------------------
Fix Version/s: 1.4.11
(was: 1.4.10)
> Wicket Tester does not properly set the rendered page when setResponsePage(xxx.class) and setRedirect(true) are called as a result of executeAjaxEvent on an AjaxButton.
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-2898
> URL: https://issues.apache.org/jira/browse/WICKET-2898
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4.8
> Reporter: Scott Hraban
> Fix For: 1.4.11, 1.5-M1
>
>
> The code that is being tested is supposed to AJAX submit a form, and if login is successful, do a redirect to the home page.
> It works in real life, but the Wicket Tester seems to have problems with it.
> The following is a simplification of the code being tested:
> public InputForm extends Form
> {
> public InputForm()
> {
> new AjaxButton("button", InputForm.this)
> {
> private static final long serialVersionUID = 1L;
> @Override
> protected void onSubmit(final AjaxRequestTarget target, final Form form)
> {
> setResponsePage(IndexPage.class);
> setRedirect(true);
> }
> };
> }
> @Override
> protected void onSubmit()
> {
> if (!<authenticate>)
> {
> error("fail");
> }
> }
> }
> And this is the test code:
> @Test
> public void testLogin()
> {
> tester.startPage(LoginPage.class);
> tester.assertRenderedPage(LoginPage.class);
> final FormTester formTester = tester.newFormTester("inputForm");
> formTester.setValue("username", "VALID");
> formTester.setValue("password", "VALID");
> formTester.setValue("button", "true");
> tester.executeAjaxEvent("inputForm:button", "onclick");
> tester.assertRenderedPage(IndexPage.class);
> tester.assertNoErrorMessage();
> }
> This issue seems to be specific in that we need the redirect, using AJAX, and setResponsePage() with a class. If I change it to setResponsePage(new IndexPage());, the there is no problem, but this is not the right thing to do for the real world.
> It appears that the problem might be in MockWebApplication::postProcessRequestCycle, in that the code in 1.3.7 tester passed this test, but the 1.4.8 tester does not, and this is the 1.3.7 and 1.4.8 code to compare:
> 1.3.7:
> if (httpResponse.isRedirect())
> {
> lastRenderedPage = generateLastRenderedPage(cycle);
> MockHttpServletRequest newHttpRequest = new MockHttpServletRequest(application,
> servletSession, application.getServletContext());
> newHttpRequest.setRequestToRedirectString(httpResponse.getRedirectLocation());
> wicketRequest = application.newWebRequest(newHttpRequest);
> cycle = createRequestCycle();
> cycle.request();
> }
> 1.4.8:
> if (httpResponse.isRedirect())
> {
> lastRenderedPage = generateLastRenderedPage(cycle);
> MockHttpServletRequest newHttpRequest = new MockHttpServletRequest(application,
> servletSession, application.getServletContext());
> newHttpRequest.setRequestToRedirectString(httpResponse.getRedirectLocation());
> wicketRequest = application.newWebRequest(newHttpRequest);
> cycle = createRequestCycle();
> cycle.request();
> }
> else
> {
> String url = httpResponse.getHeader("Ajax-Location");
> if (url != null)
> {
> MockHttpServletRequest newHttpRequest = new MockHttpServletRequest(application,
> servletSession, application.getServletContext());
> newHttpRequest.setRequestToRedirectString(url);
> wicketRequest = application.newWebRequest(newHttpRequest);
> cycle = createRequestCycle();
> cycle.request();
> }
> }
> What I notice is that the AJAX path for the redirect is missing the "lastRenderedPage = generateLastRenderedPage(cycle);" that is there for the regular redirect, and was there in 1.3.7 for the AJAX path (since there was no distinction.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.