Author: frankbille
Date: Tue May 27 13:52:54 2008
New Revision: 660698
URL: http://svn.apache.org/viewvc?rev=660698&view=rev
Log:
WICKET-1658. BaseWicketTester#clickLink didn't process the request cycle
correctly with Ajax*Links, which means that redirecting to a response page
didn't work.
Added:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
(with props)
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
(with props)
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=660698&r1=660697&r2=660698&view=diff
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
(original)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
Tue May 27 13:52:54 2008
@@ -661,7 +661,7 @@
AjaxLink link = (AjaxLink)linkComponent;
setupRequestAndResponse(true);
- RequestCycle requestCycle = createRequestCycle();
+ WebRequestCycle requestCycle = createRequestCycle();
callOnBeginRequest(requestCycle);
AjaxRequestTarget target = new
AjaxRequestTarget(link.getPage());
requestCycle.setRequestTarget(target);
@@ -669,8 +669,7 @@
link.onClick(target);
// process the request target
- target.respond(requestCycle);
- requestCycle.detach();
+ processRequestCycle(requestCycle);
}
// AjaxFallbackLinks is processed like an AjaxLink if isAjax is
true
// If it's not handling of the linkComponent is passed through
to the
@@ -680,15 +679,14 @@
AjaxFallbackLink link = (AjaxFallbackLink)linkComponent;
setupRequestAndResponse(true);
- RequestCycle requestCycle = createRequestCycle();
+ WebRequestCycle requestCycle = createRequestCycle();
AjaxRequestTarget target = new
AjaxRequestTarget(link.getPage());
requestCycle.setRequestTarget(target);
link.onClick(target);
// process the request target
- target.respond(requestCycle);
- requestCycle.detach();
+ processRequestCycle(requestCycle);
}
// if the link is an AjaxSubmitLink, we need to find the form
// from it using reflection so we know what to submit.
@@ -721,7 +719,7 @@
notNull(failMessage, ajaxFormSubmitBehavior);
setupRequestAndResponse(true);
- RequestCycle requestCycle = createRequestCycle();
+ WebRequestCycle requestCycle = createRequestCycle();
submitAjaxFormSubmitBehavior(ajaxFormSubmitBehavior);
@@ -729,8 +727,7 @@
ajaxFormSubmitBehavior.onRequest();
// process the request target
- requestCycle.getRequestTarget().respond(requestCycle);
- requestCycle.detach();
+ processRequestCycle(requestCycle);
}
/*
* If the link is a submitlink then we pretend to have clicked
it
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java?rev=660698&r1=660697&r2=660698&view=diff
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
(original)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
Tue May 27 13:52:54 2008
@@ -41,6 +41,8 @@
import org.apache.wicket.util.tester.apps_1.MyMockApplication;
import org.apache.wicket.util.tester.apps_1.SuccessPage;
import org.apache.wicket.util.tester.apps_1.ViewBook;
+import org.apache.wicket.util.tester.apps_6.LinkPage;
+import org.apache.wicket.util.tester.apps_6.ResultPage;
/**
*
@@ -159,6 +161,104 @@
/**
* @throws Exception
*/
+ public void testClickLink_setResponsePageClass() throws Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page class in the link callback
+ tester.clickLink("linkWithSetResponsePageClass");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "No Parameter");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testClickLink_setResponsePage() throws Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page instance in the link callback
+ tester.clickLink("linkWithSetResponsePage");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "A special label");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testClickLink_ajaxLink_setResponsePageClass() throws
Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page class in the link callback
+ tester.clickLink("ajaxLinkWithSetResponsePageClass");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "No Parameter");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testClickLink_ajaxLink_setResponsePage() throws Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page instance in the link callback
+ tester.clickLink("ajaxLinkWithSetResponsePage");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "A special label");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testClickLink_ajaxFallbackLink_setResponsePageClass()
throws Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page class in the link callback
+ tester.clickLink("ajaxFallbackLinkWithSetResponsePageClass");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "No Parameter");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testClickLink_ajaxFallbackLink_setResponsePage() throws
Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page instance in the link callback
+ tester.clickLink("ajaxFallbackLinkWithSetResponsePage");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "A special label");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testClickLink_ajaxSubmitLink_setResponsePage() throws
Exception
+ {
+ tester.startPage(LinkPage.class);
+ tester.assertRenderedPage(LinkPage.class);
+
+ // Set the response page instance in the form submit
+ tester.clickLink("form:submit");
+ tester.assertRenderedPage(ResultPage.class);
+ tester.assertLabel("label", "A form label");
+ }
+
+ /**
+ * @throws Exception
+ */
public void testPageConstructor() throws Exception
{
Book mockBook = new Book("xxId", "xxName");
Added:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html?rev=660698&view=auto
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
(added)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.html
Tue May 27 13:52:54 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Click Link Test Page</title>
+</head>
+<body>
+<h2>Link</h2>
+<p>
+ <a wicket:id="linkWithSetResponsePageClass">Standard Link which calls
setResponsePage with page class</a>
+ <a wicket:id="linkWithSetResponsePage">Standard Link which calls
setResponsePage with page instance</a>
+</p>
+
+<h2>Ajax link</h2>
+<p>
+ <a wicket:id="ajaxLinkWithSetResponsePageClass">Standard AjaxLink which
calls setResponsePage with page class</a>
+ <a wicket:id="ajaxLinkWithSetResponsePage">Standard AjaxLink which
calls setResponsePage with page instance</a>
+</p>
+
+<h2>Ajax fallback link</h2>
+<p>
+ <a wicket:id="ajaxFallbackLinkWithSetResponsePageClass">Standard
AjaxFallbackLink which calls setResponsePage with page class</a>
+ <a wicket:id="ajaxFallbackLinkWithSetResponsePage">Standard
AjaxFallbackLink which calls setResponsePage with page instance</a>
+</p>
+
+<h2>Ajax submit form</h2>
+<form wicket:id="form">
+ <a wicket:id="submit">submit</a>
+</form>
+</body>
+</html>
\ No newline at end of file
Added:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java?rev=660698&view=auto
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
(added)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/LinkPage.java
Tue May 27 13:52:54 2008
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.tester.apps_6;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Different kinds of links, to be test the [EMAIL PROTECTED]
WicketTester#clickLink(String, boolean)} method.
+ *
+ * Add more links when needed.
+ */
+public class LinkPage extends WebPage
+{
+ /**
+ * Construct.
+ */
+ public LinkPage()
+ {
+ // Link
+ add(new Link("linkWithSetResponsePageClass")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick()
+ {
+
getRequestCycle().setResponsePage(ResultPage.class);
+ }
+ });
+
+ add(new Link("linkWithSetResponsePage")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick()
+ {
+ getRequestCycle().setResponsePage(new
ResultPage("A special label"));
+ }
+ });
+
+ // AjaxLink
+ add(new AjaxLink("ajaxLinkWithSetResponsePageClass")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick(AjaxRequestTarget target)
+ {
+
getRequestCycle().setResponsePage(ResultPage.class);
+ }
+ });
+
+ add(new AjaxLink("ajaxLinkWithSetResponsePage")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick(AjaxRequestTarget target)
+ {
+ getRequestCycle().setResponsePage(new
ResultPage("A special label"));
+ }
+ });
+
+ // AjaxFallbackLink
+ add(new
AjaxFallbackLink("ajaxFallbackLinkWithSetResponsePageClass")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick(AjaxRequestTarget target)
+ {
+
getRequestCycle().setResponsePage(ResultPage.class);
+ }
+ });
+
+ add(new AjaxFallbackLink("ajaxFallbackLinkWithSetResponsePage")
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void onClick(AjaxRequestTarget target)
+ {
+ getRequestCycle().setResponsePage(new
ResultPage("A special label"));
+ }
+ });
+
+ // AjaxSubmitLink
+ final Form form = new Form("form");
+ add(form);
+ final AjaxSubmitLink submit = new AjaxSubmitLink("submit")
+ {
+ private static final long serialVersionUID = 1L;
+
+ protected void onSubmit(final AjaxRequestTarget target,
final Form form)
+ {
+ getRequestCycle().setResponsePage(new
ResultPage("A form label"));
+ }
+ };
+ form.add(submit);
+ }
+}
Added:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html?rev=660698&view=auto
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
(added)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
Tue May 27 13:52:54 2008
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Insert title here</title>
+</head>
+<body>
+<span wicket:id="label"></span>
+</body>
+</html>
\ No newline at end of file
Propchange:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.html
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java?rev=660698&view=auto
==============================================================================
---
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
(added)
+++
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
Tue May 27 13:52:54 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.tester.apps_6;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.Model;
+
+/**
+ * Result page
+ */
+public class ResultPage extends WebPage
+{
+ /**
+ * Construct.
+ */
+ public ResultPage()
+ {
+ this("No Parameter");
+ }
+
+ /**
+ * Construct.
+ *
+ * @param label
+ */
+ public ResultPage(String label)
+ {
+ super(new Model(label));
+
+ add(new Label("label", getModel()));
+ }
+}
Propchange:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/apps_6/ResultPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain