Class TestHelper
- java.lang.Object
-
- io.debezium.connector.oracle.util.TestHelper
-
public class TestHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description private static Map<String,Field>cacheMappingsstatic StringCONNECTOR_NAMEstatic StringCONNECTOR_USERstatic StringCONNECTOR_USER_PASSstatic StringDATABASEprivate static StringDATABASE_ADMIN_PREFIXstatic StringDATABASE_CDBprivate static StringDATABASE_PREFIXstatic PathDB_HISTORY_PATHstatic StringHOSTstatic StringINFINISPAN_HOSTstatic intINFINISPAN_HOTROD_PORTstatic StringINFINISPAN_PASSstatic StringINFINISPAN_SERVER_LISTstatic StringINFINISPAN_USERprivate static StringPDB_NAMEstatic intPORTstatic StringSCHEMA_PASSstatic StringSCHEMA_USERstatic StringSERVER_NAMEstatic StringTYPE_LENGTH_PARAMETER_KEYKey for schema parameter used to store a source column's type length.static StringTYPE_NAME_PARAMETER_KEYKey for schema parameter used to store a source column's type name.static StringTYPE_SCALE_PARAMETER_KEYKey for schema parameter used to store a source column's type scale.
-
Constructor Summary
Constructors Constructor Description TestHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.debezium.connector.oracle.OracleConnectorConfig.ConnectorAdapteradapter()private static Configuration.BuilderadminConfig()Returns a configuration builder based on the administrator account settings.static io.debezium.connector.oracle.OracleConnectionadminConnection()Return a connection that is suitable for performing test database changes that require an administrator role permission.private static JdbcConfigurationadminJdbcConfig()Returns a JdbcConfiguration for the database administrator account.private static io.debezium.connector.oracle.OracleConnectioncreateConnection(Configuration config, Configuration jdbcConfig, boolean autoCommit)Create an OracleConnection.static Configuration.BuilderdefaultConfig()Returns a JdbcConfiguration that is specific and suitable for initializing the connector.static io.debezium.connector.oracle.OracleConnectiondefaultConnection()Obtain a connection using the default configuration, i.e.private static JdbcConfigurationdefaultJdbcConfig()Returns a JdbcConfiguration that is specific for the XStream/LogMiner user accounts.static intdefaultMessageConsumerPollTimeout()static voiddropAllTables()Drops all tables visible to userSCHEMA_USER.static voiddropSequence(io.debezium.connector.oracle.OracleConnection connection, String sequence)static voiddropTable(io.debezium.connector.oracle.OracleConnection connection, String table)static voiddropTables(io.debezium.connector.oracle.OracleConnection connection, String... tables)static voidforceFlushOfRedoLogsToArchiveLogs()static voidforceLogfileSwitch()static StringgetConnectorUserName()Get the name of the connector user, the default isCONNECTOR_USER.private static StringgetConnectorUserPassword()Get the password of the connector user, the default isCONNECTOR_USER_PASS.static List<BigInteger>getCurrentRedoLogSequences()private static ConfigurationgetDatabaseConfig(String prefix)Retrieves all settings provided by system properties based on the suppliedprefix.static StringgetDatabaseName()Get the database name, the default isDATABASE.static StringgetDefaultInfinispanEmbeddedCacheConfig(String cacheName)static StringgetDefaultInfinispanRemoteCacheConfig(String cacheName)static intgetNumberOfOnlineLogGroups()static voidgrantRole(String roleName)Grants the specified role to theSCHEMA_USERor the user configured using the configuration optiondatabase.user, whichever has precedence.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 voidstreamTable(io.debezium.connector.oracle.OracleConnection connection, String table)Enables a given table to be streamed by Oracle.private static Configuration.BuildertestConfig()Returns a configuration builder based on the test schema and user account settings.static io.debezium.connector.oracle.OracleConnectiontestConnection()Return a test connection that is suitable for performing test database changes in tests.private static JdbcConfigurationtestJdbcConfig()Returns a JdbcConfiguration for the test schema and user account.static Configuration.BuilderwithDefaultInfinispanCacheConfigurations(io.debezium.connector.oracle.OracleConnectorConfig.LogMiningBufferType bufferType, Configuration.Builder builder)
-
-
-
Field Detail
-
PDB_NAME
private static final String PDB_NAME
- See Also:
- Constant Field Values
-
DATABASE_PREFIX
private static final String DATABASE_PREFIX
- See Also:
- Constant Field Values
-
DATABASE_ADMIN_PREFIX
private static final String DATABASE_ADMIN_PREFIX
- See Also:
- Constant Field Values
-
DB_HISTORY_PATH
public static final Path DB_HISTORY_PATH
-
CONNECTOR_USER
public static final String CONNECTOR_USER
- See Also:
- Constant Field Values
-
CONNECTOR_NAME
public static final String CONNECTOR_NAME
- See Also:
- Constant Field Values
-
SERVER_NAME
public static final String SERVER_NAME
- See Also:
- Constant Field Values
-
CONNECTOR_USER_PASS
public static final String CONNECTOR_USER_PASS
- See Also:
- Constant Field Values
-
HOST
public static final String HOST
- See Also:
- Constant Field Values
-
SCHEMA_USER
public static final String SCHEMA_USER
- See Also:
- Constant Field Values
-
SCHEMA_PASS
public static final String SCHEMA_PASS
- See Also:
- Constant Field Values
-
DATABASE
public static final String DATABASE
- See Also:
- Constant Field Values
-
DATABASE_CDB
public static final String DATABASE_CDB
- See Also:
- Constant Field Values
-
PORT
public static final int PORT
- See Also:
- Constant Field Values
-
INFINISPAN_HOTROD_PORT
public static final int INFINISPAN_HOTROD_PORT
- See Also:
- Constant Field Values
-
INFINISPAN_USER
public static final String INFINISPAN_USER
- See Also:
- Constant Field Values
-
INFINISPAN_PASS
public static final String INFINISPAN_PASS
- See Also:
- Constant Field Values
-
INFINISPAN_HOST
public static final String INFINISPAN_HOST
- See Also:
- Constant Field Values
-
INFINISPAN_SERVER_LIST
public static final String INFINISPAN_SERVER_LIST
- See Also:
- Constant Field Values
-
TYPE_NAME_PARAMETER_KEY
public static final String TYPE_NAME_PARAMETER_KEY
Key for schema parameter used to store a source column's type name.- See Also:
- Constant Field Values
-
TYPE_LENGTH_PARAMETER_KEY
public static final String TYPE_LENGTH_PARAMETER_KEY
Key for schema parameter used to store a source column's type length.- See Also:
- Constant Field Values
-
TYPE_SCALE_PARAMETER_KEY
public static final String TYPE_SCALE_PARAMETER_KEY
Key for schema parameter used to store a source column's type scale.- See Also:
- Constant Field Values
-
-
Method Detail
-
getConnectorUserName
public static String getConnectorUserName()
Get the name of the connector user, the default isCONNECTOR_USER.
-
getConnectorUserPassword
private static String getConnectorUserPassword()
Get the password of the connector user, the default isCONNECTOR_USER_PASS.
-
getDatabaseName
public static String getDatabaseName()
Get the database name, the default isDATABASE.
-
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 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.
-
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 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.
-
createConnection
private static io.debezium.connector.oracle.OracleConnection createConnection(Configuration config, Configuration 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 SQLExceptionEnables 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
public static void grantRole(String roleName)
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
-
revokeRole
public static void revokeRole(String roleName)
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
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)
-
-