diff options
| author | Andrew MacBean <macbean@apache.org> | 2014-06-26 11:19:54 +0000 |
|---|---|---|
| committer | Andrew MacBean <macbean@apache.org> | 2014-06-26 11:19:54 +0000 |
| commit | 8a1190a3bc398233b3cb9a295add11eef0f3cec4 (patch) | |
| tree | 15ecfb671967401f81b9dce15e46aa9f1a33489c /qpid/java/broker-plugins/derby-store/src/test | |
| parent | 4ad072fd1cca374bcf36292bcf83aba74f18f08c (diff) | |
| download | qpid-python-8a1190a3bc398233b3cb9a295add11eef0f3cec4.tar.gz | |
QPID-5821: [Java Broker] Refactor MessageStore and DurableConfigurationStore interfaces to remove message store settings map.
VirtualHost model objects now have attributes.
Work done by Keith Wall <kwall@apache.org> and me.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1605737 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/derby-store/src/test')
3 files changed, 42 insertions, 24 deletions
diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java index 08c421b606..849bd066c7 100644 --- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java +++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java @@ -20,12 +20,26 @@ */ package org.apache.qpid.server.store.derby; +import org.apache.qpid.server.model.ConfiguredObjectFactory; +import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.store.AbstractDurableConfigurationStoreTestCase; +import org.apache.qpid.server.virtualhostnode.derby.DerbyVirtualHostNode; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase { @Override + protected VirtualHostNode createVirtualHostNode(String storeLocation, ConfiguredObjectFactory factory) + { + final DerbyVirtualHostNode parent = mock(DerbyVirtualHostNode.class); + when(parent.getStorePath()).thenReturn(storeLocation); + return parent; + } + + @Override protected DerbyConfigurationStore createConfigStore() throws Exception { return new DerbyConfigurationStore(); diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java index 348d81fadd..5c8eb94d91 100644 --- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java +++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java @@ -21,26 +21,27 @@ package org.apache.qpid.server.store.derby; import java.util.Collections; -import java.util.HashMap; import java.util.Map; -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.MessageStoreQuotaEventsTestBase; +import org.apache.qpid.server.virtualhost.derby.DerbyVirtualHost; + +import static org.mockito.Mockito.mock; +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 long OVERFULL_SIZE = (long) (MESSAGE_DATA.length * 3 * NUMBER_OF_MESSAGES_TO_OVERFILL_STORE * 0.8); - private static final int UNDERFULL_SIZE = (int) (OVERFULL_SIZE * 0.8); + private static final long UNDERFULL_SIZE = (long) (OVERFULL_SIZE * 0.8); @Override protected int getNumberOfMessagesToFillStore() @@ -49,27 +50,26 @@ public class DerbyMessageStoreQuotaEventsTest extends MessageStoreQuotaEventsTes } @Override - protected MessageStore createStore() throws Exception + protected VirtualHost createVirtualHost(String storeLocation) { - return new DerbyMessageStore(); + final DerbyVirtualHost parent = mock(DerbyVirtualHost.class); + when(parent.getContext()).thenReturn(createContextSettings()); + when(parent.getStorePath()).thenReturn(storeLocation); + when(parent.getStoreOverfullSize()).thenReturn(OVERFULL_SIZE); + when(parent.getStoreUnderfullSize()).thenReturn(UNDERFULL_SIZE); + return parent; } @Override - protected Map<String, Object> createStoreSettings(String storeLocation) + protected MessageStore createStore() throws Exception { - _logger.debug("Applying store specific config. overfull-size=" + OVERFULL_SIZE + ", underfull-size=" + UNDERFULL_SIZE); - - Map<String, Object> messageStoreSettings = new HashMap<String, Object>(); - messageStoreSettings.put(MessageStore.STORE_PATH, storeLocation); - messageStoreSettings.put(MessageStore.OVERFULL_SIZE, OVERFULL_SIZE); - messageStoreSettings.put(MessageStore.UNDERFULL_SIZE, UNDERFULL_SIZE); - return messageStoreSettings; + return new DerbyMessageStore(); } - @Override - protected Map<String, String> createContextSettings() + private Map<String, String> createContextSettings() { return Collections.emptyMap(); } + } diff --git a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java index 9a2d945494..ad3246290c 100644 --- a/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java +++ b/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java @@ -22,13 +22,16 @@ package org.apache.qpid.server.store.derby; import java.io.File; -import java.util.HashMap; -import java.util.Map; +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.virtualhost.derby.DerbyVirtualHost; import org.apache.qpid.util.FileUtils; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class DerbyMessageStoreTest extends MessageStoreTestCase { private String _storeLocation; @@ -59,13 +62,14 @@ public class DerbyMessageStoreTest extends MessageStoreTestCase } @Override - protected Map<String, Object> getStoreSettings() throws Exception + protected VirtualHost createVirtualHost() { _storeLocation = TMP_FOLDER + File.separator + getTestName(); deleteStoreIfExists(); - Map<String, Object> messageStoreSettings = new HashMap<String, Object>(); - messageStoreSettings.put(MessageStore.STORE_PATH, _storeLocation); - return messageStoreSettings; + + final DerbyVirtualHost parent = mock(DerbyVirtualHost.class); + when(parent.getStorePath()).thenReturn(_storeLocation); + return parent; } private void deleteStoreIfExists() |
