Class TestHelper


  • public class TestHelper
    extends Object
    • Constructor Detail

      • TestHelper

        public TestHelper()
    • Method Detail

      • 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.
      • 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.
      • createConnection

        private static io.debezium.connector.oracle.OracleConnection createConnection​(Configuration config,
                                                                                      Configuration 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)
      • 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
      • 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.