You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jr...@apache.org on 2010/09/02 23:55:34 UTC
svn commit: r992127 -
/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/
Author: jrthomerson
Date: Thu Sep 2 21:55:34 2010
New Revision: 992127
URL: http://svn.apache.org/viewvc?rev=992127&view=rev
Log:
tests for WICKET-2974
these tests were created by mgrigorov in trunk. I'm just porting them to 1.4.x
Added:
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.html Thu Sep 2 21:55:34 2010
@@ -0,0 +1,11 @@
+<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd" >
+ <head>
+ <title>Wicket Quickstart Archetype Homepage</title>
+ </head>
+ <body>
+ <strong>Wicket Quickstart Archetype Homepage</strong>
+
+ <div wicket:id="pagefbp"></div>
+ <wicket:child />
+ </body>
+</html>
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/BasePage.java Thu Sep 2 21:55:34 2010
@@ -0,0 +1,46 @@
+/*
+ * 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.validation.innerfeedback;
+
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+
+public class BasePage extends WebPage
+{
+
+ public BasePage()
+ {
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ super.onBeforeRender();
+ if (get("pagefbp") == null)
+ {
+ add(new FeedbackPanel("pagefbp", new IFeedbackMessageFilter()
+ {
+ public boolean accept(FeedbackMessage message)
+ {
+ return !message.isRendered();
+ }
+ }));
+ }
+ }
+}
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.html Thu Sep 2 21:55:34 2010
@@ -0,0 +1,8 @@
+<wicket:extend>
+ <form wicket:id="form">
+ <div wicket:id="fieldborder">
+ <input type="text" wicket:id="field"></input>
+ </div>
+ <input type="submit" />
+ </form>
+</wicket:extend>
\ No newline at end of file
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/HomePage.java Thu Sep 2 21:55:34 2010
@@ -0,0 +1,64 @@
+/*
+ * 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.validation.innerfeedback;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.Model;
+
+/**
+ * Homepage
+ */
+public class HomePage extends BasePage
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor that is invoked when page is invoked without a session.
+ *
+ * @param parameters
+ * Page parameters
+ */
+ @SuppressWarnings("serial")
+ public HomePage(final PageParameters parameters)
+ {
+ Form<Void> form = new Form<Void>("form")
+ {
+ @Override
+ protected void onSubmit()
+ {
+ super.onSubmit();
+ info("form submitted");
+ }
+ };
+ LocalizedFeedbackBorder brdr = new LocalizedFeedbackBorder("fieldborder");
+ TextField<String> field = new TextField<String>("field", new Model<String>(""));
+ field.info("info on field");
+ brdr.add(field.setRequired(true));
+ form.add(brdr);
+ add(form);
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ info("page onbeforerender");
+ super.onBeforeRender();
+ }
+}
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/InnerFeedbackTest.java Thu Sep 2 21:55:34 2010
@@ -0,0 +1,84 @@
+/*
+ * 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.validation.innerfeedback;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Test for Wicket-2974
+ */
+public class InnerFeedbackTest extends TestCase
+{
+
+ private WicketTester tester;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ tester = new WicketTester(new WebApplication()
+ {
+ @Override
+ protected void init()
+ {
+ super.init();
+
+ // we don't care about FormComponentFeedbackBorder's 'errorindicator'
+ getDebugSettings().setComponentUseCheck(false);
+ }
+
+ /**
+ * @see org.apache.wicket.Application#getHomePage()
+ */
+ @Override
+ public Class<HomePage> getHomePage()
+ {
+ return HomePage.class;
+ }
+ });
+ }
+
+ public void testInnerFeedback() throws Exception
+ {
+ tester.startPage(HomePage.class);
+
+ // page's feedback
+ tester.assertInfoMessages(new String[] { "info on field", "page onbeforerender" });
+
+ FormTester formTester = tester.newFormTester("form");
+ formTester.submit();
+
+ // feedback message for LocalizedFeedbackBorder
+ // without the fix the same error message was reported for the page's feedback panel too
+ tester.assertErrorMessages(new String[] { "Field 'field' is required." });
+
+ // page's feedback
+ tester.assertInfoMessages(new String[] { "page onbeforerender" });
+
+ formTester = tester.newFormTester("form");
+ formTester.setValue("fieldborder:field", "some text");
+ formTester.submit();
+
+ tester.assertErrorMessages(new String[0]);
+
+ // page's feedback
+ tester.assertInfoMessages(new String[] { "form submitted", "page onbeforerender" });
+ }
+}
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.html Thu Sep 2 21:55:34 2010
@@ -0,0 +1,6 @@
+<wicket:border>
+ <div wicket:id="border">
+ <div wicket:id="feedback"></div>
+ <wicket:body />
+ </div>
+</wicket:border>
\ No newline at end of file
Added: wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java?rev=992127&view=auto
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java (added)
+++ wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/markup/html/form/validation/innerfeedback/LocalizedFeedbackBorder.java Thu Sep 2 21:55:34 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.validation.innerfeedback;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Session;
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+
+@SuppressWarnings("serial")
+class LocalizedFeedbackBorder extends FormComponentFeedbackBorder
+{
+
+ private final FeedbackPanel feedback;
+
+ public LocalizedFeedbackBorder(String id)
+ {
+ super(id);
+ WebMarkupContainer brdr = new WebMarkupContainer("border");
+ brdr.add(feedback = new FeedbackPanel("feedback", getMessagesFilter()));
+ brdr.add(getBodyContainer());
+ brdr.add(new AttributeModifier("style", true, new AbstractReadOnlyModel<String>()
+ {
+ @Override
+ public String getObject()
+ {
+ boolean error = Session.get().getFeedbackMessages().hasMessage(
+ new IFeedbackMessageFilter()
+ {
+ public boolean accept(FeedbackMessage message)
+ {
+ return feedback.getFilter().accept(message) && message.isError();
+ }
+ });
+ return "border: 1px solid " + (error ? "red" : "green");
+ }
+ }));
+ add(brdr);
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ super.onBeforeRender();
+ }
+
+}