XComp commented on code in PR #19807:
URL: https://github.com/apache/flink/pull/19807#discussion_r891193045


##########
flink-connectors/flink-connector-jdbc/src/test/java/org/apache/flink/connector/jdbc/JdbcRowOutputFormatTest.java:
##########
@@ -76,27 +75,23 @@ public void testInvalidDriver() {
                             .finish();
             jdbcOutputFormat.open(0, 1);
         } catch (Exception e) {
-            assertTrue(findThrowable(e, IOException.class).isPresent());
-            assertTrue(findThrowableWithMessage(e, expectedMsg).isPresent());
+            assertThat(findThrowable(e, IOException.class)).isPresent();
+            assertThat(findThrowableWithMessage(e, expectedMsg)).isPresent();
         }
     }
 
     @Test
     public void testInvalidURL() {
         String expectedMsg = "No suitable driver found for 
jdbc:der:iamanerror:mory:ebookshop";
-        try {
-            jdbcOutputFormat =
-                    JdbcRowOutputFormat.buildJdbcOutputFormat()
-                            .setDrivername(DERBY_EBOOKSHOP_DB.getDriverClass())
-                            .setDBUrl("jdbc:der:iamanerror:mory:ebookshop")
-                            .setQuery(String.format(INSERT_TEMPLATE, 
INPUT_TABLE))
-                            .finish();
-            jdbcOutputFormat.open(0, 1);
-            fail("expect exception");
-        } catch (Exception e) {
-            assertTrue(findThrowable(e, IOException.class).isPresent());
-            assertTrue(findThrowableWithMessage(e, expectedMsg).isPresent());
-        }
+
+        jdbcOutputFormat =
+                JdbcRowOutputFormat.buildJdbcOutputFormat()
+                        .setDrivername(DERBY_EBOOKSHOP_DB.getDriverClass())
+                        .setDBUrl("jdbc:der:iamanerror:mory:ebookshop")
+                        .setQuery(String.format(INSERT_TEMPLATE, INPUT_TABLE))
+                        .finish();
+        assertThatThrownBy(() -> jdbcOutputFormat.open(0, 1))
+                .satisfies(anyCauseMatches(SQLException.class, expectedMsg));

Review Comment:
   I verified that the stacktrace is, indeed, how you described it with 
`IOException` being caused by a `SQLException`. But I don't know enough about 
the use-case and the intention of this test. Therefore, I would assume that we 
should do the conversion properly by also asserting the `IOException` here...



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to