Package org.jumpmind.db.mock
Class MockDbUtils
java.lang.Object
org.jumpmind.db.mock.MockDbUtils
Helper class with static methods for mocking result sets and other database objects in MockDbDataSource
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResultSetbuildAutoIncrement1ColumnMetaData(boolean isAutoIncrement) Mocks up meta data ResultSet describing the AutoIncrementColumn column meta data (targeting isAutoIncrement call).static EmptyResultSetstatic MockDbPreparedStatementbuildPreparedStatement(String sql, ResultSet mockResultSet, int repeatOutput) Mocks up a PreparedStatement with specified results.static MockDbPreparedStatementbuildPreparedStatementNoResults(String sql, int repeatOutput) Mocks up an empty result set for a PreparedStatement.static ResultSetMocks up a generic ResultSet with zero columns and zero rows.static ResultSetbuildResultSet1Column1RowStringValue(String columnName, String value) Mocks up a generic ResultSet with only one column and one row.static MockDbStatementbuildStatement(String sql, ResultSet mockResultSet, int repeatOutput) Mocks up a Statement with specified results.static MockDbStatementbuildStatementNoResults(String sql, int repeatOutput) Mocks up an empty result set for a Statement.static ResultSetbuildTable1ColumnMetaData(String columnName, String defaultValue, String jdbcTypeName, int jdbcTypeCode, String testColumnSize, boolean isNullable) Mocks up meta data ResultSet describing a 1-column table (targeting getColumns call).static ResultSetbuildTable1IndexInfoMetaData(String indexName, String tableName) Mocks up meta data ResultSet describing a 1-index table (targeting getIndexInfo call).static ResultSetbuildTable1PrimaryKey1ColumnMetaData(String tableName, String primaryKeyName, String columnName) Mocks up meta data ResultSet describing a 1-primary key table with one column (targeting getPrimaryKeys call).static ResultSetbuildTableHeaderMetaData(String catalog, String schema, String tableName, String tableType, String description) Mocks up meta data ResultSet for a table (targeting getTables call).static MockDbPreparedStatementmockTableLookup1Statement(String tableName, String anticipatedPlatformTableLookupQuery) Mocks up 1 result row for an anticipated Prepared statement fetching table information (useful for DdlReader.getTableNames )static MockDbPreparedStatementmockTriggerLookup1PreparedStatement(String triggerName, String schemaName, String tableName, String triggerSource, String isInsert, String isUpdate, String isDelete, String triggerInfoQuery) Mocks up 1 result row for an anticipated Prepared statement fetching trigger information.
-
Constructor Details
-
MockDbUtils
public MockDbUtils()
-
-
Method Details
-
buildEmptyResultSet
-
buildPreparedStatementNoResults
Mocks up an empty result set for a PreparedStatement. Use with MockDbDataSource.enqueue() -
buildPreparedStatement
public static MockDbPreparedStatement buildPreparedStatement(String sql, ResultSet mockResultSet, int repeatOutput) Mocks up a PreparedStatement with specified results. Use with MockDbDataSource.enqueue() -
buildStatementNoResults
Mocks up an empty result set for a Statement. Use with MockDbDataSource.enqueue() -
buildStatement
Mocks up a Statement with specified results. Use with MockDbDataSource.enqueue() -
buildTableHeaderMetaData
public static ResultSet buildTableHeaderMetaData(String catalog, String schema, String tableName, String tableType, String description) throws SQLException Mocks up meta data ResultSet for a table (targeting getTables call). Use with MockDbDataSource.enqueueMetaData()- Throws:
SQLException
-
buildTable1ColumnMetaData
public static ResultSet buildTable1ColumnMetaData(String columnName, String defaultValue, String jdbcTypeName, int jdbcTypeCode, String testColumnSize, boolean isNullable) throws SQLException Mocks up meta data ResultSet describing a 1-column table (targeting getColumns call). Use with MockDbDataSource.enqueueMetaData()- Throws:
SQLException
-
buildTable1PrimaryKey1ColumnMetaData
public static ResultSet buildTable1PrimaryKey1ColumnMetaData(String tableName, String primaryKeyName, String columnName) throws SQLException Mocks up meta data ResultSet describing a 1-primary key table with one column (targeting getPrimaryKeys call). Use with MockDbDataSource.enqueueMetaData()- Throws:
SQLException
-
buildTable1IndexInfoMetaData
public static ResultSet buildTable1IndexInfoMetaData(String indexName, String tableName) throws SQLException Mocks up meta data ResultSet describing a 1-index table (targeting getIndexInfo call). Use with MockDbDataSource.enqueueMetaData()- Throws:
SQLException
-
buildAutoIncrement1ColumnMetaData
public static ResultSet buildAutoIncrement1ColumnMetaData(boolean isAutoIncrement) throws SQLException Mocks up meta data ResultSet describing the AutoIncrementColumn column meta data (targeting isAutoIncrement call). Use with MockDbDataSource.enqueueMetaData()- Throws:
SQLException
-
buildResultSet0Columns0Rows
Mocks up a generic ResultSet with zero columns and zero rows.- Throws:
SQLException
-
buildResultSet1Column1RowStringValue
public static ResultSet buildResultSet1Column1RowStringValue(String columnName, String value) throws SQLException Mocks up a generic ResultSet with only one column and one row.- Throws:
SQLException
-
mockTableLookup1Statement
public static MockDbPreparedStatement mockTableLookup1Statement(String tableName, String anticipatedPlatformTableLookupQuery) throws SQLException Mocks up 1 result row for an anticipated Prepared statement fetching table information (useful for DdlReader.getTableNames )- Throws:
SQLException
-
mockTriggerLookup1PreparedStatement
public static MockDbPreparedStatement mockTriggerLookup1PreparedStatement(String triggerName, String schemaName, String tableName, String triggerSource, String isInsert, String isUpdate, String isDelete, String triggerInfoQuery) throws SQLException Mocks up 1 result row for an anticipated Prepared statement fetching trigger information. Use with MockMsSqlConnection.enqueuePreparedStatement()- Throws:
SQLException
-