|
43 | 43 | import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.SCAN_INCREMENTAL_SNAPSHOT_CHUNK_KEY_COLUMN;
|
44 | 44 | import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.TABLES;
|
45 | 45 | import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.TABLES_EXCLUDE;
|
| 46 | +import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.TREAT_TINYINT1_AS_BOOLEAN_ENABLED; |
46 | 47 | import static org.apache.flink.cdc.connectors.mysql.source.MySqlDataSourceOptions.USERNAME;
|
47 | 48 | import static org.apache.flink.cdc.connectors.mysql.source.config.MySqlSourceOptions.SCAN_NEWLY_ADDED_TABLE_ENABLED;
|
48 | 49 | import static org.apache.flink.cdc.connectors.mysql.testutils.MySqSourceTestUtils.TEST_PASSWORD;
|
@@ -245,6 +246,28 @@ public void testUnsupportedOption() {
|
245 | 246 | + "unsupported_key");
|
246 | 247 | }
|
247 | 248 |
|
| 249 | + @Test |
| 250 | + public void testOptionalOption() { |
| 251 | + inventoryDatabase.createAndInitialize(); |
| 252 | + Map<String, String> options = new HashMap<>(); |
| 253 | + options.put(HOSTNAME.key(), MYSQL_CONTAINER.getHost()); |
| 254 | + options.put(PORT.key(), String.valueOf(MYSQL_CONTAINER.getDatabasePort())); |
| 255 | + options.put(USERNAME.key(), TEST_USER); |
| 256 | + options.put(PASSWORD.key(), TEST_PASSWORD); |
| 257 | + options.put(TABLES.key(), inventoryDatabase.getDatabaseName() + ".prod\\.*"); |
| 258 | + |
| 259 | + // optional option |
| 260 | + options.put(TREAT_TINYINT1_AS_BOOLEAN_ENABLED.key(), "false"); |
| 261 | + |
| 262 | + Factory.Context context = new MockContext(Configuration.fromMap(options)); |
| 263 | + MySqlDataSourceFactory factory = new MySqlDataSourceFactory(); |
| 264 | + assertThat(factory.optionalOptions().contains(TREAT_TINYINT1_AS_BOOLEAN_ENABLED)) |
| 265 | + .isEqualTo(true); |
| 266 | + |
| 267 | + MySqlDataSource dataSource = (MySqlDataSource) factory.createDataSource(context); |
| 268 | + assertThat(dataSource.getSourceConfig().isTreatTinyInt1AsBoolean()).isEqualTo(false); |
| 269 | + } |
| 270 | + |
248 | 271 | @Test
|
249 | 272 | public void testPrefixRequireOption() {
|
250 | 273 | inventoryDatabase.createAndInitialize();
|
|
0 commit comments