- All Implemented Interfaces:
- ConnectionProvider
 This ConnectionProvider wraps a delegate
 ConnectionProvider and wraps all acquired Connection
 references in MockConnection.
 
Disclaimer: The general idea of mocking a JDBC connection with this jOOQ API is to provide quick workarounds, injection points, etc. using a very simple JDBC abstraction. It is NOT RECOMMENDED to emulate an entire database (including complex state transitions, transactions, locking, etc.) using this mock API. Once you have this requirement, please consider using an actual database instead for integration testing (e.g. using https://www.testcontainers.org), rather than implementing your test database inside of a MockDataProvider.
- Author:
- Lukas Eder
- 
Constructor SummaryConstructorsConstructorDescriptionMockConnectionProvider(ConnectionProvider delegate, MockDataProvider provider) 
- 
Method SummaryModifier and TypeMethodDescriptionfinal Connectionacquire()Acquire a connection from the connection lifecycle handler.final voidrelease(Connection connection) Release a connection to the connection lifecycle handler.
- 
Constructor Details- 
MockConnectionProvider
 
- 
- 
Method Details- 
acquireDescription copied from interface:ConnectionProviderAcquire a connection from the connection lifecycle handler.This method is called by jOOQ exactly once per execution lifecycle, i.e. per ExecuteContext. Implementations may freely chose, whether subsequent calls to this method:- return the same connection instance
- return the same connection instance for the same thread
- return the same connection instance for the same transaction (e.g. a
 javax.transaction.UserTransaction)
- return a fresh connection instance every time
 jOOQ will guarantee that every acquired connection is released through ConnectionProvider.release(Connection)exactly once.- Specified by:
- acquirein interface- ConnectionProvider
- Returns:
- A connection for the current ExecuteContext. Ifnullis returned (e.g. by NoConnectionProvider), then statements cannot be executed. Attempts to execute statements will result in aDetachedException.
 
- 
releaseDescription copied from interface:ConnectionProviderRelease a connection to the connection lifecycle handler.jOOQ will guarantee that every acquired connection is released exactly once. - Specified by:
- releasein interface- ConnectionProvider
- Parameters:
- connection- A connection that was previously obtained from- ConnectionProvider.acquire(). This is never- null.
 
 
-