You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/12/07 11:28:56 UTC

svn commit: r1773057 - in /qpid/java/trunk/broker-plugins/jdbc-store/src: main/java/org/apache/qpid/server/store/jdbc/ test/java/org/apache/qpid/server/store/jdbc/

Author: orudyy
Date: Wed Dec  7 11:28:55 2016
New Revision: 1773057

URL: http://svn.apache.org/viewvc?rev=1773057&view=rev
Log:
QPID-7577: [Java Broker] Set correct state on initialization of generic JDBC configuration store

Added:
    qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStoreTest.java
Modified:
    qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
    qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java

Modified: qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java?rev=1773057&r1=1773056&r2=1773057&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java (original)
+++ qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java Wed Dec  7 11:28:55 2016
@@ -19,8 +19,8 @@
 package org.apache.qpid.server.store.jdbc;
 
 
+import static org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.CLOSED;
 import static org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.CONFIGURED;
-import static org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.OPEN;
 
 import java.io.File;
 import java.nio.charset.Charset;
@@ -77,7 +77,7 @@ public class GenericJDBCConfigurationSto
     public void init(ConfiguredObject<?> parent)
             throws StoreException
     {
-        changeState(CONFIGURED, OPEN);
+        changeState(CLOSED, CONFIGURED);
         _parent = parent;
 
         JDBCSettings settings = (JDBCSettings) parent;

Added: qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStoreTest.java?rev=1773057&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStoreTest.java (added)
+++ qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStoreTest.java Wed Dec  7 11:28:55 2016
@@ -0,0 +1,69 @@
+/*
+ * 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.qpid.server.store.jdbc;
+
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
+import org.apache.qpid.server.store.AbstractDurableConfigurationStoreTestCase;
+import org.apache.qpid.server.store.DurableConfigurationStore;
+import org.apache.qpid.server.virtualhostnode.jdbc.JDBCVirtualHostNode;
+
+public class GenericJDBCConfigurationStoreTest extends AbstractDurableConfigurationStoreTestCase
+{
+
+    private String _connectionURL;
+
+    @Override
+    public void tearDown() throws Exception
+    {
+        try
+        {
+            super.tearDown();
+        }
+        finally
+        {
+            if (_connectionURL != null)
+            {
+                JDBCMessageStoreTest.shutdownDerby(_connectionURL);
+            }
+        }
+    }
+
+    @Override
+    protected VirtualHostNode createVirtualHostNode(final String storeLocation, final ConfiguredObjectFactory factory)
+    {
+        _connectionURL = "jdbc:derby:memory:/" + getTestName();
+        final JDBCVirtualHostNode parent = mock(JDBCVirtualHostNode.class);
+        when(parent.getConnectionUrl()).thenReturn(_connectionURL + ";create=true");
+        return parent;
+    }
+
+    @Override
+    protected DurableConfigurationStore createConfigStore() throws Exception
+    {
+        return new GenericJDBCConfigurationStore(VirtualHost.class);
+    }
+}

Modified: qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java?rev=1773057&r1=1773056&r2=1773057&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java (original)
+++ qpid/java/trunk/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java Wed Dec  7 11:28:55 2016
@@ -46,7 +46,10 @@ public class JDBCMessageStoreTest extend
     {
         try
         {
-            shutdownDerby();
+            if (_connectionURL != null)
+            {
+                shutdownDerby(_connectionURL);
+            }
         }
         finally
         {
@@ -130,13 +133,12 @@ public class JDBCMessageStoreTest extend
         return DriverManager.getConnection(_connectionURL);
     }
 
-
-    private void shutdownDerby() throws SQLException
+    public static void shutdownDerby(String connectionURL) throws SQLException
     {
         Connection connection = null;
         try
         {
-            connection = DriverManager.getConnection("jdbc:derby:memory:/" + getTestName() + ";shutdown=true");
+            connection = DriverManager.getConnection(connectionURL);
         }
         catch(SQLException e)
         {



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