gemmellr commented on code in PR #4407:
URL: https://github.com/apache/activemq-artemis/pull/4407#discussion_r1140436860


##########
artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java:
##########
@@ -300,16 +309,36 @@ protected void finished(Description description) {
       }
    };
 
-   @After
-   public void shutdownDerby() {
+
+   protected final void dropDerby() {
+      String user = getJDBCUser();
+      String password = getJDBCPassword();
       try {
-         DriverManager.getConnection("jdbc:derby:" + getEmbeddedDataBaseName() 
+ ";destroy=true");
-      } catch (Exception ignored) {
+         if (user == null) {
+            DriverManager.getConnection("jdbc:derby:" + 
getEmbeddedDataBaseName() + ";drop=true");
+         } else {
+            DriverManager.getConnection("jdbc:derby:" + 
getEmbeddedDataBaseName() + ";drop=true", user, password);
+         }
+      } catch (SQLException sqlE) {
+         logger.info("{} / {}", sqlE.getMessage(), sqlE.getSQLState());
+         Assert.assertEquals("08006", sqlE.getSQLState());
+         
Assert.assertTrue(sqlE.getMessage().toLowerCase(Locale.ROOT).contains("dropped"));

Review Comment:
   With this and the bit below, its gone from never logging anything even in 
failure cases, to logging 2 info messages on every single test method using 
derby...and then possibly failing an assertion, but in doing so still not 
actually giving the full original exception.
   
   Would seem simpler all round to just check the code is as expected for what 
was done and just throw the original exception if the code isnt as expected. 
Some debug logging if a need is really seen. Constants for the success-codes 
would also make clearer whats being done.
   
   E.g simply:
   ```
         if (!DERBY_DROP_SUCCEEDED.equals(sqlE.getSQLState()) {
            throw sqlE;
         }
   ```



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