Package io.debezium.connector.mysql
Class UniqueDatabase
java.lang.Object
io.debezium.connector.mysql.UniqueDatabase
Create and populate a unique instance of a MySQL database for each run of JUnit test. A user of class
needs to provide a logical name for Debezium and database name. It is expected that there is a init file
in
src/test/resources/ddl/<database_name>.sql.
The database name is enriched with a unique suffix that guarantees complete isolation between runs
<database_name>_<suffix>- Author:
- jpechane
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUniqueDatabase(String serverName, String databaseName) Creates an instance with given Debezium logical name and database nameUniqueDatabase(String serverName, String databaseName, UniqueDatabase sibling) Creates an instance with given Debezium logical name and database name and id suffix same as another database.UniqueDatabase(String serverName, String databaseName, String charset) Creates an instance with given Debezium logical name and database name and a set default charsetUniqueDatabase(String serverName, String databaseName, String identifier, String charset) -
Method Summary
Modifier and TypeMethodDescriptionprivate StringconvertSQL(String sql) voidCreates the database and populates it with initialization SQL script.voidcreateAndInitialize(Map<String, Object> urlProperties) Creates the database and populates it with initialization SQL script.qualifiedTableName(String tableName) timezone()topicForTable(String tableName) withDbHistoryPath(Path dbHistoryPath)
-
Field Details
-
TIMEZONE
-
DEFAULT_DATABASE
- See Also:
-
CREATE_DATABASE_DDL
-
CREATE_DATABASE_WITH_CHARSET_DDL
-
COMMENT_PATTERN
-
databaseName
-
charset
-
templateName
-
serverName
-
dbHistoryPath
-
identifier
-
-
Constructor Details
-
UniqueDatabase
-
UniqueDatabase
Creates an instance with given Debezium logical name and database name- Parameters:
serverName- - logical Debezium server namedatabaseName- - the name of the database (prix)
-
UniqueDatabase
Creates an instance with given Debezium logical name and database name and a set default charset- Parameters:
serverName- - logical Debezium server namedatabaseName- - the name of the database (prix)
-
UniqueDatabase
Creates an instance with given Debezium logical name and database name and id suffix same as another database. This is handy for tests that need multpli databases and can use regex based whitelisting.- Parameters:
serverName- - logical Debezium server namedatabaseName- - the name of the database (prix)sibling- - a database whose unique suffix will be used
-
-
Method Details
-
convertSQL
-
getDatabaseName
-
topicForTable
- Parameters:
tableName-- Returns:
- Fully qualified Kafka topic name for a given table
<serverName>.<databaseName>.<tableName>
-
qualifiedTableName
- Parameters:
tableName-- Returns:
- Fully qualified table name
<databaseName>.<tableName>
-
getServerName
-
createAndInitialize
public void createAndInitialize()Creates the database and populates it with initialization SQL script. To use multiline statements for stored procedures definition use delimiter $$ to delimit statements in the procedure. See fnDbz162 procedure in reqression_test.sql for example of usage. -
createAndInitialize
Creates the database and populates it with initialization SQL script. To use multiline statements for stored procedures definition use delimiter $$ to delimit statements in the procedure. See fnDbz162 procedure in reqression_test.sql for example of usage.- Parameters:
urlProperties- jdbc url properties
-
withDbHistoryPath
- Parameters:
dbHistoryPath- - directory where to store database schema history- See Also:
-
io.debezium.relational.history.FileDatabaseHistory
-
defaultJdbcConfigBuilder
- Returns:
- Configuration builder initialized with JDBC connection parameters.
-
defaultConfig
- Returns:
- Configuration builder initialized with JDBC connection parameters and most frequently used parameters
-
defaultConfigWithoutDatabaseFilter
- Returns:
- Configuration builder initialized with JDBC connection parameters and most frequently used parameters, database not filtered by default
-
getIdentifier
- Returns:
- The unique database suffix
-
timezone
- Returns:
- timezone in which the database is located
-