private HealthCheck.Result runHealthCheck(MockDataProvider provider) throws Exception { MockConnection mockConnection = new MockConnection(provider) { @Override public Savepoint setSavepoint() throws SQLException { return new Savepoint() { @Override public int getSavepointId() throws SQLException { return 0; } @Override public String getSavepointName() throws SQLException { return "savepoint"; } }; } }; Configuration configuration = new DefaultConfiguration().set(mockConnection); configuration.settings().setExecuteLogging(false); JooqHealthCheck healthCheck = new JooqHealthCheck(configuration, validationQuery); return healthCheck.check(); }
static Connector mockConnector(MockDataProvider provider) { // Put your provider into a MockConnection and use that connection // in your application. In this case, with a jOOQ DSLContext: Connection connection = new MockConnection(provider); return new Connector() { @Override public Connection connect() throws SQLException { return connection; } @Override public SQLDialect getDialect() { return SQLDialect.HSQLDB; } @Override public Settings getSettings() { return new Settings(); } }; }
@Before public void init() { // Initialise your data provider (implementation further down): provider = new MyProvider(); connection = new MockConnection(provider); // Pass the mock connection to a jOOQ DSLContext: create = DSL.using(connection, SQLDialect.MYSQL); }