1 61 62 package org.apache.commons.dbutils; 63 64 import java.sql.ResultSet ; 65 import java.sql.ResultSetMetaData ; 66 import java.util.Date ; 67 68 import junit.framework.Test; 69 import junit.framework.TestCase; 70 import junit.framework.TestSuite; 71 72 import org.apache.commons.dbutils.handlers.ArrayHandlerTest; 73 import org.apache.commons.dbutils.handlers.ArrayListHandlerTest; 74 import org.apache.commons.dbutils.handlers.BeanHandlerTest; 75 import org.apache.commons.dbutils.handlers.BeanListHandlerTest; 76 import org.apache.commons.dbutils.handlers.MapHandlerTest; 77 import org.apache.commons.dbutils.handlers.MapListHandlerTest; 78 import org.apache.commons.dbutils.handlers.ScalarHandlerTest; 79 import org.apache.commons.dbutils.wrappers.SqlNullCheckedResultSetTest; 80 import org.apache.commons.dbutils.wrappers.StringTrimmedResultSetTest; 81 82 88 public class BaseTestCase extends TestCase { 89 90 private static final String [] columnNames = 91 new String [] { 92 "one", 93 "two", 94 "three", 95 "notInBean", 96 "intTest", 97 "integerTest", 98 "nullObjectTest", 99 "nullPrimitiveTest", 100 "notDate" }; 101 102 105 protected static final int COLS = columnNames.length; 106 107 protected static final ResultSetMetaData metaData = 108 MockResultSetMetaData.create(columnNames); 109 110 private static final Object [] row1 = 111 new Object [] { 112 "1", 113 "2", 114 "3", 115 " notInBean ", 116 new Integer (1), 117 new Integer (2), 118 null, 119 null, 120 new Date ()}; 121 122 private static final Object [] row2 = 123 new Object [] { 124 "4", 125 "5", 126 "6", 127 " notInBean ", 128 new Integer (3), 129 new Integer (4), 130 null, 131 null, 132 new Date ()}; 133 134 private static final Object [][] rows = new Object [][] { row1, row2 }; 135 136 139 protected static final int ROWS = rows.length; 140 141 144 protected ResultSet rs = null; 145 146 149 protected ResultSet emptyResultSet = null; 150 151 154 public BaseTestCase(String name) { 155 super(name); 156 } 157 158 163 protected void setUp() throws Exception { 164 super.setUp(); 165 166 rs = this.createMockResultSet(); 167 emptyResultSet = MockResultSet.create(metaData, null); 168 } 169 170 173 protected ResultSet createMockResultSet() { 174 return MockResultSet.create(metaData, rows); 175 } 176 177 180 public static Test suite() { 181 TestSuite suite = new TestSuite("All DbUtils Tests"); 182 183 suite.addTestSuite(BasicRowProcessorTest.class); 184 suite.addTestSuite(ProxyFactoryTest.class); 185 suite.addTestSuite(ResultSetIteratorTest.class); 186 suite.addTestSuite(QueryLoaderTest.class); 187 188 suite.addTestSuite(ArrayHandlerTest.class); 190 suite.addTestSuite(ArrayListHandlerTest.class); 191 suite.addTestSuite(BeanHandlerTest.class); 192 suite.addTestSuite(BeanListHandlerTest.class); 193 suite.addTestSuite(MapHandlerTest.class); 194 suite.addTestSuite(MapListHandlerTest.class); 195 suite.addTestSuite(ScalarHandlerTest.class); 196 197 suite.addTestSuite(StringTrimmedResultSetTest.class); 198 suite.addTestSuite(SqlNullCheckedResultSetTest.class); 199 200 return suite; 201 } 202 203 } 204 | Popular Tags |