Top Description Methods
org.jooq.tools.jdbc

public Interface MockDataProvider

Known Direct Implementers
org.jooq.tools.jdbc.MockFileDatabase
Annotations
@FunctionalInterface
Imports
java.sql.PreparedStatement, .SQLException, .Statement, org.jooq.DSLContext, .Query, .Record, .ResultQuery

A data provider for mock query executions.

Supply this data provider to your MockConnection in order to globally provide data for SQL statements.

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.

See execute(MockExecuteContext) for more details.

Author
Lukas Eder
See Also
MockConnection

Method Summary

Modifier and TypeMethod and Description
public MockResult[]

Returns:

The execution results. If a null or an empty MockResult[] is returned, this has the same effect as returning new MockResult[] { new MockResult(-1, null) }
execute
(MockExecuteContext
The execution context.
ctx
)

Execution callback for a JDBC query execution.

Method Detail

executeback to summary
public MockResult[] execute(MockExecuteContext ctx) throws SQLException

Execution callback for a JDBC query execution.

This callback will be called by MockStatement upon the various statement execution methods. These include:

The various execution modes are unified into this simple method. Implementations should adhere to this contract:

Parameters
ctx:MockExecuteContext

The execution context.

Returns:MockResult[]

The execution results. If a null or an empty MockResult[] is returned, this has the same effect as returning new MockResult[] { new MockResult(-1, null) }

Exceptions
SQLException:
A SQLException that is passed through to jOOQ.