1   /*
2    * Copyright 2002-2006 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.springframework.richclient.form;
17  
18  import org.springframework.binding.form.FormModel;
19  import org.springframework.binding.form.HierarchicalFormModel;
20  import org.springframework.binding.form.ValidatingFormModel;
21  import org.springframework.binding.form.support.DefaultFormModel;
22  import org.springframework.binding.support.TestBean;
23  import org.springframework.binding.value.ValueModel;
24  import org.springframework.richclient.test.SpringRichTestCase;
25  
26  import javax.swing.*;
27  
28  /**
29   * @author Mathias Broekelmann
30   * 
31   */
32  public abstract class AbstractFormTests extends SpringRichTestCase {
33  
34      /**
35       * Test method for
36       * {@link org.springframework.richclient.form.AbstractForm#addChildForm(org.springframework.richclient.form.Form)}.
37       */
38      public void testAddChildForm() {
39          TestBean testBean = new TestBean();
40          testBean.setNestedProperty(new TestBean());
41          HierarchicalFormModel model = new DefaultFormModel(testBean);
42          ValidatingFormModel childModel = FormModelHelper.createChildPageFormModel(model, "test", "nestedProperty");
43          AbstractForm form = new TestAbstractForm(model);
44          form.addChildForm(new TestAbstractForm(childModel));
45      }
46  
47      private static class TestAbstractForm extends AbstractForm {
48  
49          public TestAbstractForm() {
50              super();
51          }
52  
53          public TestAbstractForm(FormModel formModel, String formId) {
54              super(formModel, formId);
55          }
56  
57          public TestAbstractForm(FormModel pageFormModel) {
58              super(pageFormModel);
59          }
60  
61          public TestAbstractForm(HierarchicalFormModel parentFormModel, String formId, ValueModel childFormObjectHolder) {
62              super(parentFormModel, formId, childFormObjectHolder);
63          }
64  
65          public TestAbstractForm(String formId) {
66              super(formId);
67          }
68  
69          public TestAbstractForm(Object formObject) {
70              super(formObject);
71          }
72  
73          public TestAbstractForm(HierarchicalFormModel parentFormModel, String formId, String childFormObjectPropertyPath) {
74              super(parentFormModel, formId, childFormObjectPropertyPath);
75          }
76  
77          protected JComponent createFormControl() {
78              return null;
79          }
80  
81      }
82  }