summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/test
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2013-07-10 09:10:51 +0000
committerRobert Godfrey <rgodfrey@apache.org>2013-07-10 09:10:51 +0000
commiteaa8c11396b13c46c59c2030a23cc7763ecee9d7 (patch)
tree1035b7dd270a843436871ef4f321e956c5d220f3 /qpid/java/broker/src/test
parent934d23d90cb12c820ff71e54f2220991fd72c081 (diff)
downloadqpid-python-eaa8c11396b13c46c59c2030a23cc7763ecee9d7.tar.gz
QPID-4983 : [Java Broker] Move store implementations to broker plugins
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1501682 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src/test')
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java6
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (renamed from qpid/java/broker/src/test/java/org/apache/qpid/server/store/DurableConfigurationStoreTest.java)21
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreCreatorTest.java39
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java66
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java85
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java153
6 files changed, 12 insertions, 358 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
index c6473d9520..042abca9c4 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
@@ -78,8 +78,7 @@ public class VirtualHostRecovererTest extends TestCase
attributes.put(VirtualHost.NAME, getName());
attributes.put(VirtualHost.TYPE, StandardVirtualHostFactory.TYPE);
- attributes.put(VirtualHost.STORE_PATH, "/path/to/virtualhost/store");
- attributes.put(VirtualHost.STORE_TYPE, "DERBY");
+ attributes.put(VirtualHost.STORE_TYPE, "MEMORY");
when(entry.getAttributes()).thenReturn(attributes);
VirtualHost host = recoverer.create(null, entry, parent);
@@ -99,8 +98,7 @@ public class VirtualHostRecovererTest extends TestCase
attributes = new HashMap<String, Object>();
attributes.put(VirtualHost.NAME, getName());
- attributes.put(VirtualHost.STORE_PATH, "/path/to/store");
- attributes.put(VirtualHost.STORE_TYPE, "DERBY");
+ attributes.put(VirtualHost.STORE_TYPE, "MEMORY");
mandatoryAttributes = new String[]{VirtualHost.NAME, VirtualHost.STORE_TYPE};
checkMandatoryAttributesAreValidated(mandatoryAttributes, attributes);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/DurableConfigurationStoreTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index 4a6b3f2cad..c6d166bc4c 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/DurableConfigurationStoreTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -42,9 +42,6 @@ import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
import org.apache.qpid.server.binding.Binding;
import org.apache.qpid.server.exchange.Exchange;
-import org.apache.qpid.server.logging.SystemOutMessageLogger;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.TestLogActor;
import org.apache.qpid.server.message.EnqueableMessage;
import org.apache.qpid.server.model.LifetimePolicy;
import org.apache.qpid.server.model.Queue;
@@ -54,11 +51,10 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.MockStoredMessage;
import org.apache.qpid.server.store.MessageStoreRecoveryHandler.StoredMessageRecoveryHandler;
import org.apache.qpid.server.store.Transaction.Record;
-import org.apache.qpid.server.store.derby.DerbyMessageStore;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.util.FileUtils;
-public class DurableConfigurationStoreTest extends QpidTestCase
+public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTestCase
{
private static final String EXCHANGE_NAME = "exchangeName";
private String _storePath;
@@ -371,6 +367,7 @@ public class DurableConfigurationStoreTest extends QpidTestCase
private void reopenStore() throws Exception
{
+ onReopenStore();
if (_messageStore != null)
{
_messageStore.close();
@@ -383,8 +380,10 @@ public class DurableConfigurationStoreTest extends QpidTestCase
_messageStore.activate();
}
- protected MessageStore createMessageStore() throws Exception
- {
+ protected abstract void onReopenStore();
+
+ abstract protected MessageStore createMessageStore() throws Exception;
+ /*{
String storeClass = System.getProperty(MESSAGE_STORE_CLASS_NAME_KEY);
if (storeClass == null)
{
@@ -394,9 +393,9 @@ public class DurableConfigurationStoreTest extends QpidTestCase
MessageStore messageStore = (MessageStore) Class.forName(storeClass).newInstance();
return messageStore;
}
-
- protected DurableConfigurationStore createConfigStore() throws Exception
- {
+*/
+ abstract protected DurableConfigurationStore createConfigStore() throws Exception;
+ /*{
String storeClass = System.getProperty(CONFIGURATION_STORE_CLASS_NAME_KEY);
if (storeClass == null)
{
@@ -414,7 +413,7 @@ public class DurableConfigurationStoreTest extends QpidTestCase
}
return configurationStore;
}
-
+*/
public void testRecordXid() throws Exception
{
Record enqueueRecord = getTestRecord(1);
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreCreatorTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreCreatorTest.java
deleted file mode 100644
index e74937dd1c..0000000000
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreCreatorTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * 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;
-
-import org.apache.qpid.server.store.derby.DerbyMessageStore;
-import org.apache.qpid.test.utils.QpidTestCase;
-
-public class MessageStoreCreatorTest extends QpidTestCase
-{
- private static final String[] STORE_TYPES = {MemoryMessageStore.TYPE, DerbyMessageStore.TYPE};
-
- public void testMessageStoreCreator()
- {
- MessageStoreCreator messageStoreCreator = new MessageStoreCreator();
- for (String type : STORE_TYPES)
- {
- MessageStore store = messageStoreCreator.createMessageStore(type);
- assertNotNull("Store of type " + type + " is not created", store);
- }
- }
-}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
deleted file mode 100644
index 479675dac1..0000000000
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *
- * 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.derby;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreConstants;
-import org.apache.qpid.server.store.MessageStoreQuotaEventsTestBase;
-
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
-public class DerbyMessageStoreQuotaEventsTest extends MessageStoreQuotaEventsTestBase
-{
- private static final Logger _logger = Logger.getLogger(DerbyMessageStoreQuotaEventsTest.class);
-
- private static final int NUMBER_OF_MESSAGES_TO_OVERFILL_STORE = 10;
-
- /**
- * Estimated using an assumption that a physical disk space occupied by a
- * message is 3 times bigger then a message size
- */
- private static final int OVERFULL_SIZE = (int) (MESSAGE_DATA.length * 3 * NUMBER_OF_MESSAGES_TO_OVERFILL_STORE * 0.8);
-
- private static final int UNDERFULL_SIZE = (int) (OVERFULL_SIZE * 0.8);
-
- @Override
- protected int getNumberOfMessagesToFillStore()
- {
- return NUMBER_OF_MESSAGES_TO_OVERFILL_STORE;
- }
-
- @Override
- protected void applyStoreSpecificConfiguration(VirtualHost vhost)
- {
- _logger.debug("Applying store specific config. overfull-sze=" + OVERFULL_SIZE + ", underfull-size=" + UNDERFULL_SIZE);
-
- when(vhost.getAttribute(eq(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE))).thenReturn(OVERFULL_SIZE);
- when(vhost.getAttribute(eq(MessageStoreConstants.UNDERFULL_SIZE_ATTRIBUTE))).thenReturn(UNDERFULL_SIZE);
- }
-
- @Override
- protected MessageStore createStore() throws Exception
- {
- return new DerbyMessageStore();
- }
-}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
deleted file mode 100644
index 859fad629b..0000000000
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * 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.derby;
-
-import java.io.File;
-
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreTestCase;
-import org.apache.qpid.util.FileUtils;
-
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
-public class DerbyMessageStoreTest extends MessageStoreTestCase
-{
- private String _storeLocation;
-
- @Override
- public void tearDown() throws Exception
- {
- try
- {
- deleteStoreIfExists();
- }
- finally
- {
- super.tearDown();
- }
- }
-
- public void testOnDelete() throws Exception
- {
- File location = new File(_storeLocation);
- assertTrue("Store does not exist at " + _storeLocation, location.exists());
-
- getStore().close();
- assertTrue("Store does not exist at " + _storeLocation, location.exists());
-
- getStore().onDelete();
- assertFalse("Store exists at " + _storeLocation, location.exists());
- }
-
- @Override
- protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
- {
- _storeLocation = TMP_FOLDER + File.separator + getTestName();
- when(virtualHost.getAttribute(eq(VirtualHost.STORE_PATH))).thenReturn(_storeLocation);
- deleteStoreIfExists();
- }
-
- private void deleteStoreIfExists()
- {
- File location = new File(_storeLocation);
- if (location.exists())
- {
- FileUtils.delete(location, true);
- }
- }
-
- @Override
- protected MessageStore createMessageStore()
- {
- return new DerbyMessageStore();
- }
-
-}
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
deleted file mode 100644
index a8e0460cea..0000000000
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- *
- * 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 java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreTestCase;
-import org.apache.qpid.server.store.derby.DerbyMessageStore;
-
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
-public class JDBCMessageStoreTest extends MessageStoreTestCase
-{
- private String _connectionURL;
-
- @Override
- public void tearDown() throws Exception
- {
- try
- {
- shutdownDerby();
- }
- finally
- {
- super.tearDown();
- }
- }
-
- public void testOnDelete() throws Exception
- {
- String[] expectedTables = JDBCMessageStore.ALL_TABLES;
- assertTablesExist(expectedTables, true);
- getStore().close();
- assertTablesExist(expectedTables, true);
- getStore().onDelete();
- assertTablesExist(expectedTables, false);
- }
-
- @Override
- protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
- {
- _connectionURL = "jdbc:derby:memory:/" + getTestName() + ";create=true";
-
- when(virtualHost.getAttribute(eq("connectionURL"))).thenReturn(_connectionURL);
- }
-
- @Override
- protected MessageStore createMessageStore()
- {
- return new JDBCMessageStore();
- }
-
- private void assertTablesExist(String[] expectedTables, boolean exists) throws SQLException
- {
- Set<String> existingTables = getTableNames();
- for (String tableName : expectedTables)
- {
- assertEquals("Table " + tableName + (exists ? " is not found" : " actually exist"), exists,
- existingTables.contains(tableName));
- }
- }
-
- private Set<String> getTableNames() throws SQLException
- {
- Set<String> tableNames = new HashSet<String>();
- Connection conn = null;
- try
- {
- conn = openConnection();
- DatabaseMetaData metaData = conn.getMetaData();
- ResultSet tables = metaData.getTables(null, null, null, new String[] { "TABLE" });
- try
- {
- while (tables.next())
- {
- tableNames.add(tables.getString("TABLE_NAME"));
- }
- }
- finally
- {
- tables.close();
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- return tableNames;
- }
-
- private Connection openConnection() throws SQLException
- {
- return DriverManager.getConnection(_connectionURL);
- }
-
-
- private void shutdownDerby() throws SQLException
- {
- Connection connection = null;
- try
- {
- connection = DriverManager.getConnection("jdbc:derby:memory:/" + getTestName() + ";shutdown=true");
- }
- catch(SQLException e)
- {
- if (e.getSQLState().equalsIgnoreCase(DerbyMessageStore.DERBY_SINGLE_DB_SHUTDOWN_CODE))
- {
- //expected and represents a clean shutdown of this database only, do nothing.
- }
- else
- {
- throw e;
- }
- }
- finally
- {
- if (connection != null)
- {
- connection.close();
- }
- }
- }
-}