1   package org.apache.maven.struts;
2   
3   /* ====================================================================
4    *   Copyright 2001-2004 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   * ====================================================================
18   */
19  
20  import junit.framework.TestCase;
21  
22  /**
23   * Unit tests for {@link FormBean}
24   * @author dion
25   * @version $Id: FormBeanTest.java 170200 2005-05-15 06:24:19Z brett $
26   */
27  public class FormBeanTest extends TestCase
28  {
29      /** the instance being tested */
30      private FormBean instance;
31      
32      /** Creates a new instance of FormBeanTest 
33       * @param testName the name of the test
34       */
35      public FormBeanTest(String testName)
36      {
37          super(testName);
38      }
39      
40      /**
41       * Initialize per test data
42       * @throws Exception when there is an unexpected problem
43       */
44      public void setUp() throws Exception
45      {
46          instance = new FormBean();
47      }
48      
49      /** test the constructor sets all properties to null
50       * @throws Exception when any error occurs
51       */
52      public void testConstructor() throws Exception
53      {
54          assertNotNull("Instance wasn't created", instance);
55          assertNull("ClassName property isn't null", instance.getClassName());
56          assertNull("Name property isn't null", instance.getName());
57          assertNull("Type property isn't null", instance.getType());
58      }
59      
60      /** test the className property is working
61       * @throws Exception when any error occurs
62       */
63      public void testClassName() throws Exception
64      {
65          assertNotNull("Instance wasn't created", instance);
66          assertNull("ClassName property isn't null", instance.getClassName());
67          String className = "dummyClassName";
68          instance.setClassName(className);
69          assertEquals("ClassName property setter or getter failed", className,
70              instance.getClassName());
71      }
72      
73      /** test the name property is working
74       * @throws Exception when any error occurs
75       */
76      public void testName() throws Exception
77      {
78          assertNotNull("Instance wasn't created", instance);
79          assertNull("Name property isn't null", instance.getName());
80          String name = "dummyName";
81          instance.setName(name);
82          assertEquals("Name property setter or getter failed", name,
83              instance.getName());
84      }
85      
86      /** test the type property is working
87       * @throws Exception when any error occurs
88       */
89      public void testType() throws Exception
90      {
91          assertNotNull("Instance wasn't created", instance);
92          assertNull("Type property isn't null", instance.getType());
93          String type = "dummyType";
94          instance.setType(type);
95          assertEquals("Type property setter or getter failed", type,
96              instance.getType());
97      }
98  }