public class TestHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TestHelper.CdcRecordFoundBlockingMultiResultSetConsumer
A multiple result-set consumer used internally by
waitForCdcRecord(SqlServerConnection, String, CdcRecordHandler)
that allows returning whether the provided TestHelper.CdcRecordHandler detected the expected condition or not. |
static interface |
TestHelper.CdcRecordHandler |
| Modifier and Type | Field and Description |
|---|---|
private static String |
CDC_WRAPPERS_DML |
static Path |
DB_HISTORY_PATH |
private static String |
DISABLE_DB_CDC |
private static String |
DISABLE_TABLE_CDC |
private static String |
ENABLE_DB_CDC |
private static String |
ENABLE_TABLE_CDC |
private static String |
ENABLE_TABLE_CDC_WITH_CUSTOM_CAPTURE |
private static String |
IS_CDC_ENABLED |
private static String |
IS_CDC_TABLE_ENABLED |
private static org.slf4j.Logger |
LOGGER |
private static String |
STATEMENTS_PLACEHOLDER |
static String |
TEST_DATABASE |
private static String |
TEST_PROPERTY_PREFIX |
static String |
TYPE_LENGTH_PARAMETER_KEY
Key for schema parameter used to store a source column's type length.
|
static String |
TYPE_NAME_PARAMETER_KEY
Key for schema parameter used to store a source column's type name.
|
static String |
TYPE_SCALE_PARAMETER_KEY
Key for schema parameter used to store a source column's type scale.
|
| Constructor and Description |
|---|
TestHelper() |
| Modifier and Type | Method and Description |
|---|---|
static io.debezium.connector.sqlserver.SqlServerConnection |
adminConnection() |
static io.debezium.jdbc.JdbcConfiguration |
adminJdbcConfig() |
static void |
createTestDatabase() |
static Configuration.Builder |
defaultConfig()
Returns a default configuration suitable for most test cases.
|
static io.debezium.jdbc.JdbcConfiguration |
defaultJdbcConfig() |
protected static void |
disableDbCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
Disables CDC for a given database, if not already disabled.
|
static void |
disableTableCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
Disables CDC for a table for which it was enabled before.
|
static void |
dropTestDatabase() |
private static void |
dropTestDatabase(io.debezium.connector.sqlserver.SqlServerConnection connection) |
static void |
enableDbCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
Enables CDC for a given database, if not already enabled.
|
static void |
enableTableCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
Enables CDC for a table if not already enabled and generates the wrapper
functions for that table.
|
static void |
enableTableCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String tableName,
String captureName)
Enables CDC for a table with a custom capture name
functions for that table.
|
private static ObjectName |
getObjectName(String context,
String serverName) |
static boolean |
isCdcEnabled(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name) |
static io.debezium.connector.sqlserver.SqlServerConnection |
testConnection() |
static void |
waitForCdcRecord(io.debezium.connector.sqlserver.SqlServerConnection connection,
String tableName,
String captureInstanceName,
TestHelper.CdcRecordHandler handler) |
static void |
waitForCdcRecord(io.debezium.connector.sqlserver.SqlServerConnection connection,
String tableName,
TestHelper.CdcRecordHandler handler)
Utility method that will poll the CDC change tables and provide the record handler with the changes detected.
|
static void |
waitForMaxLsnAvailable(io.debezium.connector.sqlserver.SqlServerConnection connection) |
static void |
waitForSnapshotToBeCompleted() |
static void |
waitForStreamingStarted() |
static int |
waitTimeForRecords() |
private static final org.slf4j.Logger LOGGER
public static final Path DB_HISTORY_PATH
public static final String TEST_DATABASE
private static final String TEST_PROPERTY_PREFIX
private static final String STATEMENTS_PLACEHOLDER
private static final String ENABLE_DB_CDC
private static final String DISABLE_DB_CDC
private static final String ENABLE_TABLE_CDC
private static final String IS_CDC_ENABLED
private static final String IS_CDC_TABLE_ENABLED
private static final String ENABLE_TABLE_CDC_WITH_CUSTOM_CAPTURE
private static final String DISABLE_TABLE_CDC
private static final String CDC_WRAPPERS_DML
public static final String TYPE_NAME_PARAMETER_KEY
public static final String TYPE_LENGTH_PARAMETER_KEY
public static final String TYPE_SCALE_PARAMETER_KEY
public static io.debezium.jdbc.JdbcConfiguration adminJdbcConfig()
public static io.debezium.jdbc.JdbcConfiguration defaultJdbcConfig()
public static Configuration.Builder defaultConfig()
public static void createTestDatabase()
public static void dropTestDatabase()
private static void dropTestDatabase(io.debezium.connector.sqlserver.SqlServerConnection connection)
throws SQLException
SQLExceptionpublic static io.debezium.connector.sqlserver.SqlServerConnection adminConnection()
public static io.debezium.connector.sqlserver.SqlServerConnection testConnection()
public static void enableDbCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
throws SQLException
name - the name of the DB, may not be nullSQLException - if anything unexpected failsprotected static void disableDbCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
throws SQLException
name - the name of the DB, may not be nullSQLException - if anything unexpected failspublic static void enableTableCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
throws SQLException
name - the name of the table, may not be nullSQLException - if anything unexpected failspublic static boolean isCdcEnabled(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
throws SQLException
name - the name of the table, may not be nullSQLException - if anything unexpected failspublic static void enableTableCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String tableName,
String captureName)
throws SQLException
name - the name of the table, may not be nullSQLException - if anything unexpected failspublic static void disableTableCdc(io.debezium.connector.sqlserver.SqlServerConnection connection,
String name)
throws SQLException
name - the name of the table, may not be nullSQLException - if anything unexpected failspublic static void waitForSnapshotToBeCompleted()
public static void waitForStreamingStarted()
public static void waitForMaxLsnAvailable(io.debezium.connector.sqlserver.SqlServerConnection connection)
throws Exception
Exceptionprivate static ObjectName getObjectName(String context, String serverName) throws MalformedObjectNameException
MalformedObjectNameExceptionpublic static int waitTimeForRecords()
public static void waitForCdcRecord(io.debezium.connector.sqlserver.SqlServerConnection connection,
String tableName,
TestHelper.CdcRecordHandler handler)
true if the expected outcome
exists or false to indicate it did not find what it expected. This method will block until either
the handler returns true or if the polling fails to complete within the allocated poll window.connection - the SQL Server connection to be usedtableName - the main table name to be checkedhandler - the handler method to be called if changes are found in the capture table instancepublic static void waitForCdcRecord(io.debezium.connector.sqlserver.SqlServerConnection connection,
String tableName,
String captureInstanceName,
TestHelper.CdcRecordHandler handler)
Copyright © 2020 JBoss by Red Hat. All rights reserved.