Author: jdonnerstag
Date: Sun Mar 22 08:14:39 2009
New Revision: 757143

URL: http://svn.apache.org/viewvc?rev=757143&view=rev
Log:
A test case for CompoundPropertyModel

Added:
    wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.html
    wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.xml
    wicket/trunk/wicket/src/test/java/org/apache/wicket/model/TestHomePage.java

Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.html?rev=757143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.html 
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.html Sun 
Mar 22 08:14:39 2009
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";
+      xmlns:wicket="http://wicket.apache.org/";>
+<body>
+    <div wicket:id="feedback">message will be here</div>
+
+    <form wicket:id="bookingForm" action="#">
+      <div wicket:id="nameBorder">
+         <input wicket:id="partyDetails.name" type="text" id="name"/>
+      </div>
+      <input type="submit" value="Submit"/>
+    </form>
+</body>
+</html>
+

Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.java?rev=757143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.java 
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.java Sun 
Mar 22 08:14:39 2009
@@ -0,0 +1,112 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import 
org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.validation.validator.StringValidator;
+
+/**
+ * Homepage: A simple test for CompoundPropertyModel and id's like "A.B"
+ */
+public class HomePage extends WebPage
+{
+       private static final long serialVersionUID = 1L;
+
+       private final Booking booking = new Booking();
+
+       /**
+        * Constructor that is invoked when page is invoked without a session.
+        * 
+        * @param parameters
+        *            Page parameters
+        */
+       public HomePage(final PageParameters parameters)
+       {
+               add(new FeedbackPanel("feedback"));
+               add(new BookingForm("bookingForm"));
+       }
+
+       private class BookingForm extends Form
+       {
+               private static final long serialVersionUID = 1L;
+
+               String name;
+
+               public BookingForm(String s)
+               {
+                       super(s);
+                       setDefaultModel(new CompoundPropertyModel(booking));
+
+                       TextField<String> name = new 
TextField<String>("partyDetails.name");
+                       name.setRequired(Boolean.TRUE);
+                       name.add(new StringValidator.LengthBetweenValidator(1, 
30));
+
+                       FormComponentFeedbackBorder nameBorder = new 
FormComponentFeedbackBorder("nameBorder");
+                       nameBorder.add(name);
+                       add(nameBorder);
+               }
+       }
+
+       private class Booking implements Serializable
+       {
+               private static final long serialVersionUID = 1L;
+
+               PartyDetails partyDetails = new PartyDetails();
+
+               private Booking()
+               {
+               }
+
+               public PartyDetails getPartyDetails()
+               {
+                       return partyDetails;
+               }
+
+               public void setPartyDetails(PartyDetails partyDetails)
+               {
+                       this.partyDetails = partyDetails;
+               }
+       }
+
+       private class PartyDetails implements Serializable
+       {
+               private static final long serialVersionUID = 1L;
+
+               private String name;
+
+               private PartyDetails()
+               {
+               }
+
+               public String getName()
+               {
+                       return name;
+               }
+
+               public void setName(String name)
+               {
+                       this.name = name;
+               }
+       }
+}

Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.xml
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.xml?rev=757143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.xml 
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/model/HomePage.xml Sun 
Mar 22 08:14:39 2009
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd";>
+
+<properties>
+    <entry key="bookingForm.nameBorder.partyDetails.name.Required">Name is 
required</entry>
+</properties>
\ No newline at end of file

Added: 
wicket/trunk/wicket/src/test/java/org/apache/wicket/model/TestHomePage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/model/TestHomePage.java?rev=757143&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/model/TestHomePage.java 
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/model/TestHomePage.java 
Sun Mar 22 08:14:39 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.model;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.util.tester.FormTester;
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Simple test for CompoundPropertyModel and id's like "A.B"
+ */
+public class TestHomePage extends TestCase
+{
+       private WicketTester tester;
+
+       @Override
+       public void setUp()
+       {
+               tester = new WicketTester();
+       }
+
+       /**
+        * 
+        */
+       public void testRenderMyPage()
+       {
+               // start and render the test page
+               tester.startPage(HomePage.class);
+
+               // assert rendered page class
+               tester.assertRenderedPage(HomePage.class);
+
+               FormTester formTester = tester.newFormTester("bookingForm");
+               formTester.submit();
+
+               tester.assertErrorMessages(new String[] { "Name is required" });
+       }
+}


Reply via email to