Class TestHelper

java.lang.Object
io.debezium.connector.oracle.util.TestHelper

public class TestHelper extends Object
  • Field Details

  • Constructor Details

    • TestHelper

      public TestHelper()
  • Method Details

    • getConnectorUserName

      public static String getConnectorUserName()
      Get the name of the connector user, the default is CONNECTOR_USER.
    • getConnectorUserPassword

      private static String getConnectorUserPassword()
      Get the password of the connector user, the default is CONNECTOR_USER_PASS.
    • getDatabaseName

      public static String getDatabaseName()
      Get the database name, the default is DATABASE.
    • defaultJdbcConfig

      private static JdbcConfiguration defaultJdbcConfig()
      Returns a JdbcConfiguration that is specific for the XStream/LogMiner user accounts. If connecting to a CDB enabled database, this connection is to the root database.
    • defaultConfig

      public static Configuration.Builder defaultConfig()
      Returns a JdbcConfiguration that is specific and suitable for initializing the connector. The returned builder can be amended with values as a test case requires. When initializing a connector connection to a database that operates in non-CDB mode, the configuration should still provide a database.pdb.name setting; however the value of the setting should be empty. This is specific to the test suite only.
    • defaultConnection

      public static io.debezium.connector.oracle.OracleConnection defaultConnection()
      Obtain a connection using the default configuration, i.e. within the context of the actual connector user that connectors and interacts with the database.
    • defaultConnection

      public static io.debezium.connector.oracle.OracleConnection defaultConnection(boolean switchToRoot)
      Obtain a connection using the default configuration. Note that the returned connection will automatically switch to the container database root if switchToRoot is specified as true. If the connection is not configured to use pluggable databases or pluggable databases are not enabled, the argument has no effect on the returned connection.
    • testJdbcConfig

      private static JdbcConfiguration testJdbcConfig()
      Returns a JdbcConfiguration for the test schema and user account.
    • adminJdbcConfig

      private static JdbcConfiguration adminJdbcConfig()
      Returns a JdbcConfiguration for the database administrator account.
    • testConfig

      private static Configuration.Builder testConfig()
      Returns a configuration builder based on the test schema and user account settings.
    • adminConfig

      private static Configuration.Builder adminConfig()
      Returns a configuration builder based on the administrator account settings.
    • getDatabaseConfig

      private static Configuration getDatabaseConfig(String prefix)
      Retrieves all settings provided by system properties based on the supplied prefix.
      Parameters:
      prefix - the key prefix to limit the settings based upon, i.e. database..
      Returns:
      the configuration object
    • testConnection

      public static io.debezium.connector.oracle.OracleConnection testConnection()
      Return a test connection that is suitable for performing test database changes in tests.
    • adminConnection

      public static io.debezium.connector.oracle.OracleConnection adminConnection()
      Return a connection that is suitable for performing test database changes that require an administrator role permission. Additionally, the connection returned will be associated to the configured pluggable database if one is configured otherwise the root database.
    • adminConnection

      public static io.debezium.connector.oracle.OracleConnection adminConnection(boolean switchToRoot)
      Return a connection that is suitable for performing test database changes that require an administrator role permission. Note that the returned connection will automatically switch to the container database root if switchToRoot is specified as true. If the connection is not configured to use pluggable databases or pluggable databases are not enabled, the argument has no effect on the returned connection.
    • createConnection

      private static io.debezium.connector.oracle.OracleConnection createConnection(Configuration config, JdbcConfiguration jdbcConfig, boolean autoCommit)
      Create an OracleConnection.
      Parameters:
      config - the connector configuration
      jdbcConfig - the JDBC configuration
      autoCommit - whether the connection should enforce auto-commit
      Returns:
      the connection
    • forceLogfileSwitch

      public static void forceLogfileSwitch()
    • getNumberOfOnlineLogGroups

      public static int getNumberOfOnlineLogGroups()
    • forceFlushOfRedoLogsToArchiveLogs

      public static void forceFlushOfRedoLogsToArchiveLogs()
    • dropTable

      public static void dropTable(io.debezium.connector.oracle.OracleConnection connection, String table)
    • dropTables

      public static void dropTables(io.debezium.connector.oracle.OracleConnection connection, String... tables)
    • dropSequence

      public static void dropSequence(io.debezium.connector.oracle.OracleConnection connection, String sequence)
    • streamTable

      public static void streamTable(io.debezium.connector.oracle.OracleConnection connection, String table) throws SQLException
      Enables a given table to be streamed by Oracle.
      Parameters:
      connection - the oracle connection
      table - the table name in schema.table format.
      Throws:
      SQLException - if an exception occurred
    • purgeRecycleBin

      public static void purgeRecycleBin(io.debezium.connector.oracle.OracleConnection connection)
      Clear the recycle bin, removing all objects from the bin and release all space associated with objects in the recycle bin. This also clears any system-generated objects that are associated with a table that may have been recently dropped, such as index-organized tables.
      Parameters:
      connection - the oracle connection
    • grantRole

      public static void grantRole(String roleName)
      Grants the specified role to the SCHEMA_USER or the user configured using the configuration option database.user, whichever has precedence. If the configuration uses PDB, the grant will be performed in the PDB and not the CDB database.
      Parameters:
      roleName - role to be granted
      Throws:
      RuntimeException - if the role cannot be granted
    • grantRole

      public static void grantRole(String roleName, String objectName, String userName)
      Grants the specified roles to the SCHEMA_USER or the user configured using the configuration option database.user, which has precedence, on the specified object. If the configuration uses PDB, the grant will be performed int he PDB and not the CDB database.
      Parameters:
      roleName - role to be granted
      objectName - the object to grant the role against
      userName - the user to whom the grant should be applied
      Throws:
      RuntimeException - if the role cannot be granted
    • revokeRole

      public static void revokeRole(String roleName)
      Revokes the specified role from the SCHEMA_USER or the user configured using the configuration option database.user, whichever has precedence. If the configuration uses PDB, the revoke will be performed in the PDB and not the CDB instance.
      Parameters:
      roleName - role to be revoked
      Throws:
      RuntimeException - if the role cannot be revoked
    • defaultMessageConsumerPollTimeout

      public static int defaultMessageConsumerPollTimeout()
    • adapter

      public static io.debezium.connector.oracle.OracleConnectorConfig.ConnectorAdapter adapter()
    • dropAllTables

      public static void dropAllTables()
      Drops all tables visible to user SCHEMA_USER.
    • getCurrentRedoLogSequences

      public static List<BigInteger> getCurrentRedoLogSequences() throws SQLException
      Throws:
      SQLException
    • getDefaultInfinispanEmbeddedCacheConfig

      public static String getDefaultInfinispanEmbeddedCacheConfig(String cacheName)
    • getDefaultInfinispanRemoteCacheConfig

      public static String getDefaultInfinispanRemoteCacheConfig(String cacheName)
    • withDefaultInfinispanCacheConfigurations

      public static Configuration.Builder withDefaultInfinispanCacheConfigurations(io.debezium.connector.oracle.OracleConnectorConfig.LogMiningBufferType bufferType, Configuration.Builder builder)
    • sleep

      public static void sleep(long duration, TimeUnit units) throws Exception
      Simulate Thread.sleep(long) by using Awaitility instead.
      Parameters:
      duration - the duration to sleep (wait)
      units - the unit of time
      Throws:
      Exception - if the wait/sleep failed
    • getOracleConnectionUrlDescriptor

      public static String getOracleConnectionUrlDescriptor()
      Get a valid OracleConnectorConfig.URL string.
    • isUsingPdb

      public static boolean isUsingPdb()
      Returns whether the connection is using a pluggable database configuration.
    • getAdapter

      public static io.debezium.connector.oracle.OracleConnectorConfig.ConnectorAdapter getAdapter(Configuration config)
      Returns the connector adapter from the provided configuration.
      Parameters:
      config - the connector configuration, must not be null
      Returns:
      the connector adapter being used.