FrankChen021 commented on code in PR #19878:
URL: https://github.com/apache/druid/pull/19878#discussion_r3717623298


##########
extensions-core/lookups-cached-global/src/test/java/org/apache/druid/server/lookup/namespace/cache/JdbcExtractionNamespaceTest.java:
##########
@@ -85,8 +90,51 @@ public class JdbcExtractionNamespaceTest
       "empty string", new String[]{"empty string", "0"}
   );
 
+  private static class DerbyConnectorExtension implements BeforeEachCallback, 
AfterEachCallback
+  {
+    private final TestDerbyConnector connector = new TestDerbyConnector();
+
+    @Override
+    public void beforeEach(ExtensionContext context)
+    {
+      connector.createDatabase();
+    }
+
+    @Override
+    public void afterEach(ExtensionContext context)
+    {
+      try {
+        new DBI(connector.getJdbcUri() + ";drop=true").open().close();
+      }
+      catch (UnableToObtainConnectionException e) {
+        final SQLException cause = (SQLException) e.getCause();
+        Assertions.assertEquals(
+            "08006",
+            cause.getSQLState(),
+            StringUtils.format("Derby not shutdown: [%s]", cause)
+        );
+      }

Review Comment:
   Fixed in 07b88aac61. The teardown now uses JUnit 5 
Assertions.assertInstanceOf(SQLException.class, e.getCause(), ...) before 
reading SQLState, so a null or unexpected cause type fails with a clear 
assertion instead of ClassCastException or NPE. Focused lookup tests passed: 20 
tests, 0 failures, errors, or skips. Checkstyle: 0 violations. SpotBugs: 0 bugs 
or errors.



##########
extensions-core/lookups-cached-global/src/test/java/org/apache/druid/server/lookup/namespace/JdbcCacheGeneratorTest.java:
##########
@@ -83,32 +81,32 @@ public void setup()
   @Test
   public void indicatesMissingJdbcJarsWithTsColumn()
   {
-    String tsColumn = "tsColumn";
-    JdbcExtractionNamespace missingJarNamespace = 
createJdbcExtractionNamespace(
-        MISSING_METADATA_STORAGE_CONNECTOR_CONFIG,
-        tsColumn
-    );
-
-    exception.expect(IllegalStateException.class);
-    exception.expectMessage(MISSING_JDB_DRIVER_JAR_MSG);
-
-    target.generateCache(missingJarNamespace, KEY, LAST_VERSION, 
CACHE_MANAGER.allocateCache());
+    Throwable exception = assertThrows(IllegalStateException.class, () -> {
+      String tsColumn = "tsColumn";
+      JdbcExtractionNamespace missingJarNamespace = 
createJdbcExtractionNamespace(
+          MISSING_METADATA_STORAGE_CONNECTOR_CONFIG,
+          tsColumn
+      );

Review Comment:
   Fixed in 07b88aac61. Added final to the newly introduced non-reassigned 
locals in both JdbcCacheGeneratorTest cases, including the exception, column, 
and namespace variables. Focused lookup tests passed: 20 tests, 0 failures, 
errors, or skips. Checkstyle: 0 violations. SpotBugs: 0 bugs or errors.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to