alpreu commented on code in PR #19807: URL: https://github.com/apache/flink/pull/19807#discussion_r891173524
########## flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/table/JdbcOutputFormatTest.java: ########## @@ -91,181 +87,190 @@ public void tearDown() throws Exception { @Test public void testInvalidDriver() { String expectedMsg = "unable to open JDBC writer"; - try { - JdbcConnectorOptions jdbcOptions = - JdbcConnectorOptions.builder() - .setDriverName("org.apache.derby.jdbc.idontexist") - .setDBUrl(DERBY_EBOOKSHOP_DB.getUrl()) - .setTableName(INPUT_TABLE) - .build(); - JdbcDmlOptions dmlOptions = - JdbcDmlOptions.builder() - .withTableName(jdbcOptions.getTableName()) - .withDialect(jdbcOptions.getDialect()) - .withFieldNames(fieldNames) - .build(); - - outputFormat = - new JdbcOutputFormatBuilder() - .setJdbcOptions(jdbcOptions) - .setFieldDataTypes(fieldDataTypes) - .setJdbcDmlOptions(dmlOptions) - .setJdbcExecutionOptions(JdbcExecutionOptions.builder().build()) - .build(); - outputFormat.open(0, 1); - fail("Expected exception is not thrown."); - } catch (Exception e) { - assertTrue(findThrowable(e, IOException.class).isPresent()); - assertTrue(findThrowableWithMessage(e, expectedMsg).isPresent()); - } + assertThatThrownBy( + () -> { + JdbcConnectorOptions jdbcOptions = + JdbcConnectorOptions.builder() + .setDriverName("org.apache.derby.jdbc.idontexist") + .setDBUrl(DERBY_EBOOKSHOP_DB.getUrl()) + .setTableName(INPUT_TABLE) + .build(); + JdbcDmlOptions dmlOptions = + JdbcDmlOptions.builder() + .withTableName(jdbcOptions.getTableName()) + .withDialect(jdbcOptions.getDialect()) + .withFieldNames(fieldNames) + .build(); + + outputFormat = + new JdbcOutputFormatBuilder() + .setJdbcOptions(jdbcOptions) + .setFieldDataTypes(fieldDataTypes) + .setJdbcDmlOptions(dmlOptions) + .setJdbcExecutionOptions( + JdbcExecutionOptions.builder().build()) + .build(); + outputFormat.open(0, 1); + }) + .hasMessage(expectedMsg); Review Comment: Good catch :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org