Package org.dbunit
Class DefaultDatabaseTester
java.lang.Object
org.dbunit.assertion.SimpleAssert
org.dbunit.AbstractDatabaseTester
org.dbunit.DefaultDatabaseTester
- All Implemented Interfaces:
IDatabaseTester
Default implementation of AbstractDatabaseTester, which does not know how
to get a connection by itself.
- Since:
- 2.2
- Version:
- $Revision$
- Author:
- Felipe Leme (dbunit@felipeal.net)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultDatabaseTester(CachingConnectionProvider connectionProvider, Callable<IDatabaseConnection> connectionFactory) Creates a new DefaultDatabaseTester that reuses one connection - created with the given factory - across calls via the givenCachingConnectionProvider, transparently replacing it if it is no longer alive.
Share the sameconnectionProviderinstance across the testers created for each test to get reuse across test methods; pair it withIOperationListener.NO_OP_OPERATION_LISTENER(or an equivalent non-closing listener) so the cached connection is not closed after everyAbstractDatabaseTester.onSetup()/AbstractDatabaseTester.onTearDown()call.DefaultDatabaseTester(IDatabaseConnection connection) Creates a new DefaultDatabaseTester with the supplied connection.
The same connection instance is returned by everygetConnection()call, with no liveness check. -
Method Summary
Modifier and TypeMethodDescriptionReturns the test database connection.Methods inherited from class org.dbunit.AbstractDatabaseTester
closeConnection, getDataSet, getSchema, getSetUpOperation, getTearDownOperation, onSetup, onTearDown, setDataSet, setOperationListener, setSchema, setSetUpOperation, setTearDownOperation, toStringMethods inherited from class org.dbunit.assertion.SimpleAssert
assertNotNull, assertNotNull, assertNotNullNorEmpty, assertTrue, assertTrue, fail
-
Constructor Details
-
DefaultDatabaseTester
Creates a new DefaultDatabaseTester with the supplied connection.
The same connection instance is returned by everygetConnection()call, with no liveness check. Pair this with a non-closingIOperationListener(e.g.IOperationListener.NO_OP_OPERATION_LISTENER) to keep it open across test methods.- Parameters:
connection- the connection to return from everygetConnection()call
-
DefaultDatabaseTester
public DefaultDatabaseTester(CachingConnectionProvider connectionProvider, Callable<IDatabaseConnection> connectionFactory) Creates a new DefaultDatabaseTester that reuses one connection - created with the given factory - across calls via the givenCachingConnectionProvider, transparently replacing it if it is no longer alive.
Share the sameconnectionProviderinstance across the testers created for each test to get reuse across test methods; pair it withIOperationListener.NO_OP_OPERATION_LISTENER(or an equivalent non-closing listener) so the cached connection is not closed after everyAbstractDatabaseTester.onSetup()/AbstractDatabaseTester.onTearDown()call.- Parameters:
connectionProvider- caches and validates the connection across callsconnectionFactory- creates a new connection; only invoked byconnectionProviderwhen there is no live cached connection to reuse- Since:
- 3.4.0
-
-
Method Details
-
getConnection
Description copied from interface:IDatabaseTesterReturns the test database connection.- Returns:
- the test database connection.
- Throws:
Exception- if the connection cannot be retrieved or created.
-