Package org.dbunit
Interface IDatabaseTester
- All Known Implementing Classes:
AbstractDatabaseTester,DataSourceDatabaseTester,DefaultDatabaseTester,JdbcDatabaseTester,JndiDatabaseTester,PropertiesBasedJdbcDatabaseTester
public interface IDatabaseTester
This interface defines the behavior of a DatabaseTester, which is responsible
for adding DBUnit features as composition on existing test cases (instead of
extending DBTestCase directly).
- Since:
- 2.2.0
- Version:
- $Revision$ $Date$
- Author:
- Andres Almiray (aalmiray@users.sourceforge.net), Last changed by: $Author$
-
Method Summary
Modifier and TypeMethodDescriptionvoidcloseConnection(IDatabaseConnection connection) Deprecated.Returns the test database connection.Returns the test dataset.default IOperationListenerReturns the listener currently notified of connection-retrieval and setup/tear-down events, so a caller composing a new listener can wrap it instead of discarding it.Gets the DatabaseOperation to call when starting the test.Gets the DatabaseOperation to call when ending the test.voidonSetup()TestCases must call this method inside setUp()voidTestCases must call this method inside tearDown()voidsetDataSet(IDataSet dataSet) Sets the test dataset to use.voidsetOperationListener(IOperationListener operationListener) Sets the listener notified of connection-retrieval and setup/tear-down events.voidDeprecated.since 2.4.3 Should not be used anymore.voidsetSetUpOperation(DatabaseOperation setUpOperation) Sets the DatabaseOperation to call when starting the test.voidsetTearDownOperation(DatabaseOperation tearDownOperation) Sets the DatabaseOperation to call when ending the test.
-
Method Details
-
closeConnection
Deprecated.since 2.4.4 define a user definedsetOperationListener(IOperationListener)in advanceClose the specified connection.- Parameters:
connection- the connection to close.- Throws:
Exception- if the connection cannot be closed.
-
getConnection
Returns the test database connection.- Returns:
- the test database connection.
- Throws:
Exception- if the connection cannot be retrieved or created.
-
getDataSet
IDataSet getDataSet()Returns the test dataset.- Returns:
- the test dataset.
-
getSetUpOperation
DatabaseOperation getSetUpOperation()Gets the DatabaseOperation to call when starting the test.- Returns:
- the setup
DatabaseOperation.
-
getTearDownOperation
DatabaseOperation getTearDownOperation()Gets the DatabaseOperation to call when ending the test.- Returns:
- the tear-down
DatabaseOperation.
-
setDataSet
Sets the test dataset to use.- Parameters:
dataSet- the test dataset to use.
-
setSchema
Deprecated.since 2.4.3 Should not be used anymore. Every concreteIDatabaseTesterimplementation that needs a schema has the possibility to set it somehow in the constructorSets the schema value.- Parameters:
schema- the schema name.
-
setSetUpOperation
Sets the DatabaseOperation to call when starting the test.- Parameters:
setUpOperation- the setupDatabaseOperation.
-
setTearDownOperation
Sets the DatabaseOperation to call when ending the test.- Parameters:
tearDownOperation- the tear-downDatabaseOperation.
-
onSetup
TestCases must call this method inside setUp()- Throws:
Exception- if the setup operation fails.
-
onTearDown
TestCases must call this method inside tearDown()- Throws:
Exception- if the tear-down operation fails.
-
setOperationListener
Sets the listener notified of connection-retrieval and setup/tear-down events.- Parameters:
operationListener- The operation listener that is invoked on specific events in theIDatabaseTester.- Since:
- 2.4.4
-
getOperationListener
Returns the listener currently notified of connection-retrieval and setup/tear-down events, so a caller composing a new listener can wrap it instead of discarding it.Default method for binary compatibility with implementations predating this method; they report no listener rather than failing to compile. Implementations backed by
setOperationListener(IOperationListener)should override this to return the value that method was last called with.- Returns:
- The current
IOperationListener, ornullifsetOperationListener(IOperationListener)has never been called. - Since:
- 3.6.0
-
setOperationListener(IOperationListener)in advance