You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/09/05 18:22:50 UTC
svn commit: r572984 - in
/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink:
./ HomePage.html HomePage.java TestHomePage.java
Author: jbq
Date: Wed Sep 5 09:22:38 2007
New Revision: 572984
URL: http://svn.apache.org/viewvc?rev=572984&view=rev
Log:
Adding unit tests for WICKET-932 BaseWicketTester support for SubmitLink
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.html
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java (with props)
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java (with props)
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.html?rev=572984&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.html Wed Sep 5 09:22:38 2007
@@ -0,0 +1,27 @@
+<!--
+ $Id: CookieValuePersisterTestPage.html 527232 2007-04-10 18:15:14Z jcompagner $
+ $Revision: 527232 $
+ $Date: 2007-04-10 20:15:14 +0200 (Tue, 10 Apr 2007) $
+
+ ====================================================================
+ Licensed 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+<body>
+ <form wicket:id="form">
+ <input type="text" wicket:id="text"/>
+ <a wicket:id="link">my link</a>
+ </form>
+</body>
+</html>
+
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java?rev=572984&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java Wed Sep 5 09:22:38 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.markup.html.form.submitlink;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.SubmitLink;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.PropertyModel;
+
+public class HomePage extends WebPage
+{
+ boolean submitted = false;
+ boolean submittedViaLink = false;
+ String text;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public HomePage()
+ {
+ super();
+ Form form = new Form("form")
+ {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ protected void onSubmit()
+ {
+ submitted = true;
+ }
+ };
+ form.add(new TextField("text", new PropertyModel(HomePage.this, "text")));
+ form.add(new SubmitLink("link")
+ {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public void onSubmit()
+ {
+ submittedViaLink = true;
+ }
+
+ });
+
+ add(form);
+ }
+
+ public boolean isSubmitted()
+ {
+ return submitted;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+ public boolean isSubmittedViaLink()
+ {
+ return submittedViaLink;
+ }
+}
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/HomePage.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java?rev=572984&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java Wed Sep 5 09:22:38 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.markup.html.form.submitlink;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.protocol.http.MockHttpServletResponse;
+import org.apache.wicket.util.tester.FormTester;
+
+public class TestHomePage extends WicketTestCase
+{
+ public void bugTestSubmitLinkByClickingLink()
+ {
+ tester.startPage(HomePage.class);
+ tester.assertRenderedPage(HomePage.class);
+ HomePage home = (HomePage)tester.getLastRenderedPage();
+ System.out.println(((MockHttpServletResponse)tester.getWicketResponse()
+ .getHttpServletResponse()).getDocument());
+ tester.setParameterForNextRequest("form:text", "Hello");
+ tester.getParametersForNextRequest().put("link", "");
+ tester.getParametersForNextRequest().put("link.x", "");
+ // FIXME clickLink should submit the form
+ tester.clickLink("form:link");
+ assertEquals("Hello", home.getText());
+ assertTrue("Form.onSubmit() has not been called!", home.isSubmitted());
+ assertTrue("SubmitLink.onSubmit() has not been called!", home.isSubmittedViaLink());
+ }
+
+ public void testSubmitLinkBySubmittingForm()
+ {
+ tester.startPage(HomePage.class);
+ tester.assertRenderedPage(HomePage.class);
+ HomePage home = (HomePage)tester.getLastRenderedPage();
+ tester.setParameterForNextRequest("form:text", "Hello");
+ // Pretend we clicked on "link"
+ tester.getParametersForNextRequest().put("link", "");
+ tester.getParametersForNextRequest().put("link.x", "");
+ tester.submitForm("form");
+ assertEquals("Hello", home.getText());
+ assertTrue("Form.onSubmit() has not been called!", home.isSubmitted());
+ assertTrue("SubmitLink.onSubmit() has not been called!", home.isSubmittedViaLink());
+ }
+
+ public void bugTestSubmitLinkByUsingFormTester()
+ {
+ tester.startPage(HomePage.class);
+ tester.assertRenderedPage(HomePage.class);
+ HomePage home = (HomePage)tester.getLastRenderedPage();
+ FormTester formTester = tester.newFormTester("form");
+ formTester.setValue("text", "Hello");
+ // FIXME submit(String) should allow for SubmitLink
+ formTester.submit("link");
+ assertEquals("Hello", home.getText());
+ assertTrue("Form.onSubmit() has not been called!", home.isSubmitted());
+ assertTrue("SubmitLink.onSubmit() has not been called!", home.isSubmittedViaLink());
+ }
+
+}
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/form/submitlink/TestHomePage.java
------------------------------------------------------------------------------
svn:keywords = Id