KickJava   Java API By Example, From Geeks To Geeks.

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


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 junit.framework.TestCase;
23
24 /**
25  * Tests {@link net.sf.uitags.tagutil.PropertyUtils}.
26  *
27  * @author jonni
28  * @version $Id$
29  */

30 public final class PropertyUtilsTest extends TestCase {
31   /**
32    * The JavaBean under test. We can use any random type, String is chosen
33    * because it's straightforward to use.
34    */

35   private String JavaDoc beanUnderTest;
36   /**
37    * Name of a property that must not exist in the bean under test.
38    */

39   private String JavaDoc dummyPropertyName;
40
41   /**
42    * Main method for the tests.
43    *
44    * @param args main arguments
45    */

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

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

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