Class MockDbUtils

java.lang.Object
org.jumpmind.db.mock.MockDbUtils

public final class MockDbUtils extends Object
Helper class with static methods for mocking result sets and other database objects in MockDbDataSource
  • Constructor Details

    • MockDbUtils

      public MockDbUtils()
  • Method Details

    • buildEmptyResultSet

      public static EmptyResultSet buildEmptyResultSet()
    • buildPreparedStatementNoResults

      public static MockDbPreparedStatement buildPreparedStatementNoResults(String sql, int repeatOutput)
      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

      public static MockDbStatement buildStatementNoResults(String sql, int repeatOutput)
      Mocks up an empty result set for a Statement. Use with MockDbDataSource.enqueue()
    • buildStatement

      public static MockDbStatement buildStatement(String sql, ResultSet mockResultSet, int repeatOutput)
      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

      public static ResultSet buildResultSet0Columns0Rows() throws SQLException
      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