DbdaTestDriver – records and replays JDBC sessions for DataBase Driven Applications
The DbdaTestDriver is a JDBC proxy driver that wraps the JDBC driver of an application. It operates in two modes:
RECORD - the driver stores the entire data retrieved from the JDBC layer into a file.
REPLAY - the driver reads the data previously recorded and replays it to the application, as if the underlying database was responding the requests.
The driver is very helpful during development and test of applications that depend on huge and/or slow databases (data warehouses, operational datastores, ...), or on databases where the content changes over time. Using the DbdaTestDriver the developer is no longer dependent on the content, the speed, or even the availability of the database.
Application development – replaying data recorded with the DbdaTestDriver during application development is fast, usually faster than requesting data from the database via JDBC. So the develop–test–develop cycle can be run through faster.
Regression testing – running large testsuites against a database driven application is not only time consuming, it also requires the relevant database to be up and running. Additionally, changing database content could cause testcases to fail and require a lengthy analysis to track down the cause of the (non-)failure.
Download and place the DbdaTestDriver.jar in a location where the application can find it.
Provide a properties file with the JDBC connection information of the original database driver, called <younameit>.properties. This could look like follows (Oracle example):
The driver will record to / replay from the file configured unter the property „recordFilename“.
You can choose which backend to use by specifying the optional property:
See the DataBackend source on how to implement your own backend and the three example backends already provided.
Next, configure your application to use the class „conpar.dbda.test.driver.DbdaTestDriver“ as the JDBC driver and the URL
„jdbc:conpar:dbda:record:<younameit>.properties“ to save data in record mode
„jdbc:conpar:dbda:replay:<younameit>.properties“ to provide data in replay mode
A trivial case is shown below. It shows how to manually register the JDBC driver and get a connection for recording the data transferred between the application and the database.
There is also a simple showcase main class in the DbdaTestDriver jar to support when doing the first steps with DbdaTestDriver. Simply call „java -cp <log4j jar, database driver jar, dbdatestdriver jar> conpar.dbda.test.driver.Showcase and let the usage guide help you.
DbdaTestDriver itself depends on the Log4J library
Versions up to R1_3 require a JVM version 1.4 or greater. Later versions require a JVM version 6 or greater.
It has been developed and tested extensively against Oracle 9i / 10g / 11g, using the DriverManager directly or using a ConnectionPool provided by Apache DBCP (http://commons.apache.org/dbcp/). Limited tests were done using MySQL 5. There is no guarantee that the driver will work well or even at all in a similar or different environment.
During tests the driver was recording several hundered megabytes of JDBC data, producing a storage file of about 15 megabyte. However, there is an internal lookup of values stored already used by the driver. So storing more than MAX_INTEGER different values will cause the driver to fail.
By nature of the recording process, the driver is not multi-thread safe. Trying to record the database session of a multi-user web application will fail. Using several connections serially should work.
This project is licenced under the EUPL v1.1 (European Public License), see http://ec.europa.eu/idabc/eupl/ for details.
HOW TO GET
The compiled library can be downloaded from (http://sourceforge.net/projects/dbdatestdriver/). Sourcecode is available from the CVS.