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 Action}
24   * @author dion
25   * @version $Id: ActionTest.java 170200 2005-05-15 06:24:19Z brett $
26   */
27  public class ActionTest extends TestCase
28  {
29      /** the instance being tested */
30      private Action instance;
31      
32      /** Creates a new instance of ActionTest 
33       * @param testName the name of the test
34       */
35      public ActionTest(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 Action();
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("Scope property isn't null", instance.getScope());
58          assertNull("Type property isn't null", instance.getType());
59          assertNull("Unknown property isn't null", instance.getUnknown());
60          assertNull("Validate property isn't null", instance.getValidate());
61      }
62      
63      /** test the className property is working
64       * @throws Exception when any error occurs
65       */
66      public void testClassName() throws Exception
67      {
68          testConstructor();
69          String className = "dummyClassName";
70          instance.setClassName(className);
71          assertEquals("ClassName property setter or getter failed", className,
72              instance.getClassName());
73      }
74      
75      /** test the name property is working
76       * @throws Exception when any error occurs
77       */
78      public void testName() throws Exception
79      {
80          testConstructor();
81          String name = "dummyName";
82          instance.setName(name);
83          assertEquals("Name property setter or getter failed", name,
84              instance.getName());
85      }
86      
87      /** test the name property is working
88       * @throws Exception when any error occurs
89       */
90      public void testPath() throws Exception
91      {
92          testConstructor();
93          String path = "/dummy";
94          instance.setPath(path);
95          assertEquals("Path property setter or getter failed", path,
96              instance.getPath());
97      }
98      
99      /** test the scope property is working
100      * @throws Exception when any error occurs
101      */
102     public void testScope() throws Exception
103     {
104         testConstructor();
105         String scope = "dummyScope";
106         instance.setScope(scope);
107         assertEquals("Scope property setter or getter failed", scope,
108             instance.getScope());
109     }
110     
111     /** test the type property is working
112      * @throws Exception when any error occurs
113      */
114     public void testType() throws Exception
115     {
116         testConstructor();
117         String type = "dummyType";
118         instance.setType(type);
119         assertEquals("Type property setter or getter failed", type,
120             instance.getType());
121     }
122     
123     /** test the unknown property is working
124      * @throws Exception when any error occurs
125      */
126     public void testUnknown() throws Exception
127     {
128         testConstructor();
129         String unknown = "true";
130         instance.setUnknown(unknown);
131         assertEquals("Unknown property setter or getter failed", unknown,
132             instance.getUnknown());
133     }
134     
135     /** test the unknown property is working
136      * @throws Exception when any error occurs
137      */
138     public void testValidate() throws Exception
139     {
140         testConstructor();
141         String validate = "true";
142         instance.setValidate(validate);
143         assertEquals("Validate property setter or getter failed", validate,
144             instance.getValidate());
145     }
146 
147 }