Class TestHelper
java.lang.Object
io.debezium.connector.oracle.util.TestHelper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final Stringstatic final Stringprivate static final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringprivate static final Stringstatic final intstatic final Pathstatic final Stringstatic final Stringstatic final Stringstatic final StringKey for schema parameter used to store a source column's type length.static final StringKey for schema parameter used to store a source column's type name.static final StringKey for schema parameter used to store a source column's type scale. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.debezium.connector.oracle.OracleConnectorConfig.ConnectorAdapteradapter()private static Configuration.BuilderReturns a configuration builder based on the administrator account settings.static io.debezium.connector.oracle.OracleConnectionReturn a connection that is suitable for performing test database changes that require an administrator role permission.static io.debezium.connector.oracle.OracleConnectionadminConnection(boolean switchToRoot) Return a connection that is suitable for performing test database changes that require an administrator role permission.private static JdbcConfigurationReturns a JdbcConfiguration for the database administrator account.private static io.debezium.connector.oracle.OracleConnectioncreateConnection(Configuration config, JdbcConfiguration jdbcConfig, boolean autoCommit) Create an OracleConnection.static Configuration.BuilderReturns a JdbcConfiguration that is specific and suitable for initializing the connector.static io.debezium.connector.oracle.OracleConnectionObtain a connection using the default configuration, i.e.static io.debezium.connector.oracle.OracleConnectiondefaultConnection(boolean switchToRoot) Obtain a connection using the default configuration.private static JdbcConfigurationReturns a JdbcConfiguration that is specific for the XStream/LogMiner user accounts.static intstatic voidDrops all tables visible to userSCHEMA_USER.static voiddropSequence(io.debezium.connector.oracle.OracleConnection connection, String sequence) static voidstatic voiddropTables(io.debezium.connector.oracle.OracleConnection connection, String... tables) static voidstatic voidstatic io.debezium.connector.oracle.OracleConnectorConfig.ConnectorAdaptergetAdapter(Configuration config) Returns the connector adapter from the provided configuration.static StringGet the name of the connector user, the default isCONNECTOR_USER.private static StringGet the password of the connector user, the default isCONNECTOR_USER_PASS.static List<BigInteger>static io.debezium.connector.oracle.ScnReturns the current system change number in the database.private static ConfigurationgetDatabaseConfig(String prefix) Retrieves all settings provided by system properties based on the suppliedprefix.static StringGet the database name, the default isDATABASE.static StringgetDefaultInfinispanEmbeddedCacheConfig(String cacheName) static StringgetDefaultInfinispanRemoteCacheConfig(String cacheName) static intstatic StringGet a validOracleConnectorConfig.URLstring.static voidGrants the specified role to theSCHEMA_USERor the user configured using the configuration optiondatabase.user, whichever has precedence.static voidGrants the specified roles to theSCHEMA_USERor the user configured using the configuration optiondatabase.user, which has precedence, on the specified object.static booleanReturns whether the connection is using a pluggable database configuration.static voidpurgeRecycleBin(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.static voidrevokeRole(String roleName) Revokes the specified role from theSCHEMA_USERor the user configured using the configuration optiondatabase.user, whichever has precedence.static voidSimulateThread.sleep(long)by usingAwaitilityinstead.static voidstreamTable(io.debezium.connector.oracle.OracleConnection connection, String table) Enables a given table to be streamed by Oracle.private static Configuration.BuilderReturns a configuration builder based on the test schema and user account settings.static io.debezium.connector.oracle.OracleConnectionReturn a test connection that is suitable for performing test database changes in tests.private static JdbcConfigurationReturns a JdbcConfiguration for the test schema and user account.static Configuration.BuilderwithDefaultInfinispanCacheConfigurations(io.debezium.connector.oracle.OracleConnectorConfig.LogMiningBufferType bufferType, Configuration.Builder builder)
-
Field Details
-
PDB_NAME
- See Also:
-
DATABASE_PREFIX
- See Also:
-
DATABASE_ADMIN_PREFIX
- See Also:
-
SCHEMA_HISTORY_PATH
-
CONNECTOR_USER
- See Also:
-
CONNECTOR_NAME
- See Also:
-
SERVER_NAME
- See Also:
-
CONNECTOR_USER_PASS
- See Also:
-
HOST
- See Also:
-
SCHEMA_USER
- See Also:
-
SCHEMA_PASS
- See Also:
-
DATABASE
- See Also:
-
DATABASE_CDB
- See Also:
-
PORT
public static final int PORT- See Also:
-
INFINISPAN_HOTROD_PORT
public static final int INFINISPAN_HOTROD_PORT- See Also:
-
INFINISPAN_USER
- See Also:
-
INFINISPAN_PASS
- See Also:
-
INFINISPAN_HOST
- See Also:
-
INFINISPAN_SERVER_LIST
- See Also:
-
TYPE_NAME_PARAMETER_KEY
Key for schema parameter used to store a source column's type name.- See Also:
-
TYPE_LENGTH_PARAMETER_KEY
Key for schema parameter used to store a source column's type length.- See Also:
-
TYPE_SCALE_PARAMETER_KEY
Key for schema parameter used to store a source column's type scale.- See Also:
-
cacheMappings
-
-
Constructor Details
-
TestHelper
public TestHelper()
-
-
Method Details
-
getConnectorUserName
Get the name of the connector user, the default isCONNECTOR_USER. -
getConnectorUserPassword
Get the password of the connector user, the default isCONNECTOR_USER_PASS. -
getDatabaseName
Get the database name, the default isDATABASE. -
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
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 adatabase.pdb.namesetting; 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 ifswitchToRootis specified astrue. 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
Returns a JdbcConfiguration for the test schema and user account. -
adminJdbcConfig
Returns a JdbcConfiguration for the database administrator account. -
testConfig
Returns a configuration builder based on the test schema and user account settings. -
adminConfig
Returns a configuration builder based on the administrator account settings. -
getDatabaseConfig
Retrieves all settings provided by system properties based on the suppliedprefix.- 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 ifswitchToRootis specified astrue. 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 configurationjdbcConfig- the JDBC configurationautoCommit- 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 connectiontable- the table name inschema.tableformat.- 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
Grants the specified role to theSCHEMA_USERor the user configured using the configuration optiondatabase.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
Grants the specified roles to theSCHEMA_USERor the user configured using the configuration optiondatabase.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 grantedobjectName- the object to grant the role againstuserName- the user to whom the grant should be applied- Throws:
RuntimeException- if the role cannot be granted
-
revokeRole
Revokes the specified role from theSCHEMA_USERor the user configured using the configuration optiondatabase.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 userSCHEMA_USER. -
getCurrentRedoLogSequences
- Throws:
SQLException
-
getDefaultInfinispanEmbeddedCacheConfig
-
getDefaultInfinispanRemoteCacheConfig
-
withDefaultInfinispanCacheConfigurations
public static Configuration.Builder withDefaultInfinispanCacheConfigurations(io.debezium.connector.oracle.OracleConnectorConfig.LogMiningBufferType bufferType, Configuration.Builder builder) -
sleep
SimulateThread.sleep(long)by usingAwaitilityinstead.- Parameters:
duration- the duration to sleep (wait)units- the unit of time- Throws:
Exception- if the wait/sleep failed
-
getOracleConnectionUrlDescriptor
Get a validOracleConnectorConfig.URLstring. -
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 benull- Returns:
- the connector adapter being used.
-
getCurrentScn
Returns the current system change number in the database.- Returns:
- the current system change number, never
null - Throws:
SQLException- if a database error occurred
-