jxUtil 0.6

org.sourceforge.jxutil.dbtest
Class DatabaseTest

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--org.sourceforge.jxutil.dbtest.DatabaseTest
All Implemented Interfaces:
Test
Direct Known Subclasses:
BatchUpdateTest, DBMetaDataTest, EscapeTest, ExceptionTest, ForeignKeyTest, MultipleResultTest, ResultSetMetaDataTest, ResultSetTest, SimpleCallTest, SimpleFunctionTest, TypeTest.DBTypeTest

public class DatabaseTest
extends TestCase

Superclass for all database tests. All public methods beginning with test will be executed. Test methods need not catch and report unexpected exception, they are being dealt with in the runTest method. When extending DatabaseTest keep in mind, that an instance of this class is created for every test method it defines. Every test method call is prepended with a call to setUp and a tearDown afterwards.

Author:
Peter Brant, Keve Müller

Nested Class Summary
static class DatabaseTest.ColumnDef
           
static class DatabaseTest.TableDef
           
 
Field Summary
private static Category cat
           
protected  Connection conn
           
protected  DatabaseMetaData dbMeta
           
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
protected DatabaseTest(String name)
          Run a test.
 
Method Summary
private  void assertEquals(Class type, Object arr, int aidx, ResultSet set, int sidx)
           
protected  void checkDataCols(Object[] data, ResultSet set)
          Check the data in the givent ResultSet against the reference data in the array organized by columns.
protected  void checkDataRows(Object data, ResultSet set)
          Check the data in the givent ResultSet against the reference data in the array organized by row.
protected  void createTable(DatabaseTest.TableDef table)
           
protected  void dropTable(DatabaseTest.TableDef table)
           
protected  void dropTable(String tableName)
           
protected  String getColumnString(DatabaseTest.ColumnDef cdef)
           
protected  SQLUtil.TypeInfoRow getType(int jdbcType)
          The test is framed by logging info.
protected  boolean isDBMS(String dbms)
           
protected  boolean isDriver(String driver)
           
protected  void loadData(DatabaseTest.TableDef table, Object data)
           
 void setConnection(Connection conn)
          Set the connection and database metadata members.
protected  void setUp()
          The connection is set to autocommit mode.
protected  void setUpDB()
           
protected  void tearDown()
          The current transaction (if any) is aborted and the connection set back to autocommit mode.
protected  void tearDownDB()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cat

private static final Category cat

conn

protected Connection conn

dbMeta

protected DatabaseMetaData dbMeta
Constructor Detail

DatabaseTest

protected DatabaseTest(String name)
Run a test. This will be invoked as part of the test run.

Parameters:
name - the method name to invoke
Method Detail

assertEquals

private void assertEquals(Class type,
                          Object arr,
                          int aidx,
                          ResultSet set,
                          int sidx)
                   throws SQLException
SQLException

checkDataCols

protected void checkDataCols(Object[] data,
                             ResultSet set)
                      throws SQLException
Check the data in the givent ResultSet against the reference data in the array organized by columns.

SQLException

checkDataRows

protected void checkDataRows(Object data,
                             ResultSet set)
                      throws SQLException
Check the data in the givent ResultSet against the reference data in the array organized by row.

SQLException

createTable

protected void createTable(DatabaseTest.TableDef table)
                    throws SQLException
SQLException

dropTable

protected void dropTable(DatabaseTest.TableDef table)
                  throws SQLException
SQLException

dropTable

protected final void dropTable(String tableName)
                        throws SQLException
SQLException

getColumnString

protected final String getColumnString(DatabaseTest.ColumnDef cdef)
                                throws SQLException
SQLException

getType

protected final SQLUtil.TypeInfoRow getType(int jdbcType)
                                     throws SQLException
The test is framed by logging info. Unexpected exceptions are also logged.

SQLException

isDBMS

protected final boolean isDBMS(String dbms)
                        throws SQLException
SQLException

isDriver

protected final boolean isDriver(String driver)
                          throws SQLException
SQLException

loadData

protected void loadData(DatabaseTest.TableDef table,
                        Object data)
                 throws SQLException
SQLException

setConnection

public void setConnection(Connection conn)
Set the connection and database metadata members.


setUp

protected void setUp()
              throws Exception
The connection is set to autocommit mode.

Overrides:
setUp in class TestCase
Exception

setUpDB

protected void setUpDB()
                throws SQLException
SQLException

tearDown

protected void tearDown()
                 throws Exception
The current transaction (if any) is aborted and the connection set back to autocommit mode.

Overrides:
tearDown in class TestCase
Exception

tearDownDB

protected void tearDownDB()
                   throws SQLException
SQLException

jxUtil 0.6

Copyright © 2001,2002 Keve Müller, et al.; see LICENSE file for details.