KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > util > BeanUtilsTest


1 /**
2  * Jun 27, 2005
3  *
4  * Copyright 2004 - 2005 uitags
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 package net.sf.uitags.util;
19
20 import javax.servlet.jsp.JspException JavaDoc;
21
22 import net.sf.uitags.util.BeanUtils;
23
24
25 import junit.framework.TestCase;
26
27 /**
28  * Tests {@link net.sf.uitags.util.BeanUtils}.
29  *
30  * @author jonni
31  * @version $Id$
32  */

33 public final class BeanUtilsTest extends TestCase {
34   /**
35    * The JavaBean under test. We can use any random type, String is chosen
36    * because it's straightforward to use.
37    */

38   private String JavaDoc beanUnderTest;
39   /**
40    * Name of a property that must not exist in the bean under test.
41    */

42   private String JavaDoc dummyPropertyName;
43
44   /**
45    * Main method for the tests.
46    *
47    * @param args main arguments
48    */

49   public static void main(String JavaDoc[] args) {
50     junit.textui.TestRunner.run(BeanUtilsTest.class);
51   }
52
53   /** {@inheritDoc} */
54   protected void setUp() throws Exception JavaDoc {
55     super.setUp();
56     this.beanUnderTest = "dummyBean";
57     this.dummyPropertyName = "dummyPropertyName";
58   }
59
60   /** {@inheritDoc} */
61   protected void tearDown() throws Exception JavaDoc {
62     super.tearDown();
63     this.beanUnderTest = null;
64     this.dummyPropertyName = null;
65   }
66
67   /**
68    * Ensures that {@link BeanUtils#getSimpleProperty(Object, String)}
69    * throws <code>JspException</code> when an introspection error occurs.
70    */

71   public void testGetSimpleProperty() {
72     try {
73       BeanUtils.getSimpleProperty(this.beanUnderTest, this.dummyPropertyName);
74     }
75     catch (JspException JavaDoc e) {
76       // Test passes if we end up here
77
}
78   }
79
80   /**
81    * Tests {@link BeanUtils#getProperty(Object, String)} to make sure
82    * it throws <code>JspException</code> when an introspection error occurs.
83    */

84   public void testGetProperty() {
85     try {
86       BeanUtils.getProperty(this.beanUnderTest, this.dummyPropertyName);
87     }
88     catch (JspException JavaDoc e) {
89       // Test passes if we end up here
90
}
91   }
92 }
93
Popular Tags