jbertram commented on code in PR #5194:
URL: https://github.com/apache/activemq-artemis/pull/5194#discussion_r1752085133


##########
artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/store/sql/PropertySQLProviderTest.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jdbc.store.sql;
+
+import java.sql.DriverManager;
+
+import org.apache.activemq.artemis.tests.util.ArtemisTestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static 
org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider.Factory.SQLDialect.DERBY;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class PropertySQLProviderTest extends ArtemisTestCase {
+
+   @Test
+   public void testGetProperty() {
+      for (SQLProvider.DatabaseStoreType storeType : 
SQLProvider.DatabaseStoreType.values()) {
+         PropertySQLProvider factory = (PropertySQLProvider) new 
PropertySQLProvider.Factory(DERBY).create("who-cares", storeType);
+         factory.sql("create-file-table");
+      }
+   }
+
+   @Test
+   public void testGetMissingProperty() {
+      for (SQLProvider.DatabaseStoreType storeType : 
SQLProvider.DatabaseStoreType.values()) {
+         try {
+            PropertySQLProvider factory = (PropertySQLProvider) new 
PropertySQLProvider.Factory(DERBY).create("who-cares", storeType);
+            factory.sql("foo");
+            fail();
+         } catch (IllegalStateException e) {
+            // expected
+         }
+      }
+   }
+
+   @AfterEach
+   public void shutdownDerby() {
+      try {
+         DriverManager.getConnection("jdbc:derby:;shutdown=true");
+      } catch (Exception ignored) {
+      }

Review Comment:
   > Doesnt the failure suggest the driver was never registered in the test to 
begin with (I just assumed it was, given you added the shutdown step)?
   
   Yes. I originally copied this test from 
`org.apache.activemq.artemis.jdbc.store.journal.JDBCJournalLoaderCallbackTest` 
which had the `shutdownDerby` method. Apparently this isn't needed at all and 
in that test it swallows a similar exception every time. I changed my tests to 
use a `null` SQL dialect to make it more clear that Derby isn't required.



-- 
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: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to