You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2008/12/14 15:21:04 UTC
svn commit: r726454 - in
/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form:
DropDownChoiceTest.java DropDownChoiceTestPage.html
DropDownChoiceTestPage.java FormSubmitTest.java
Author: jdonnerstag
Date: Sun Dec 14 06:21:04 2008
New Revision: 726454
URL: http://svn.apache.org/viewvc?rev=726454&view=rev
Log:
wicket-1979 test case
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.html
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.java
Modified:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTest.java?rev=726454&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTest.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTest.java Sun Dec 14 06:21:04 2008
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.util.tester.FormTester;
+
+/**
+ * @author Juergen Donnerstag
+ */
+public class DropDownChoiceTest extends WicketTestCase
+{
+ /**
+ * Construct.
+ *
+ * @param name
+ */
+ public DropDownChoiceTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test Case for jira issue 1979
+ */
+ public void test_1979()
+ {
+ tester.startPage(DropDownChoiceTestPage.class);
+
+ // FIXME should not be needed
+ // tester.createRequestCycle();
+
+ FormTester formTester = tester.newFormTester("form");
+ formTester.submit();
+ }
+}
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.html?rev=726454&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.html (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.html Sun Dec 14 06:21:04 2008
@@ -0,0 +1,8 @@
+<html>
+<body>
+ <form wicket:id="form">
+ <select wicket:id="dropdown"></select>
+ <input wicket:id="text" id="text" name="text" size="40" type="text" value="test"/>
+ </form>
+</body>
+</html>
\ No newline at end of file
Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.java?rev=726454&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.java (added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/DropDownChoiceTestPage.java Sun Dec 14 06:21:04 2008
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.model.PropertyModel;
+
+/**
+ * @author Juergen Donnerstag
+ */
+public class DropDownChoiceTestPage extends WebPage
+{
+ /** */
+ public class DocumentType
+ {
+ private String name;
+ private boolean hasExpiryDate;
+
+ /**
+ * Construct.
+ *
+ * @param name
+ * @param expiryDate
+ */
+ public DocumentType(String name, boolean expiryDate)
+ {
+ this.name = name;
+ hasExpiryDate = expiryDate;
+ }
+
+ /**
+ * Gets name.
+ *
+ * @return name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Sets name.
+ *
+ * @param name
+ * name
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Gets hasExpiryDate.
+ *
+ * @return hasExpiryDate
+ */
+ public boolean getHasExpiryDate()
+ {
+ return hasExpiryDate;
+ }
+
+ /**
+ * Sets hasExpiryDate.
+ *
+ * @param hasExpiryDate
+ * hasExpiryDate
+ */
+ public void setHasExpiryDate(boolean hasExpiryDate)
+ {
+ this.hasExpiryDate = hasExpiryDate;
+ }
+ }
+
+ /**
+ *
+ */
+ public enum MyEnum {
+ A("a"), B("b"), C("c"), D("d"), E("e");
+
+ private String text;
+
+ MyEnum(String text)
+ {
+ this.text = text;
+ }
+ }
+
+ public DocumentType dtype;
+
+ public String myDate;
+
+ /**
+ * Construct.
+ *
+ * @param name
+ */
+ public DropDownChoiceTestPage()
+ {
+ Form<String> form = new MyForm("form");
+ add(form);
+
+ DocumentType[] docTypes = new DocumentType[3];
+ docTypes[0] = new DocumentType("a", true);
+ docTypes[1] = new DocumentType("b", false);
+ docTypes[2] = new DocumentType("c", true);
+
+ List<DocumentType> docTypes2 = new ArrayList<DocumentType>();
+ docTypes2.add(new DocumentType("a", true));
+ docTypes2.add(new DocumentType("b", false));
+ docTypes2.add(new DocumentType("c", true));
+
+ // List<DocumentType> allDocumentTypes = docTypes2;
+ // List<DocumentType> allDocumentTypes = Arrays.asList(docTypes);
+ List<MyEnum> allDocumentTypes = Arrays.asList(MyEnum.values());
+
+ final DropDownChoice ddc = new DropDownChoice("dropdown", new PropertyModel(this, "dtype"),
+ allDocumentTypes, new ChoiceRenderer("name"));
+
+ TextField expiryDate = new TextField("text", new PropertyModel(this, "myDate"), Date.class)
+ {
+ @Override
+ public boolean isRequired()
+ {
+ // ddc.validate();
+ DocumentType dt = (DocumentType)ddc.getConvertedInput();
+ return dt != null && dt.getHasExpiryDate();
+ }
+ };
+
+ form.add(ddc);
+ form.add(expiryDate);
+ }
+
+ /**
+ *
+ */
+ public class MyForm extends Form<String>
+ {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param id
+ */
+ public MyForm(String id)
+ {
+ super(id);
+ }
+ }
+
+ /**
+ * Gets dtype.
+ *
+ * @return dtype
+ */
+ public DocumentType getDtype()
+ {
+ return dtype;
+ }
+
+ /**
+ * Sets dtype.
+ *
+ * @param dtype
+ * dtype
+ */
+ public void setDtype(DocumentType dtype)
+ {
+ this.dtype = dtype;
+ }
+
+ /**
+ * Gets myDate.
+ *
+ * @return myDate
+ */
+ public String getMyDate()
+ {
+ return myDate;
+ }
+
+ /**
+ * Sets myDate.
+ *
+ * @param myDate
+ * myDate
+ */
+ public void setMyDate(String myDate)
+ {
+ this.myDate = myDate;
+ }
+}
Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java?rev=726454&r1=726453&r2=726454&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java (original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/form/FormSubmitTest.java Sun Dec 14 06:21:04 2008
@@ -22,18 +22,23 @@
import org.apache.wicket.util.tester.FormTester;
/**
- * @see <a href="http://cwiki.apache.org/WICKET/nested-forms.html">"Specification"</a> of nested
- * forms handling
+ * Please see <a href="http://cwiki.apache.org/WICKET/nested-forms.html">"Nested Forms"</a> for more
+ * details on nested forms
+ *
* @author Gerolf Seitz
*/
public class FormSubmitTest extends WicketTestCase
{
-
private Page page;
private NestableForm outerForm;
private NestableForm middleForm;
private NestableForm innerForm;
+ /**
+ *
+ * @see org.apache.wicket.WicketTestCase#setUp()
+ */
+ @Override
protected void setUp() throws Exception
{
super.setUp();
@@ -44,7 +49,6 @@
innerForm = (NestableForm)page.get("outerForm:middleForm:innerForm");
}
-
/**
*
*/
@@ -87,7 +91,6 @@
assertOnErrorCalled(false, false, false);
}
-
/**
*
*/
@@ -217,7 +220,12 @@
assertOnErrorCalled(false, false, false);
}
-
+ /**
+ *
+ * @param isOuterFormEnabled
+ * @param isMiddleFormEnabled
+ * @param isInnerFormEnabled
+ */
private void assertEnabledState(boolean isOuterFormEnabled, boolean isMiddleFormEnabled,
boolean isInnerFormEnabled)
{
@@ -226,7 +234,12 @@
assertEquals(isInnerFormEnabled, innerForm.isEnabled());
}
-
+ /**
+ *
+ * @param isOuterFormOnErrorCalled
+ * @param isMiddleFormOnErrorCalled
+ * @param isInnerFormOnErrorCalled
+ */
private void assertOnErrorCalled(boolean isOuterFormOnErrorCalled,
boolean isMiddleFormOnErrorCalled, boolean isInnerFormOnErrorCalled)
{
@@ -235,7 +248,12 @@
assertEquals(isInnerFormOnErrorCalled, innerForm.onErrorCalled);
}
-
+ /**
+ *
+ * @param isOuterFormOnSubmitCalled
+ * @param isMiddleFormOnSubmitCalled
+ * @param isInnerFormOnSubmitCalled
+ */
private void assertOnSubmitCalled(boolean isOuterFormOnSubmitCalled,
boolean isMiddleFormOnSubmitCalled, boolean isInnerFormOnSubmitCalled)
{
@@ -244,7 +262,6 @@
assertEquals(isInnerFormOnSubmitCalled, innerForm.onSubmitCalled);
}
-
/**
* @param formToBeSubmitted
* absolute path of the form to be submitted
@@ -261,5 +278,4 @@
formTester.submit("submit");
return formTester;
}
-
}