01: package test.org.mandarax.jdbc;
02:
03: /*
04: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20:
21: import java.sql.*;
22: import junit.framework.TestCase;
23:
24: /**
25: * Test case for result set meta data based on the memory kb from
26: * the test.org.mandarax.util.resultsetfilters package.
27: * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
28: * @version 3.3.2 <29 December 2004>
29: * @since 3.0
30: */
31:
32: public abstract class ResultSetMetaDataTestCase extends TestCase
33: implements Constants {
34: private String url = null;
35: private String sql = null;
36:
37: /**
38: * Constructor.
39: * @param name the name of this test case
40: * @param sql the sql command
41: */
42: public ResultSetMetaDataTestCase(String sql) {
43: super ("test");
44: url = "jdbc:mandarax:ref:"
45: + test.org.mandarax.jdbc.TestKnowledgeBaseRef.class
46: .getName();
47: this .sql = sql;
48: }
49:
50: /**
51: * Set up the test case.
52: */
53: public void setUp() throws Exception {
54: super .setUp();
55: Class.forName("org.mandarax.jdbc.DriverImpl");
56: }
57:
58: /**
59: * Run the test case.
60: */
61: public void test() throws Exception {
62:
63: Connection connection = java.sql.DriverManager
64: .getConnection(url);
65: Statement stmnt = connection.createStatement();
66: java.sql.ResultSet rs = stmnt.executeQuery(sql);
67: ResultSetMetaData metaData = rs.getMetaData();
68: assertTrue(check(metaData));
69: }
70:
71: /**
72: * Check the meta data.
73: * @param metaData the result set meta data
74: */
75: protected abstract boolean check(ResultSetMetaData metaData)
76: throws Exception;
77:
78: /**
79: * Convert this object to a string.
80: * @return the string representation of this object
81: */
82: public String toString() {
83: return "Testing result set meta data for SQL statement: " + sql;
84: }
85: }
|