Source Code Cross Referenced for BeanUtils2TestCase.java in  » Library » Apache-commons-beanutils-1.8.0-BETA-src » org » apache » commons » beanutils » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons beanutils 1.8.0 BETA src » org.apache.commons.beanutils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.beanutils;
018:
019:        import junit.framework.Test;
020:        import junit.framework.TestSuite;
021:
022:        /**
023:         * Test Case for the {@link BeanUtilsBean2}.
024:         *
025:         * @version $Revision: 552381 $
026:         */
027:        public class BeanUtils2TestCase extends BeanUtilsTestCase {
028:
029:            // ---------------------------------------------------------- Constructors
030:
031:            /**
032:             * Construct a new instance of this test case.
033:             *
034:             * @param name Name of the test case
035:             */
036:            public BeanUtils2TestCase(String name) {
037:                super (name);
038:            }
039:
040:            // -------------------------------------------------- Overall Test Methods
041:
042:            /**
043:             * Set up instance variables required by this test case.
044:             */
045:            public void setUp() {
046:                ConvertUtils.deregister();
047:                BeanUtilsBean.setInstance(new BeanUtilsBean2());
048:                setUpShared();
049:            }
050:
051:            /**
052:             * Return the tests included in this test suite.
053:             */
054:            public static Test suite() {
055:                return (new TestSuite(BeanUtils2TestCase.class));
056:            }
057:
058:            /**
059:             * Tear down instance variables required by this test case.
060:             */
061:            public void tearDown() {
062:                bean = null;
063:            }
064:
065:            /**
066:             * Test <code>copyProperty()</code> converting to a String.
067:             */
068:            public void testCopyPropertyConvertToString() {
069:                try {
070:                    BeanUtils
071:                            .copyProperty(bean, "stringProperty", testUtilDate);
072:                } catch (Throwable t) {
073:                    fail("Threw " + t);
074:                }
075:                assertEquals("java.util.Date --> String", testStringDate, bean
076:                        .getStringProperty());
077:            }
078:
079:            /**
080:             * Test <code>copyProperty()</code> converting to a String.
081:             */
082:            public void testCopyPropertyConvertToStringArray() {
083:                try {
084:                    bean.setStringArray(null);
085:                    BeanUtils.copyProperty(bean, "stringArray",
086:                            new java.util.Date[] { testUtilDate });
087:                } catch (Throwable t) {
088:                    fail("Threw " + t);
089:                }
090:                assertEquals("java.util.Date[] --> String[] length", 1, bean
091:                        .getStringArray().length);
092:                assertEquals("java.util.Date[] --> String[] value ",
093:                        testStringDate, bean.getStringArray()[0]);
094:            }
095:
096:            /**
097:             * Test <code>copyProperty()</code> converting to a String on indexed property
098:             */
099:            public void testCopyPropertyConvertToStringIndexed() {
100:                try {
101:                    bean.setStringArray(new String[1]);
102:                    BeanUtils
103:                            .copyProperty(bean, "stringArray[0]", testUtilDate);
104:                } catch (Throwable t) {
105:                    fail("Threw " + t);
106:                }
107:                assertEquals("java.util.Date[] --> String[] length", 1, bean
108:                        .getStringArray().length);
109:                assertEquals("java.util.Date[] --> String[] value ",
110:                        testStringDate, bean.getStringArray()[0]);
111:            }
112:
113:            /**
114:             * Test <code>getArrayProperty()</code> converting to a String.
115:             */
116:            public void testGetArrayPropertyDate() {
117:                String[] value = null;
118:                try {
119:                    bean
120:                            .setDateArrayProperty(new java.util.Date[] { testUtilDate });
121:                    value = BeanUtils.getArrayProperty(bean,
122:                            "dateArrayProperty");
123:                } catch (Throwable t) {
124:                    fail("Threw " + t);
125:                }
126:                assertEquals("java.util.Date[] --> String[] length", 1,
127:                        value.length);
128:                assertEquals("java.util.Date[] --> String[] value ",
129:                        testStringDate, value[0]);
130:            }
131:
132:            /**
133:             * Test <code>getArrayProperty()</code> converting to a String.
134:             */
135:            public void testGetIndexedPropertyDate() {
136:                String value = null;
137:                try {
138:                    bean
139:                            .setDateArrayProperty(new java.util.Date[] { testUtilDate });
140:                    value = BeanUtils.getIndexedProperty(bean,
141:                            "dateArrayProperty[0]");
142:                } catch (Throwable t) {
143:                    fail("Threw " + t);
144:                }
145:                assertEquals("java.util.Date[0] --> String", testStringDate,
146:                        value);
147:            }
148:
149:            /**
150:             * Test <code>getSimpleProperty()</code> converting to a String.
151:             */
152:            public void testGetSimplePropertyDate() {
153:                String value = null;
154:                try {
155:                    bean.setDateProperty(testUtilDate);
156:                    value = BeanUtils.getSimpleProperty(bean, "dateProperty");
157:                } catch (Throwable t) {
158:                    fail("Threw " + t);
159:                }
160:                assertEquals("java.util.Date --> String", testStringDate, value);
161:            }
162:
163:            /**
164:             * Test <code>setProperty()</code> converting to a String.
165:             */
166:            public void testSetPropertyConvertToString() {
167:                try {
168:                    BeanUtils.setProperty(bean, "stringProperty", testUtilDate);
169:                } catch (Throwable t) {
170:                    fail("Threw " + t);
171:                }
172:                assertEquals("java.util.Date --> String", testStringDate, bean
173:                        .getStringProperty());
174:            }
175:
176:            /**
177:             * Test <code>setProperty()</code> converting to a String array.
178:             */
179:            public void testSetPropertyConvertToStringArray() {
180:                try {
181:                    bean.setStringArray(null);
182:                    BeanUtils.setProperty(bean, "stringArray",
183:                            new java.util.Date[] { testUtilDate });
184:                } catch (Throwable t) {
185:                    fail("Threw " + t);
186:                }
187:                assertEquals("java.util.Date[] --> String[] length", 1, bean
188:                        .getStringArray().length);
189:                assertEquals("java.util.Date[] --> String[] value ",
190:                        testStringDate, bean.getStringArray()[0]);
191:            }
192:
193:            /**
194:             * Test <code>setProperty()</code> converting to a String on indexed property
195:             */
196:            public void testSetPropertyConvertToStringIndexed() {
197:                try {
198:                    bean.setStringArray(new String[1]);
199:                    BeanUtils.setProperty(bean, "stringArray[0]", testUtilDate);
200:                } catch (Throwable t) {
201:                    fail("Threw " + t);
202:                }
203:                assertEquals("java.util.Date --> String[]", testStringDate,
204:                        bean.getStringArray()[0]);
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.