Package org.dbunit.database.connection
Class AutoCommitOffWarning
java.lang.Object
org.dbunit.database.connection.AutoCommitOffWarning
- All Implemented Interfaces:
Consumer<IDatabaseConnection>
Logs one warning, the first time it sees a connection whose autocommit is disabled, for a
connection dbUnit's own setup and teardown operations will run on. Those operations
(
CLEAN_INSERT, DELETE_ALL, ...) do not manage a transaction of their own, and
TransactionOperation refuses a connection whose autocommit is
already off, so on such a connection their writes are never committed: invisible to other
connections, and - when the connection is kept across test methods - held as locks a
database's idle-in-transaction timeout may terminate mid-run.
Used as the onAcquired hook of a TestScopedConnection so the check runs
once per acquired connection at the single acquisition point, whichever path - the annotation
runtime's setup/teardown handling, or DefaultPrepAndExpectedTestCase -
borrowed it. One instance per lifecycle owner; it warns at most once regardless of how many
times the connection is (re)acquired.
- Since:
- 3.6.0
- Author:
- Jeff Jensen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IDatabaseConnection connection) Warns whenconnection's autocommit is off, unless a warning has already been logged by this instance or the autocommit state cannot be read.
-
Constructor Details
-
AutoCommitOffWarning
public AutoCommitOffWarning()
-
-
Method Details
-
accept
Warns whenconnection's autocommit is off, unless a warning has already been logged by this instance or the autocommit state cannot be read.- Specified by:
acceptin interfaceConsumer<IDatabaseConnection>- Parameters:
connection- The connection just acquired.
-