001 /* 002 * Copyright 2002-2006 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 * use this file except in compliance with the License. You may obtain a copy of 006 * the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations under 014 * the License. 015 */ 016 package org.springframework.richclient.form; 017 018 import org.springframework.binding.form.FormModel; 019 import org.springframework.binding.form.HierarchicalFormModel; 020 import org.springframework.binding.form.ValidatingFormModel; 021 import org.springframework.binding.form.support.DefaultFormModel; 022 import org.springframework.binding.support.TestBean; 023 import org.springframework.binding.value.ValueModel; 024 import org.springframework.richclient.test.SpringRichTestCase; 025 026 import javax.swing.*; 027 028 /** 029 * @author Mathias Broekelmann 030 * 031 */ 032 public abstract class AbstractFormTests extends SpringRichTestCase { 033 034 /** 035 * Test method for 036 * {@link org.springframework.richclient.form.AbstractForm#addChildForm(org.springframework.richclient.form.Form)}. 037 */ 038 public void testAddChildForm() { 039 TestBean testBean = new TestBean(); 040 testBean.setNestedProperty(new TestBean()); 041 HierarchicalFormModel model = new DefaultFormModel(testBean); 042 ValidatingFormModel childModel = FormModelHelper.createChildPageFormModel(model, "test", "nestedProperty"); 043 AbstractForm form = new TestAbstractForm(model); 044 form.addChildForm(new TestAbstractForm(childModel)); 045 } 046 047 private static class TestAbstractForm extends AbstractForm { 048 049 public TestAbstractForm() { 050 super(); 051 } 052 053 public TestAbstractForm(FormModel formModel, String formId) { 054 super(formModel, formId); 055 } 056 057 public TestAbstractForm(FormModel pageFormModel) { 058 super(pageFormModel); 059 } 060 061 public TestAbstractForm(HierarchicalFormModel parentFormModel, String formId, ValueModel childFormObjectHolder) { 062 super(parentFormModel, formId, childFormObjectHolder); 063 } 064 065 public TestAbstractForm(String formId) { 066 super(formId); 067 } 068 069 public TestAbstractForm(Object formObject) { 070 super(formObject); 071 } 072 073 public TestAbstractForm(HierarchicalFormModel parentFormModel, String formId, String childFormObjectPropertyPath) { 074 super(parentFormModel, formId, childFormObjectPropertyPath); 075 } 076 077 protected JComponent createFormControl() { 078 return null; 079 } 080 081 } 082 }