You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/01/16 15:29:28 UTC

[2/2] qpid-broker-j git commit: QPID-8070: [Broker-J] [Unit Tests] Prevent tests leaking in-memory Derby instances

QPID-8070: [Broker-J] [Unit Tests] Prevent tests leaking in-memory Derby instances

Cherry picked fromac5587287d67e1965273155a9d70e63d50f0c3b1


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/887f535e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/887f535e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/887f535e

Branch: refs/heads/7.0.x
Commit: 887f535ea766ef9197b28a95f223b742044e5908
Parents: 14a53f6
Author: Keith Wall <kw...@apache.org>
Authored: Tue Jan 16 15:17:37 2018 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Tue Jan 16 15:21:40 2018 +0000

----------------------------------------------------------------------
 .../server/store/jdbc/JDBCMessageStoreTest.java  | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/887f535e/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java b/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
index 5e77791..279ee78 100644
--- a/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
+++ b/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
@@ -50,7 +50,7 @@ import org.apache.qpid.server.virtualhost.jdbc.JDBCVirtualHost;
 
 public class JDBCMessageStoreTest extends MessageStoreTestCase
 {
-    public static final String TEST_TABLE_PREFIX = "TEST_TABLE_PREFIX_";
+    private static final String TEST_TABLE_PREFIX = "TEST_TABLE_PREFIX_";
     private String _connectionURL;
     private static final int BUFFER_SIZE = 10;
     private static final int POOL_SIZE = 20;
@@ -163,10 +163,10 @@ public class JDBCMessageStoreTest extends MessageStoreTestCase
     @Override
     protected VirtualHost createVirtualHost()
     {
-        _connectionURL = "jdbc:derby:memory:/" + getTestName() + ";create=true";
+        _connectionURL = "jdbc:derby:memory:/" + getTestName();
 
         final JDBCVirtualHost jdbcVirtualHost = mock(JDBCVirtualHost.class);
-        when(jdbcVirtualHost.getConnectionUrl()).thenReturn(_connectionURL);
+        when(jdbcVirtualHost.getConnectionUrl()).thenReturn(_connectionURL + ";create=true");
         when(jdbcVirtualHost.getUsername()).thenReturn("test");
         when(jdbcVirtualHost.getPassword()).thenReturn("pass");
         when(jdbcVirtualHost.getTableNamePrefix()).thenReturn(TEST_TABLE_PREFIX);
@@ -192,24 +192,19 @@ public class JDBCMessageStoreTest extends MessageStoreTestCase
 
     private Set<String> getTableNames() throws SQLException
     {
-        Set<String> tableNames = new HashSet<String>();
+        Set<String> tableNames = new HashSet<>();
         Connection conn = null;
         try
         {
             conn = openConnection();
             DatabaseMetaData metaData = conn.getMetaData();
-            ResultSet tables = metaData.getTables(null, null, null, new String[] { "TABLE" });
-            try
+            try (ResultSet tables = metaData.getTables(null, null, null, new String[]{"TABLE"}))
             {
                 while (tables.next())
                 {
                     tableNames.add(tables.getString("TABLE_NAME"));
                 }
             }
-            finally
-            {
-                tables.close();
-            }
         }
         finally
         {
@@ -226,12 +221,12 @@ public class JDBCMessageStoreTest extends MessageStoreTestCase
         return DriverManager.getConnection(_connectionURL);
     }
 
-    public static void shutdownDerby(String connectionURL) throws SQLException
+    static void shutdownDerby(String connectionURL) throws SQLException
     {
         Connection connection = null;
         try
         {
-            connection = DriverManager.getConnection(connectionURL);
+            connection = DriverManager.getConnection(connectionURL + ";shutdown=true");
         }
         catch(SQLException e)
         {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org