4343import static org .apache .flink .cdc .connectors .mysql .source .MySqlDataSourceOptions .SCAN_INCREMENTAL_SNAPSHOT_CHUNK_KEY_COLUMN ;
4444import static org .apache .flink .cdc .connectors .mysql .source .MySqlDataSourceOptions .TABLES ;
4545import 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 ;
4647import static org .apache .flink .cdc .connectors .mysql .source .MySqlDataSourceOptions .USERNAME ;
4748import static org .apache .flink .cdc .connectors .mysql .source .config .MySqlSourceOptions .SCAN_NEWLY_ADDED_TABLE_ENABLED ;
4849import static org .apache .flink .cdc .connectors .mysql .testutils .MySqSourceTestUtils .TEST_PASSWORD ;
@@ -232,7 +233,6 @@ public void testUnsupportedOption() {
232233 options .put (USERNAME .key (), TEST_USER );
233234 options .put (PASSWORD .key (), TEST_PASSWORD );
234235 options .put (TABLES .key (), inventoryDatabase .getDatabaseName () + ".prod\\ .*" );
235- options .put ("unsupported_key" , "unsupported_value" );
236236
237237 MySqlDataSourceFactory factory = new MySqlDataSourceFactory ();
238238 Factory .Context context = new MockContext (Configuration .fromMap (options ));
@@ -245,6 +245,27 @@ public void testUnsupportedOption() {
245245 + "unsupported_key" );
246246 }
247247
248+ @ Test
249+ public void testOptionalOption () {
250+ Map <String , String > options = new HashMap <>();
251+ options .put (HOSTNAME .key (), MYSQL_CONTAINER .getHost ());
252+ options .put (PORT .key (), String .valueOf (MYSQL_CONTAINER .getDatabasePort ()));
253+ options .put (USERNAME .key (), TEST_USER );
254+ options .put (PASSWORD .key (), TEST_PASSWORD );
255+ options .put (TABLES .key (), inventoryDatabase .getDatabaseName () + ".prod\\ .*" );
256+
257+ // optional option
258+ options .put (TREAT_TINYINT1_AS_BOOLEAN_ENABLED .key (), "false" );
259+
260+ Factory .Context context = new MockContext (Configuration .fromMap (options ));
261+ MySqlDataSourceFactory factory = new MySqlDataSourceFactory ();
262+ assertThat (factory .optionalOptions ().contains (TREAT_TINYINT1_AS_BOOLEAN_ENABLED ))
263+ .isEqualTo (true );
264+
265+ MySqlDataSource dataSource = (MySqlDataSource ) factory .createDataSource (context );
266+ assertThat (dataSource .getSourceConfig ().isTreatTinyInt1AsBoolean ()).isEqualTo (false );
267+ }
268+
248269 @ Test
249270 public void testPrefixRequireOption () {
250271 inventoryDatabase .createAndInitialize ();
0 commit comments