Source Code Cross Referenced for BaseTestCase.java in  » Open-Source-Library-Database » Database-Utilities » org » apache » commons » dbutils » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. JDK Core
2. JDK Modules
3. JDK Modules com.sun
4. JDK Modules com.sun.java
5. JDK Modules Platform
6. JDK Modules sun
7. Open Source Build
8. Open Source Graphic Library
9. Open Source IDE Eclipse
10. Open Source J2EE
11. Open Source JDBC Driver
12. Open Source Library
13. Open Source Library Database
14. Open Source Net
15. Open Source Script
16. Science
17. Security
18. Sevlet Container
19. SUN GlassFish
20. Swing Library
21. Web Services apache cxf 2.0.1
22. Web Services AXIS2
23. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java Source Code / Java Documentation » Open Source Library Database » Database Utilities » org.apache.commons.dbutils 
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.dbutils;
018:
019:        import java.math.BigInteger;
020:        import java.sql.ResultSet;
021:        import java.sql.ResultSetMetaData;
022:        import java.util.Date;
023:
024:        import junit.framework.Test;
025:        import junit.framework.TestCase;
026:        import junit.framework.TestSuite;
027:
028:        import org.apache.commons.dbutils.handlers.ArrayHandlerTest;
029:        import org.apache.commons.dbutils.handlers.ArrayListHandlerTest;
030:        import org.apache.commons.dbutils.handlers.BeanHandlerTest;
031:        import org.apache.commons.dbutils.handlers.BeanListHandlerTest;
032:        import org.apache.commons.dbutils.handlers.ColumnListHandlerTest;
033:        import org.apache.commons.dbutils.handlers.KeyedHandlerTest;
034:        import org.apache.commons.dbutils.handlers.MapHandlerTest;
035:        import org.apache.commons.dbutils.handlers.MapListHandlerTest;
036:        import org.apache.commons.dbutils.handlers.ScalarHandlerTest;
037:        import org.apache.commons.dbutils.wrappers.SqlNullCheckedResultSetTest;
038:        import org.apache.commons.dbutils.wrappers.StringTrimmedResultSetTest;
039:
040:        /**
041:         * BaseTestCase is the base class for all test cases as well as the "all tests"
042:         * runner.
043:         */
044:        public class BaseTestCase extends TestCase {
045:
046:            private static final String[] columnNames = new String[] { "one",
047:                    "two", "three", "notInBean", "intTest", "integerTest",
048:                    "nullObjectTest", "nullPrimitiveTest", "notDate",
049:                    "columnProcessorDoubleTest" };
050:
051:            /**
052:             * The number of columns in the MockResultSet.
053:             */
054:            protected static final int COLS = columnNames.length;
055:
056:            protected static final ResultSetMetaData metaData = MockResultSetMetaData
057:                    .create(columnNames);
058:
059:            private static final Object[] row1 = new Object[] { "1", "2", "3",
060:                    "  notInBean  ", new Integer(1), new Integer(2), null,
061:                    null, new Date(), BigInteger.valueOf(13) };
062:
063:            private static final Object[] row2 = new Object[] { "4", "5", "6",
064:                    "  notInBean  ", new Integer(3), new Integer(4), null,
065:                    null, new Date(), BigInteger.valueOf(13) };
066:
067:            private static final Object[][] rows = new Object[][] { row1, row2 };
068:
069:            /**
070:             * The number of rows in the MockResultSet.
071:             */
072:            protected static final int ROWS = rows.length;
073:
074:            /**
075:             * The ResultSet all test methods will use.
076:             */
077:            protected ResultSet rs = null;
078:
079:            /**
080:             * A ResultSet with 0 rows.
081:             */
082:            protected ResultSet emptyResultSet = null;
083:
084:            /**
085:             * Constructor for BaseTestCase.
086:             */
087:            public BaseTestCase(String name) {
088:                super (name);
089:            }
090:
091:            /**
092:             * This is called before each test method so ResultSet will be fresh each
093:             * time.
094:             * @see junit.framework.TestCase#setUp()
095:             */
096:            protected void setUp() throws Exception {
097:                super .setUp();
098:
099:                rs = this .createMockResultSet();
100:                emptyResultSet = MockResultSet.create(metaData, null);
101:            }
102:
103:            /**
104:             * Creates a freshly initialized ResultSet.
105:             */
106:            protected ResultSet createMockResultSet() {
107:                return MockResultSet.create(metaData, rows);
108:            }
109:
110:            /**
111:             * Return a TestSuite containing all of our test cases.
112:             */
113:            public static Test suite() {
114:                TestSuite suite = new TestSuite("All DbUtils Tests");
115:
116:                suite.addTestSuite(BasicRowProcessorTest.class);
117:                suite.addTestSuite(BeanProcessorTest.class);
118:                suite.addTestSuite(ProxyFactoryTest.class);
119:                suite.addTestSuite(ResultSetIteratorTest.class);
120:                suite.addTestSuite(QueryLoaderTest.class);
121:
122:                // test handler implementations
123:                suite.addTestSuite(ArrayHandlerTest.class);
124:                suite.addTestSuite(ArrayListHandlerTest.class);
125:                suite.addTestSuite(BeanHandlerTest.class);
126:                suite.addTestSuite(BeanListHandlerTest.class);
127:                suite.addTestSuite(MapHandlerTest.class);
128:                suite.addTestSuite(MapListHandlerTest.class);
129:                suite.addTestSuite(ScalarHandlerTest.class);
130:                suite.addTestSuite(ColumnListHandlerTest.class);
131:                suite.addTestSuite(KeyedHandlerTest.class);
132:
133:                suite.addTestSuite(StringTrimmedResultSetTest.class);
134:                suite.addTestSuite(SqlNullCheckedResultSetTest.class);
135:
136:                return suite;
137:            }
138:
139:        }
w_w__w___.j_a_v_a___2s.__c___o_m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.