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 2014/04/01 12:35:37 UTC

svn commit: r1583597 [5/8] - in /qpid/trunk: ./ qpid/ qpid/cpp/src/ qpid/cpp/src/tests/ qpid/java/ qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleyd...

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Tue Apr  1 10:35:33 2014
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.times;
 
 import java.io.File;
 import java.util.HashMap;
@@ -36,24 +35,20 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.commons.configuration.Configuration;
 import org.apache.qpid.common.AMQPFilterTypes;
 import org.apache.qpid.server.binding.BindingImpl;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.message.EnqueueableMessage;
 import org.apache.qpid.server.model.Binding;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.ExclusivityPolicy;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.plugin.ExchangeType;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.store.MessageStoreRecoveryHandler.StoredMessageRecoveryHandler;
-import org.apache.qpid.server.store.Transaction.Record;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.util.FileUtils;
 import org.mockito.ArgumentCaptor;
@@ -75,16 +70,8 @@ public abstract class AbstractDurableCon
 
     private String _storePath;
     private String _storeName;
-    private MessageStore _messageStore;
-    private Configuration _configuration;
-    private VirtualHost _virtualHost;
 
     private ConfigurationRecoveryHandler _recoveryHandler;
-    private MessageStoreRecoveryHandler _messageStoreRecoveryHandler;
-    private StoredMessageRecoveryHandler _storedMessageRecoveryHandler;
-    private TransactionLogRecoveryHandler _logRecoveryHandler;
-    private TransactionLogRecoveryHandler.QueueEntryRecoveryHandler _queueEntryRecoveryHandler;
-    private TransactionLogRecoveryHandler.DtxRecordRecoveryHandler _dtxRecordRecoveryHandler;
 
     private ExchangeImpl _exchange = mock(ExchangeImpl.class);
     private static final String ROUTING_KEY = "routingKey";
@@ -93,32 +80,24 @@ public abstract class AbstractDurableCon
     private UUID _queueId;
     private UUID _exchangeId;
     private DurableConfigurationStore _configStore;
+    protected Map<String, Object> _configurationStoreSettings;
 
     public void setUp() throws Exception
     {
         super.setUp();
 
+        _configurationStoreSettings = new HashMap<String, Object>();
         _queueId = UUIDGenerator.generateRandomUUID();
         _exchangeId = UUIDGenerator.generateRandomUUID();
 
         _storeName = getName();
         _storePath = TMP_FOLDER + File.separator + _storeName;
+        _configurationStoreSettings.put(MessageStore.STORE_PATH, _storePath);
         FileUtils.delete(new File(_storePath), true);
         setTestSystemProperty("QPID_WORK", TMP_FOLDER);
-        _configuration = mock(Configuration.class);
+
         _recoveryHandler = mock(ConfigurationRecoveryHandler.class);
-        _storedMessageRecoveryHandler = mock(StoredMessageRecoveryHandler.class);
-        _logRecoveryHandler = mock(TransactionLogRecoveryHandler.class);
-        _messageStoreRecoveryHandler = mock(MessageStoreRecoveryHandler.class);
-        _queueEntryRecoveryHandler = mock(TransactionLogRecoveryHandler.QueueEntryRecoveryHandler.class);
-        _dtxRecordRecoveryHandler = mock(TransactionLogRecoveryHandler.DtxRecordRecoveryHandler.class);
-        _virtualHost = mock(VirtualHost.class);
-
-        when(_messageStoreRecoveryHandler.begin()).thenReturn(_storedMessageRecoveryHandler);
-        when(_logRecoveryHandler.begin(any(MessageStore.class))).thenReturn(_queueEntryRecoveryHandler);
-        when(_queueEntryRecoveryHandler.completeQueueEntryRecovery()).thenReturn(_dtxRecordRecoveryHandler);
         when(_exchange.getName()).thenReturn(EXCHANGE_NAME);
-
         when(_exchange.getId()).thenReturn(_exchangeId);
         when(_exchange.getExchangeType()).thenReturn(mock(ExchangeType.class));
         when(_exchange.getEventLogger()).thenReturn(new EventLogger());
@@ -128,11 +107,6 @@ public abstract class AbstractDurableCon
         when(exchangeRecord.getType()).thenReturn(Exchange.class.getSimpleName());
         when(_exchange.asObjectRecord()).thenReturn(exchangeRecord);
 
-        when(_configuration.getString(eq(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY), anyString())).thenReturn(
-                _storePath);
-        when(_virtualHost.getAttribute(eq(VirtualHost.STORE_PATH))).thenReturn(_storePath);
-
-
         _bindingArgs = new HashMap<String, Object>();
         String argKey = AMQPFilterTypes.JMS_SELECTOR.toString();
         String argValue = "some selector expression";
@@ -145,7 +119,6 @@ public abstract class AbstractDurableCon
     {
         try
         {
-            closeMessageStore();
             closeConfigStore();
             FileUtils.delete(new File(_storePath), true);
         }
@@ -512,123 +485,22 @@ public abstract class AbstractDurableCon
 
     private void reopenStore() throws Exception
     {
-        closeMessageStore();
         closeConfigStore();
-        _messageStore = createMessageStore();
         _configStore = createConfigStore();
 
-        _configStore.configureConfigStore(_virtualHost, _recoveryHandler);
-        _messageStore.configureMessageStore(_virtualHost, _messageStoreRecoveryHandler, _logRecoveryHandler);
-        _messageStore.activate();
+        ConfiguredObject<?> parent = mock(ConfiguredObject.class);
+        when(parent.getName()).thenReturn("testName");
+        _configStore.openConfigurationStore(parent, _configurationStoreSettings);
+        _configStore.recoverConfigurationStore(_recoveryHandler);
     }
 
-    protected abstract MessageStore createMessageStore() throws Exception;
     protected abstract DurableConfigurationStore createConfigStore() throws Exception;
-    protected abstract void closeMessageStore() throws Exception;
-    protected abstract void closeConfigStore() throws Exception;
 
-    public void testRecordXid() throws Exception
+    protected void closeConfigStore() throws Exception
     {
-        Record enqueueRecord = getTestRecord(1);
-        Record dequeueRecord = getTestRecord(2);
-        Record[] enqueues = { enqueueRecord };
-        Record[] dequeues = { dequeueRecord };
-        byte[] globalId = new byte[] { 1 };
-        byte[] branchId = new byte[] { 2 };
-
-        Transaction transaction = _messageStore.newTransaction();
-        transaction.recordXid(1l, globalId, branchId, enqueues, dequeues);
-        transaction.commitTran();
-        reopenStore();
-        verify(_dtxRecordRecoveryHandler).dtxRecord(1l, globalId, branchId, enqueues, dequeues);
-
-        transaction = _messageStore.newTransaction();
-        transaction.removeXid(1l, globalId, branchId);
-        transaction.commitTran();
-
-        reopenStore();
-        verify(_dtxRecordRecoveryHandler, times(1)).dtxRecord(1l, globalId, branchId, enqueues, dequeues);
-    }
-
-    private Record getTestRecord(long messageNumber)
-    {
-        UUID queueId1 = UUIDGenerator.generateRandomUUID();
-        TransactionLogResource queue1 = mock(TransactionLogResource.class);
-        when(queue1.getId()).thenReturn(queueId1);
-        EnqueueableMessage message1 = mock(EnqueueableMessage.class);
-        when(message1.isPersistent()).thenReturn(true);
-        when(message1.getMessageNumber()).thenReturn(messageNumber);
-        final StoredMessage storedMessage = mock(StoredMessage.class);
-        when(storedMessage.getMessageNumber()).thenReturn(messageNumber);
-        when(message1.getStoredMessage()).thenReturn(storedMessage);
-        Record enqueueRecord = new TestRecord(queue1, message1);
-        return enqueueRecord;
-    }
-
-    private static class TestRecord implements Record
-    {
-        private TransactionLogResource _queue;
-        private EnqueueableMessage _message;
-
-        public TestRecord(TransactionLogResource queue, EnqueueableMessage message)
-        {
-            super();
-            _queue = queue;
-            _message = message;
-        }
-
-        @Override
-        public TransactionLogResource getResource()
-        {
-            return _queue;
-        }
-
-        @Override
-        public EnqueueableMessage getMessage()
-        {
-            return _message;
-        }
-
-        @Override
-        public int hashCode()
+        if (_configStore != null)
         {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((_message == null) ? 0 : new Long(_message.getMessageNumber()).hashCode());
-            result = prime * result + ((_queue == null) ? 0 : _queue.getId().hashCode());
-            return result;
+            _configStore.closeConfigurationStore();
         }
-
-        @Override
-        public boolean equals(Object obj)
-        {
-            if (this == obj)
-            {
-                return true;
-            }
-            if (obj == null)
-            {
-                return false;
-            }
-            if (!(obj instanceof Record))
-            {
-                return false;
-            }
-            Record other = (Record) obj;
-            if (_message == null && other.getMessage() != null)
-            {
-                return false;
-            }
-            if (_queue == null && other.getResource() != null)
-            {
-                return false;
-            }
-            if (_message.getMessageNumber() != other.getMessage().getMessageNumber())
-            {
-                return false;
-            }
-            return _queue.getId().equals(other.getResource().getId());
-        }
-
     }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java Tue Apr  1 10:35:33 2014
@@ -22,8 +22,8 @@ package org.apache.qpid.server.store;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.apache.qpid.server.store.Event.AFTER_ACTIVATE;
-import static org.apache.qpid.server.store.Event.BEFORE_ACTIVATE;
+import static org.apache.qpid.server.store.Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL;
+import static org.apache.qpid.server.store.Event.PERSISTENT_MESSAGE_SIZE_OVERFULL;
 import junit.framework.TestCase;
 
 public class EventManagerTest extends TestCase
@@ -33,28 +33,28 @@ public class EventManagerTest extends Te
 
     public void testEventListenerFires()
     {
-        _eventManager.addEventListener(_mockListener, BEFORE_ACTIVATE);
-        _eventManager.notifyEvent(BEFORE_ACTIVATE);
-        verify(_mockListener).event(BEFORE_ACTIVATE);
+        _eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        _eventManager.notifyEvent(PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        verify(_mockListener).event(PERSISTENT_MESSAGE_SIZE_OVERFULL);
     }
 
     public void testEventListenerDoesntFire()
     {
-        _eventManager.addEventListener(_mockListener, BEFORE_ACTIVATE);
-        _eventManager.notifyEvent(AFTER_ACTIVATE);
+        _eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        _eventManager.notifyEvent(Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL);
         verifyZeroInteractions(_mockListener);
     }
 
     public void testEventListenerFiresMultipleTimes()
     {
-        _eventManager.addEventListener(_mockListener, BEFORE_ACTIVATE);
-        _eventManager.addEventListener(_mockListener, AFTER_ACTIVATE);
+        _eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        _eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_UNDERFULL);
 
-        _eventManager.notifyEvent(BEFORE_ACTIVATE);
-        verify(_mockListener).event(BEFORE_ACTIVATE);
+        _eventManager.notifyEvent(PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        verify(_mockListener).event(PERSISTENT_MESSAGE_SIZE_OVERFULL);
 
-        _eventManager.notifyEvent(AFTER_ACTIVATE);
-        verify(_mockListener).event(AFTER_ACTIVATE);
+        _eventManager.notifyEvent(PERSISTENT_MESSAGE_SIZE_UNDERFULL);
+        verify(_mockListener).event(PERSISTENT_MESSAGE_SIZE_UNDERFULL);
     }
 
     public void testMultipleListenersFireForSameEvent()
@@ -62,11 +62,11 @@ public class EventManagerTest extends Te
         final EventListener mockListener1 = mock(EventListener.class);
         final EventListener mockListener2 = mock(EventListener.class);
 
-        _eventManager.addEventListener(mockListener1, BEFORE_ACTIVATE);
-        _eventManager.addEventListener(mockListener2, BEFORE_ACTIVATE);
-        _eventManager.notifyEvent(BEFORE_ACTIVATE);
+        _eventManager.addEventListener(mockListener1, PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        _eventManager.addEventListener(mockListener2, PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        _eventManager.notifyEvent(PERSISTENT_MESSAGE_SIZE_OVERFULL);
 
-        verify(mockListener1).event(BEFORE_ACTIVATE);
-        verify(mockListener2).event(BEFORE_ACTIVATE);
+        verify(mockListener1).event(PERSISTENT_MESSAGE_SIZE_OVERFULL);
+        verify(mockListener2).event(PERSISTENT_MESSAGE_SIZE_OVERFULL);
     }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java Tue Apr  1 10:35:33 2014
@@ -26,17 +26,16 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.model.Binding;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestFileUtils;
+import org.apache.qpid.util.FileUtils;
 import org.mockito.ArgumentMatcher;
 import org.mockito.InOrder;
 
 import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyMap;
-import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.argThat;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.inOrder;
@@ -48,8 +47,11 @@ import static org.mockito.Mockito.when;
 public class JsonFileConfigStoreTest extends QpidTestCase
 {
     private final ConfigurationRecoveryHandler _recoveryHandler = mock(ConfigurationRecoveryHandler.class);
-    private VirtualHost _virtualHost;
+
     private JsonFileConfigStore _store;
+    private HashMap<String, Object> _configurationStoreSettings;
+    private ConfiguredObject<?> _virtualHost;
+    private File _storeLocation;
 
 
     private static final UUID ANY_UUID = UUID.randomUUID();
@@ -59,34 +61,35 @@ public class JsonFileConfigStoreTest ext
     public void setUp() throws Exception
     {
         super.setUp();
-        removeStoreFile();
-        _virtualHost = mock(VirtualHost.class);
+
+        _virtualHost = mock(ConfiguredObject.class);
         when(_virtualHost.getName()).thenReturn(getName());
-        when(_virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH)).thenReturn(TMP_FOLDER);
+        _storeLocation = TestFileUtils.createTestDirectory("json", true);
+        _configurationStoreSettings = new HashMap<String, Object>();
+        _configurationStoreSettings.put(JsonFileConfigStore.STORE_TYPE, JsonFileConfigStore.TYPE);
+        _configurationStoreSettings.put(JsonFileConfigStore.STORE_PATH, _storeLocation.getAbsolutePath());
         _store = new JsonFileConfigStore();
     }
 
     @Override
     public void tearDown() throws Exception
     {
-        removeStoreFile();
-    }
-
-    private void removeStoreFile()
-    {
-        File file = new File(TMP_FOLDER, getName() + ".json");
-        if(file.exists())
+        try
+        {
+            super.tearDown();
+        }
+        finally
         {
-            file.delete();
+            FileUtils.delete(_storeLocation, true);
         }
     }
 
     public void testNoStorePath() throws Exception
     {
-        when(_virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH)).thenReturn(null);
+        _configurationStoreSettings.put(JsonFileConfigStore.STORE_PATH, null);
         try
         {
-            _store.configureConfigStore(_virtualHost, _recoveryHandler);
+            _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
             fail("Store should not successfully configure if there is no path set");
         }
         catch (ServerScopedRuntimeException e)
@@ -98,10 +101,10 @@ public class JsonFileConfigStoreTest ext
 
     public void testInvalidStorePath() throws Exception
     {
-        when(_virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH)).thenReturn(System.getProperty("file.separator"));
+        _configurationStoreSettings.put(JsonFileConfigStore.STORE_PATH, System.getProperty("file.separator"));
         try
         {
-            _store.configureConfigStore(_virtualHost, _recoveryHandler);
+            _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
             fail("Store should not successfully configure if there is an invalid path set");
         }
         catch (ServerScopedRuntimeException e)
@@ -112,12 +115,13 @@ public class JsonFileConfigStoreTest ext
 
     public void testStartFromNoStore() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
         InOrder inorder = inOrder(_recoveryHandler);
         inorder.verify(_recoveryHandler).beginConfigurationRecovery(eq(_store), eq(0));
         inorder.verify(_recoveryHandler,never()).configuredObject(any(ConfiguredObjectRecord.class));
         inorder.verify(_recoveryHandler).completeConfigurationRecovery();
-        _store.close();
+        _store.closeConfigurationStore();
     }
 
     public void testUpdatedConfigVersionIsRetained() throws Exception
@@ -125,10 +129,12 @@ public class JsonFileConfigStoreTest ext
         final int NEW_CONFIG_VERSION = 42;
         when(_recoveryHandler.completeConfigurationRecovery()).thenReturn(NEW_CONFIG_VERSION);
 
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
-        _store.close();
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
+        _store.closeConfigurationStore();
 
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
         InOrder inorder = inOrder(_recoveryHandler);
 
         // first time the config version should be the initial version - 0
@@ -137,27 +143,28 @@ public class JsonFileConfigStoreTest ext
         // second time the config version should be the updated version
         inorder.verify(_recoveryHandler).beginConfigurationRecovery(eq(_store), eq(NEW_CONFIG_VERSION));
 
-        _store.close();
+        _store.closeConfigurationStore();
     }
 
     public void testCreateObject() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         final UUID queueId = new UUID(0, 1);
         final String queueType = Queue.class.getSimpleName();
         final Map<String,Object> queueAttr = Collections.singletonMap("name", (Object) "q1");
 
         _store.create(new ConfiguredObjectRecordImpl(queueId, queueType, queueAttr));
-        _store.close();
+        _store.closeConfigurationStore();
 
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
         verify(_recoveryHandler).configuredObject(matchesRecord(queueId, queueType, queueAttr));
-        _store.close();
+        _store.closeConfigurationStore();
     }
 
     public void testCreateAndUpdateObject() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         final UUID queueId = new UUID(0, 1);
         final String queueType = Queue.class.getSimpleName();
         Map<String,Object> queueAttr = Collections.singletonMap("name", (Object) "q1");
@@ -169,17 +176,18 @@ public class JsonFileConfigStoreTest ext
         queueAttr.put("owner", "theowner");
         _store.update(false, new ConfiguredObjectRecordImpl(queueId, queueType, queueAttr));
 
-        _store.close();
+        _store.closeConfigurationStore();
 
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
         verify(_recoveryHandler).configuredObject(matchesRecord(queueId, queueType, queueAttr));
-        _store.close();
+        _store.closeConfigurationStore();
     }
 
 
     public void testCreateAndRemoveObject() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         final UUID queueId = new UUID(0, 1);
         final String queueType = Queue.class.getSimpleName();
         Map<String,Object> queueAttr = Collections.singletonMap("name", (Object) "q1");
@@ -190,16 +198,17 @@ public class JsonFileConfigStoreTest ext
 
         _store.remove(record);
 
-        _store.close();
+        _store.closeConfigurationStore();
 
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
         verify(_recoveryHandler, never()).configuredObject(any(ConfiguredObjectRecord.class));
-        _store.close();
+        _store.closeConfigurationStore();
     }
 
     public void testCreateUnknownObjectType() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         try
         {
             _store.create(new ConfiguredObjectRecordImpl(UUID.randomUUID(), "wibble", Collections.<String, Object>emptyMap()));
@@ -213,7 +222,7 @@ public class JsonFileConfigStoreTest ext
 
     public void testTwoObjectsWithSameId() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         final UUID id = UUID.randomUUID();
         _store.create(new ConfiguredObjectRecordImpl(id, "Queue", Collections.<String, Object>emptyMap()));
         try
@@ -230,11 +239,11 @@ public class JsonFileConfigStoreTest ext
 
     public void testChangeTypeOfObject() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         final UUID id = UUID.randomUUID();
         _store.create(new ConfiguredObjectRecordImpl(id, "Queue", Collections.<String, Object>emptyMap()));
-        _store.close();
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.closeConfigurationStore();
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
 
         try
         {
@@ -249,21 +258,21 @@ public class JsonFileConfigStoreTest ext
 
     public void testLockFileGuaranteesExclusiveAccess() throws Exception
     {
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
 
         JsonFileConfigStore secondStore = new JsonFileConfigStore();
 
         try
         {
-            secondStore.configureConfigStore(_virtualHost, _recoveryHandler);
+            secondStore.openConfigurationStore(_virtualHost, _configurationStoreSettings);
             fail("Should not be able to open a second store with the same path");
         }
         catch(ServerScopedRuntimeException e)
         {
             // pass
         }
-        _store.close();
-        secondStore.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.closeConfigurationStore();
+        secondStore.openConfigurationStore(_virtualHost, _configurationStoreSettings);
 
 
     }
@@ -271,7 +280,7 @@ public class JsonFileConfigStoreTest ext
     public void testCreatedNestedObjects() throws Exception
     {
 
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
         final UUID queueId = new UUID(0, 1);
         final UUID queue2Id = new UUID(1, 1);
 
@@ -300,14 +309,15 @@ public class JsonFileConfigStoreTest ext
         final ConfiguredObjectRecordImpl binding2Record =
                 new ConfiguredObjectRecordImpl(binding2Id, "Binding", EMPTY_ATTR, binding2Parents);
         _store.update(true, bindingRecord, binding2Record);
-        _store.close();
-        _store.configureConfigStore(_virtualHost, _recoveryHandler);
+        _store.closeConfigurationStore();
+        _store.openConfigurationStore(_virtualHost, _configurationStoreSettings);
+        _store.recoverConfigurationStore(_recoveryHandler);
         verify(_recoveryHandler).configuredObject(matchesRecord(queueId, "Queue", EMPTY_ATTR));
         verify(_recoveryHandler).configuredObject(matchesRecord(queue2Id, "Queue", EMPTY_ATTR));
         verify(_recoveryHandler).configuredObject(matchesRecord(exchangeId, "Exchange", EMPTY_ATTR));
         verify(_recoveryHandler).configuredObject(matchesRecord(bindingId, "Binding", EMPTY_ATTR));
         verify(_recoveryHandler).configuredObject(matchesRecord(binding2Id, "Binding", EMPTY_ATTR));
-        _store.close();
+        _store.closeConfigurationStore();
 
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java Tue Apr  1 10:35:33 2014
@@ -20,23 +20,23 @@
  */
 package org.apache.qpid.server.store;
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import java.io.File;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.message.EnqueueableMessage;
-import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.store.MessageStoreRecoveryHandler.StoredMessageRecoveryHandler;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.util.FileUtils;
 
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase implements EventListener, TransactionLogResource
 {
     private static final Logger _logger = Logger.getLogger(MessageStoreQuotaEventsTestBase.class);
@@ -50,9 +50,7 @@ public abstract class MessageStoreQuotaE
     private UUID _transactionResource;
 
     protected abstract MessageStore createStore() throws Exception;
-
-    protected abstract void applyStoreSpecificConfiguration(VirtualHost virtualHost);
-
+    protected abstract Map<String, Object> createStoreSettings(String storeLocation);
     protected abstract int getNumberOfMessagesToFillStore();
 
     @Override
@@ -64,24 +62,23 @@ public abstract class MessageStoreQuotaE
         FileUtils.delete(_storeLocation, true);
 
 
-        VirtualHost vhost = mock(VirtualHost.class);
-        when(vhost.getAttribute(eq(VirtualHost.STORE_PATH))).thenReturn(_storeLocation.getAbsolutePath());
-        when(vhost.getName()).thenReturn("test");
-
-        applyStoreSpecificConfiguration(vhost);
+        Map<String, Object> storeSettings = createStoreSettings(_storeLocation.getAbsolutePath());
 
         _store = createStore();
-        ((DurableConfigurationStore)_store).configureConfigStore(vhost, null);
+
         MessageStoreRecoveryHandler recoveryHandler = mock(MessageStoreRecoveryHandler.class);
         when(recoveryHandler.begin()).thenReturn(mock(StoredMessageRecoveryHandler.class));
-        _store.configureMessageStore(vhost, recoveryHandler, null);
-        _store.activate();
+        ConfiguredObject<?> parent = mock(ConfiguredObject.class);
+        when(parent.getName()).thenReturn("test");
+        _store.openMessageStore(parent, storeSettings);
+        _store.recoverMessageStore(recoveryHandler, null);
 
         _transactionResource = UUID.randomUUID();
         _events = new ArrayList<Event>();
         _store.addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_OVERFULL, Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL);
     }
 
+
     @Override
     public void tearDown() throws Exception
     {
@@ -93,7 +90,7 @@ public abstract class MessageStoreQuotaE
         {
             if (_store != null)
             {
-                _store.close();
+                _store.closeMessageStore();
             }
             FileUtils.delete(_storeLocation, true);
         }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java Tue Apr  1 10:35:33 2014
@@ -23,50 +23,57 @@ package org.apache.qpid.server.store;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.times;
 
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.server.message.EnqueueableMessage;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.store.MessageStoreRecoveryHandler.StoredMessageRecoveryHandler;
+import org.apache.qpid.server.store.Transaction.Record;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public abstract class MessageStoreTestCase extends QpidTestCase
 {
-    private ConfigurationRecoveryHandler _recoveryHandler;
     private MessageStoreRecoveryHandler _messageStoreRecoveryHandler;
     private StoredMessageRecoveryHandler _storedMessageRecoveryHandler;
     private TransactionLogRecoveryHandler _logRecoveryHandler;
     private TransactionLogRecoveryHandler.QueueEntryRecoveryHandler _queueEntryRecoveryHandler;
     private TransactionLogRecoveryHandler.DtxRecordRecoveryHandler _dtxRecordRecoveryHandler;
-    private VirtualHost _virtualHost;
 
     private MessageStore _store;
+    private Map<String, Object> _storeSettings;
+    private ConfiguredObject<?> _parent;
 
     public void setUp() throws Exception
     {
         super.setUp();
 
-        _recoveryHandler = mock(ConfigurationRecoveryHandler.class);
+        _parent = mock(ConfiguredObject.class);
+        when(_parent.getName()).thenReturn("test");
+
         _storedMessageRecoveryHandler = mock(StoredMessageRecoveryHandler.class);
         _logRecoveryHandler = mock(TransactionLogRecoveryHandler.class);
         _messageStoreRecoveryHandler = mock(MessageStoreRecoveryHandler.class);
         _queueEntryRecoveryHandler = mock(TransactionLogRecoveryHandler.QueueEntryRecoveryHandler.class);
         _dtxRecordRecoveryHandler = mock(TransactionLogRecoveryHandler.DtxRecordRecoveryHandler.class);
-        _virtualHost = mock(VirtualHost.class);
-
 
         when(_messageStoreRecoveryHandler.begin()).thenReturn(_storedMessageRecoveryHandler);
         when(_logRecoveryHandler.begin(any(MessageStore.class))).thenReturn(_queueEntryRecoveryHandler);
         when(_queueEntryRecoveryHandler.completeQueueEntryRecovery()).thenReturn(_dtxRecordRecoveryHandler);
 
-        setUpStoreConfiguration(_virtualHost);
-        when(_virtualHost.getName()).thenReturn(getTestName());
+        _storeSettings = getStoreSettings();
 
         _store = createMessageStore();
-        ((DurableConfigurationStore)_store).configureConfigStore(_virtualHost, _recoveryHandler);
 
-        _store.configureMessageStore(_virtualHost, _messageStoreRecoveryHandler, _logRecoveryHandler);
+        _store.openMessageStore(_parent, _storeSettings);
+        _store.recoverMessageStore(_messageStoreRecoveryHandler, _logRecoveryHandler);
     }
 
-    protected abstract void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception;
+    protected abstract Map<String, Object> getStoreSettings() throws Exception;
 
     protected abstract MessageStore createMessageStore();
 
@@ -75,4 +82,116 @@ public abstract class MessageStoreTestCa
         return _store;
     }
 
+    public void testRecordXid() throws Exception
+    {
+        Record enqueueRecord = getTestRecord(1);
+        Record dequeueRecord = getTestRecord(2);
+        Record[] enqueues = { enqueueRecord };
+        Record[] dequeues = { dequeueRecord };
+        byte[] globalId = new byte[] { 1 };
+        byte[] branchId = new byte[] { 2 };
+
+        Transaction transaction = _store.newTransaction();
+        transaction.recordXid(1l, globalId, branchId, enqueues, dequeues);
+        transaction.commitTran();
+        reopenStore();
+        verify(_dtxRecordRecoveryHandler).dtxRecord(1l, globalId, branchId, enqueues, dequeues);
+
+        transaction = _store.newTransaction();
+        transaction.removeXid(1l, globalId, branchId);
+        transaction.commitTran();
+
+        reopenStore();
+        verify(_dtxRecordRecoveryHandler, times(1)).dtxRecord(1l, globalId, branchId, enqueues, dequeues);
+    }
+
+    private void reopenStore() throws Exception
+    {
+        _store.closeMessageStore();
+
+        _store = createMessageStore();
+        _store.openMessageStore(_parent, _storeSettings);
+        _store.recoverMessageStore(_messageStoreRecoveryHandler, _logRecoveryHandler);
+    }
+    private Record getTestRecord(long messageNumber)
+    {
+        UUID queueId1 = UUIDGenerator.generateRandomUUID();
+        TransactionLogResource queue1 = mock(TransactionLogResource.class);
+        when(queue1.getId()).thenReturn(queueId1);
+        EnqueueableMessage message1 = mock(EnqueueableMessage.class);
+        when(message1.isPersistent()).thenReturn(true);
+        when(message1.getMessageNumber()).thenReturn(messageNumber);
+        final StoredMessage storedMessage = mock(StoredMessage.class);
+        when(storedMessage.getMessageNumber()).thenReturn(messageNumber);
+        when(message1.getStoredMessage()).thenReturn(storedMessage);
+        Record enqueueRecord = new TestRecord(queue1, message1);
+        return enqueueRecord;
+    }
+
+    private static class TestRecord implements Record
+    {
+        private TransactionLogResource _queue;
+        private EnqueueableMessage _message;
+
+        public TestRecord(TransactionLogResource queue, EnqueueableMessage message)
+        {
+            super();
+            _queue = queue;
+            _message = message;
+        }
+
+        @Override
+        public TransactionLogResource getResource()
+        {
+            return _queue;
+        }
+
+        @Override
+        public EnqueueableMessage getMessage()
+        {
+            return _message;
+        }
+
+        @Override
+        public int hashCode()
+        {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((_message == null) ? 0 : new Long(_message.getMessageNumber()).hashCode());
+            result = prime * result + ((_queue == null) ? 0 : _queue.getId().hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj)
+        {
+            if (this == obj)
+            {
+                return true;
+            }
+            if (obj == null)
+            {
+                return false;
+            }
+            if (!(obj instanceof Record))
+            {
+                return false;
+            }
+            Record other = (Record) obj;
+            if (_message == null && other.getMessage() != null)
+            {
+                return false;
+            }
+            if (_queue == null && other.getResource() != null)
+            {
+                return false;
+            }
+            if (_message.getMessageNumber() != other.getMessage().getMessageNumber())
+            {
+                return false;
+            }
+            return _queue.getId().equals(other.getResource().getId());
+        }
+
+    }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java Tue Apr  1 10:35:33 2014
@@ -21,9 +21,8 @@
 
 package org.apache.qpid.server.store;
 
-import java.util.Collections;
 import java.util.Map;
-import org.apache.commons.configuration.Configuration;
+
 import org.apache.qpid.server.plugin.MessageStoreFactory;
 
 public class TestMemoryMessageStoreFactory implements MessageStoreFactory
@@ -42,12 +41,6 @@ public class TestMemoryMessageStoreFacto
     }
 
     @Override
-    public Map<String, Object> convertStoreConfiguration(Configuration configuration)
-    {
-        return Collections.emptyMap();
-    }
-
-    @Override
     public void validateAttributes(Map<String, Object> attributes)
     {
     }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java Tue Apr  1 10:35:33 2014
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.Atomi
  */
 public class TestableMemoryMessageStore extends TestMemoryMessageStore
 {
+    public static final String TYPE = "TestableMemory";
     private final Map<Long, AMQQueue> _messages = new HashMap<Long, AMQQueue>();
     private final AtomicInteger _messageCount = new AtomicInteger(0);
 

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java Tue Apr  1 10:35:33 2014
@@ -29,14 +29,11 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.protocol.AMQSessionModel;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.configuration.store.JsonConfigurationEntryStore;
 import org.apache.qpid.server.exchange.DefaultExchangeFactory;
 import org.apache.qpid.server.model.Broker;
@@ -45,9 +42,12 @@ import org.apache.qpid.server.queue.AMQQ
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.stats.StatisticsGatherer;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.TestMemoryMessageStore;
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
 import org.apache.qpid.server.virtualhost.StandardVirtualHostFactory;
 import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.plugin.PluggableFactoryLoader;
 import org.apache.qpid.server.plugin.VirtualHostFactory;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 import org.apache.qpid.server.virtualhost.QueueExistsException;
@@ -82,23 +82,14 @@ public class BrokerTestHelper
     {
     }
 
-    public static VirtualHost createVirtualHost(VirtualHostConfiguration virtualHostConfiguration, VirtualHostRegistry virtualHostRegistry)
+    public static VirtualHost createVirtualHost(VirtualHostRegistry virtualHostRegistry, org.apache.qpid.server.model.VirtualHost modelVHost)
             throws Exception
     {
-        return createVirtualHost(virtualHostConfiguration, virtualHostRegistry, mock(org.apache.qpid.server.model.VirtualHost.class));
-    }
-
-    public static VirtualHost createVirtualHost(VirtualHostConfiguration virtualHostConfiguration, VirtualHostRegistry virtualHostRegistry, org.apache.qpid.server.model.VirtualHost modelVHost)
-            throws Exception
-    {
-        StatisticsGatherer statisticsGatherer = mock(StatisticsGatherer.class);
-        final VirtualHostFactory factory =
-                        virtualHostConfiguration == null ? new StandardVirtualHostFactory()
-                                                         : VirtualHostFactory.FACTORIES.get(virtualHostConfiguration.getType());
+        String hostType = modelVHost.getType();
+        VirtualHostFactory factory = new PluggableFactoryLoader<VirtualHostFactory>(VirtualHostFactory.class).get(hostType);
         VirtualHost host = factory.createVirtualHost(virtualHostRegistry,
-                statisticsGatherer,
+                mock(StatisticsGatherer.class),
                 new SecurityManager(mock(Broker.class), false),
-                virtualHostConfiguration,
                 modelVHost);
         if(virtualHostRegistry != null)
         {
@@ -107,29 +98,23 @@ public class BrokerTestHelper
         return host;
     }
 
-    public static VirtualHost createVirtualHost(VirtualHostConfiguration virtualHostConfiguration) throws Exception
-    {
-
-        return createVirtualHost(virtualHostConfiguration, new VirtualHostRegistry(new EventLogger()));
-    }
-
-    public static VirtualHost createVirtualHost(String name, VirtualHostRegistry virtualHostRegistry) throws Exception
-    {
-        VirtualHostConfiguration vhostConfig = createVirtualHostConfiguration(name);
-        return createVirtualHost(vhostConfig, virtualHostRegistry);
-    }
-
     public static VirtualHost createVirtualHost(String name) throws Exception
     {
-        VirtualHostConfiguration configuration = createVirtualHostConfiguration(name);
-        return createVirtualHost(configuration);
+        return createVirtualHost(name, new VirtualHostRegistry(new EventLogger()));
     }
 
-    private static VirtualHostConfiguration createVirtualHostConfiguration(String name) throws ConfigurationException
+    public static VirtualHost createVirtualHost(String name, VirtualHostRegistry virtualHostRegistry) throws Exception
     {
-        VirtualHostConfiguration vhostConfig = new VirtualHostConfiguration(name, new PropertiesConfiguration(), createBrokerMock());
-        vhostConfig.setMessageStoreClass(TestableMemoryMessageStore.class.getName());
-        return vhostConfig;
+        org.apache.qpid.server.model.VirtualHost virtualHost = mock(org.apache.qpid.server.model.VirtualHost.class);
+        when(virtualHost.getType()).thenReturn(StandardVirtualHostFactory.TYPE);
+        when(virtualHost.getAttribute(org.apache.qpid.server.model.VirtualHost.TYPE)).thenReturn(StandardVirtualHostFactory.TYPE);
+
+        Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+        messageStoreSettings.put(MessageStore.STORE_TYPE, TestableMemoryMessageStore.TYPE);
+
+        when(virtualHost.getMessageStoreSettings()).thenReturn(messageStoreSettings);
+        when(virtualHost.getName()).thenReturn(name);
+        return createVirtualHost(virtualHostRegistry, virtualHost);
     }
 
     public static AMQSessionModel createSession(int channelId, AMQConnectionModel connection)
@@ -189,5 +174,4 @@ public class BrokerTestHelper
         return queue;
     }
 
-
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java Tue Apr  1 10:35:33 2014
@@ -33,13 +33,16 @@ import org.apache.qpid.server.logging.Ev
 import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
 import org.apache.qpid.server.store.StoreException;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.exchange.ExchangeFactory;
 import org.apache.qpid.server.exchange.ExchangeRegistry;
+import org.apache.qpid.server.exchange.FanoutExchange;
 import org.apache.qpid.server.exchange.HeadersExchange;
 import org.apache.qpid.server.exchange.TopicExchange;
 import org.apache.qpid.server.model.Binding;
 import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.plugin.ExchangeType;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.QueueFactory;
@@ -60,19 +63,21 @@ import static org.mockito.Mockito.doAnsw
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-
 import static org.apache.qpid.server.model.VirtualHost.CURRENT_CONFIG_VERSION;
 
 public class DurableConfigurationRecovererTest extends QpidTestCase
 {
+    private static final String VIRTUAL_HOST_NAME = "test";
     private static final UUID QUEUE_ID = new UUID(0,0);
-    private static final UUID TOPIC_EXCHANGE_ID = new UUID(0,1);
-    private static final UUID DIRECT_EXCHANGE_ID = new UUID(0,2);
+    private static final UUID TOPIC_EXCHANGE_ID = UUIDGenerator.generateExchangeUUID(TopicExchange.TYPE.getDefaultExchangeName(), VIRTUAL_HOST_NAME);
+    private static final UUID DIRECT_EXCHANGE_ID = UUIDGenerator.generateExchangeUUID(DirectExchange.TYPE.getDefaultExchangeName(), VIRTUAL_HOST_NAME);
     private static final String CUSTOM_EXCHANGE_NAME = "customExchange";
 
     private DurableConfigurationRecoverer _durableConfigurationRecoverer;
-    private ExchangeImpl _directExchange;
-    private ExchangeImpl _topicExchange;
+    private ExchangeImpl<?> _directExchange;
+    private ExchangeImpl<?> _topicExchange;
+    private ExchangeImpl<?> _matchExchange;
+    private ExchangeImpl<?> _fanoutExchange;
     private VirtualHost _vhost;
     private DurableConfigurationStore _store;
     private ExchangeFactory _exchangeFactory;
@@ -84,21 +89,19 @@ public class DurableConfigurationRecover
     {
         super.setUp();
 
+        _exchangeFactory = mock(ExchangeFactory.class);
 
-        _directExchange = mock(ExchangeImpl.class);
-        when(_directExchange.getExchangeType()).thenReturn(DirectExchange.TYPE);
-
-
-        _topicExchange = mock(ExchangeImpl.class);
-        when(_topicExchange.getExchangeType()).thenReturn(TopicExchange.TYPE);
+        _directExchange = createAndRegisterDefaultExchangeWithFactory(DirectExchange.TYPE);
+        _topicExchange = createAndRegisterDefaultExchangeWithFactory(TopicExchange.TYPE);
+        _matchExchange = createAndRegisterDefaultExchangeWithFactory(HeadersExchange.TYPE);
+        _fanoutExchange = createAndRegisterDefaultExchangeWithFactory(FanoutExchange.TYPE);
 
-        AMQQueue queue = mock(AMQQueue.class);
+        AMQQueue<?> queue = mock(AMQQueue.class);
 
         _vhost = mock(VirtualHost.class);
+        when(_vhost.getName()).thenReturn(VIRTUAL_HOST_NAME);
 
         _exchangeRegistry = mock(ExchangeRegistry.class);
-        when(_exchangeRegistry.getExchange(eq(DIRECT_EXCHANGE_ID))).thenReturn(_directExchange);
-        when(_exchangeRegistry.getExchange(eq(TOPIC_EXCHANGE_ID))).thenReturn(_topicExchange);
 
         when(_vhost.getQueue(eq(QUEUE_ID))).thenReturn(queue);
 
@@ -166,7 +169,6 @@ public class DurableConfigurationRecover
                     }
                 });
 
-        _exchangeFactory = mock(ExchangeFactory.class);
 
 
         DurableConfiguredObjectRecoverer[] recoverers = {
@@ -182,12 +184,25 @@ public class DurableConfigurationRecover
         }
         _durableConfigurationRecoverer =
                 new DurableConfigurationRecoverer(_vhost.getName(), recovererMap,
-                                                  new DefaultUpgraderProvider(_vhost, _exchangeRegistry), new EventLogger());
+                                                  new DefaultUpgraderProvider(_vhost), new EventLogger());
 
         _store = mock(DurableConfigurationStore.class);
 
     }
 
+    private ExchangeImpl<?> createAndRegisterDefaultExchangeWithFactory(ExchangeType<?> exchangeType) throws AMQUnknownExchangeType, UnknownExchangeException
+    {
+        ExchangeImpl exchange = mock(ExchangeImpl.class);
+        when(exchange.getExchangeType()).thenReturn(exchangeType);
+        Map<String, Object> directExchangeAttrsWithId = new HashMap<String, Object>();
+        directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.ID, UUIDGenerator.generateExchangeUUID(exchangeType.getDefaultExchangeName(), VIRTUAL_HOST_NAME));
+        directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.DURABLE, true);
+        directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.TYPE, exchangeType.getType());
+        directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.NAME, exchangeType.getDefaultExchangeName());
+        when(_exchangeFactory.restoreExchange(directExchangeAttrsWithId)).thenReturn(exchange);
+        return exchange;
+    }
+
     public void testUpgradeEmptyStore() throws Exception
     {
         _durableConfigurationRecoverer.beginConfigurationRecovery(_store, 0);
@@ -273,12 +288,29 @@ public class DurableConfigurationRecover
             public ExchangeImpl answer(final InvocationOnMock invocation) throws Throwable
             {
                 Map arguments = attributesCaptor.getValue();
-                if(CUSTOM_EXCHANGE_NAME.equals(arguments.get(org.apache.qpid.server.model.Exchange.NAME))
+                String exchangeName = (String) arguments.get(org.apache.qpid.server.model.Exchange.NAME);
+                if(CUSTOM_EXCHANGE_NAME.equals(exchangeName)
                     && HeadersExchange.TYPE.getType().equals(arguments.get(org.apache.qpid.server.model.Exchange.TYPE))
-                    && customExchangeId.equals(arguments.get(org.apache.qpid.server.model.Exchange.ID)))
+                    && customExchangeId.equals((UUID) arguments.get(org.apache.qpid.server.model.Exchange.ID)))
                 {
                     return customExchange;
                 }
+                else if ("amq.topic".equals(exchangeName))
+                {
+                    return _topicExchange;
+                }
+                else if ("amq.direct".equals(exchangeName))
+                {
+                    return _directExchange;
+                }
+                else if ("amq.fanout".equals(exchangeName))
+                {
+                    return _fanoutExchange;
+                }
+                else if ("amq.match".equals(exchangeName))
+                {
+                    return _matchExchange;
+                }
                 else
                 {
                     return null;
@@ -406,12 +438,29 @@ public class DurableConfigurationRecover
             public ExchangeImpl answer(final InvocationOnMock invocation) throws Throwable
             {
                 Map arguments = attributesCaptor.getValue();
-                if(CUSTOM_EXCHANGE_NAME.equals(arguments.get(org.apache.qpid.server.model.Exchange.NAME))
+                String exchangeName = (String) arguments.get(org.apache.qpid.server.model.Exchange.NAME);
+                if(CUSTOM_EXCHANGE_NAME.equals(exchangeName)
                    && HeadersExchange.TYPE.getType().equals(arguments.get(org.apache.qpid.server.model.Exchange.TYPE))
                    && exchangeId.equals(arguments.get(org.apache.qpid.server.model.Exchange.ID)))
                 {
                     return customExchange;
                 }
+                else if ("amq.topic".equals(exchangeName))
+                {
+                    return _topicExchange;
+                }
+                else if ("amq.direct".equals(exchangeName))
+                {
+                    return _directExchange;
+                }
+                else if ("amq.fanout".equals(exchangeName))
+                {
+                    return _fanoutExchange;
+                }
+                else if ("amq.match".equals(exchangeName))
+                {
+                    return _matchExchange;
+                }
                 else
                 {
                     return null;

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java Tue Apr  1 10:35:33 2014
@@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualho
 import java.util.Collection;
 import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.connection.IConnectionRegistry;
 import org.apache.qpid.server.exchange.ExchangeImpl;
@@ -73,11 +72,6 @@ public class MockVirtualHost implements 
         return null;
     }
 
-    public VirtualHostConfiguration getConfiguration()
-    {
-        return null;
-    }
-
     public IConnectionRegistry getConnectionRegistry()
     {
         return null;
@@ -370,4 +364,10 @@ public class MockVirtualHost implements 
     {
         return null;
     }
+
+    @Override
+    public boolean getDefaultDeadLetterQueueEnabled()
+    {
+        return false;
+    }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory Tue Apr  1 10:35:33 2014
@@ -17,3 +17,4 @@
 # under the License.
 #
 org.apache.qpid.server.store.TestMemoryMessageStoreFactory
+org.apache.qpid.server.store.TestableMemoryMessageStoreFactory
\ No newline at end of file

Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java Tue Apr  1 10:35:33 2014
@@ -29,7 +29,6 @@ import java.util.Set;
 
 import javax.security.auth.Subject;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
@@ -64,7 +63,7 @@ public class DefaultAccessControl implem
         _aclFile = new File(fileName);
     }
 
-    DefaultAccessControl(RuleSet rs) throws ConfigurationException
+    DefaultAccessControl(RuleSet rs)
     {
         _ruleSet = rs;
         _eventLogger = rs;

Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java Tue Apr  1 10:35:33 2014
@@ -36,12 +36,6 @@ import org.apache.qpid.server.security.a
 
 import static org.mockito.Mockito.mock;
 
-/**
- * These tests check that the ACL file parsing works correctly.
- *
- * For each message that can be returned in a {@link ConfigurationException}, an ACL file is created that should trigger this
- * particular message.
- */
 public class PlainConfigurationTest extends TestCase
 {
     private PlainConfiguration writeACLConfig(String...aclData) throws Exception

Modified: qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java Tue Apr  1 10:35:33 2014
@@ -33,7 +33,6 @@ import javax.security.auth.Subject;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.qpid.server.connection.ConnectionPrincipal;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.EventLoggerProvider;
@@ -70,12 +69,12 @@ public class DefaultAccessControlTest ex
         _plugin = null;
     }
 
-    private void setUpGroupAccessControl() throws ConfigurationException
+    private void setUpGroupAccessControl()
     {
         configureAccessControl(createGroupRuleSet());
     }
 
-    private void configureAccessControl(final RuleSet rs) throws ConfigurationException
+    private void configureAccessControl(final RuleSet rs)
     {
         _plugin = new DefaultAccessControl(rs);
     }
@@ -100,7 +99,7 @@ public class DefaultAccessControlTest ex
     /**
      * ACL plugin must always abstain if there is no  subject attached to the thread.
      */
-    public void testNoSubjectAlwaysAbstains() throws ConfigurationException
+    public void testNoSubjectAlwaysAbstains()
     {
         setUpGroupAccessControl();
         final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
@@ -111,7 +110,7 @@ public class DefaultAccessControlTest ex
      * Tests that an allow rule expressed with a username allows an operation performed by a thread running
      * with the same username.
      */
-    public void testUsernameAllowsOperation() throws ConfigurationException
+    public void testUsernameAllowsOperation()
     {
         setUpGroupAccessControl();
         Subject.doAs(TestPrincipalUtils.createTestSubject("user1"), new PrivilegedAction<Object>()
@@ -130,7 +129,7 @@ public class DefaultAccessControlTest ex
      * Tests that an allow rule expressed with an <b>ACL groupname</b> allows an operation performed by a thread running
      * by a user who belongs to the same group..
      */
-    public void testGroupMembershipAllowsOperation() throws ConfigurationException
+    public void testGroupMembershipAllowsOperation()
     {
         setUpGroupAccessControl();
 
@@ -143,7 +142,7 @@ public class DefaultAccessControlTest ex
      * Tests that a deny rule expressed with a <b>groupname</b> denies an operation performed by a thread running
      * by a user who belongs to the same group.
      */
-    public void testGroupMembershipDeniesOperation() throws ConfigurationException
+    public void testGroupMembershipDeniesOperation()
     {
         setUpGroupAccessControl();
         authoriseAndAssertResult(Result.DENIED, "user3", DENIED_GROUP);
@@ -152,7 +151,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that the catch all deny denies the operation and logs with the logging actor.
      */
-    public void testCatchAllRuleDeniesUnrecognisedUsername() throws ConfigurationException
+    public void testCatchAllRuleDeniesUnrecognisedUsername()
     {
         setUpGroupAccessControl();
         Subject.doAs(TestPrincipalUtils.createTestSubject("unknown", "unkgroup1", "unkgroup2"),
@@ -179,7 +178,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that a grant access method rule allows any access operation to be performed on any component
      */
-    public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnAllComponents() throws ConfigurationException
+    public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnAllComponents()
     {
         final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
 
@@ -205,7 +204,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that a grant access method rule allows any access operation to be performed on a specified component
      */
-    public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+    public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnSpecifiedComponent()
     {
         final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
 
@@ -305,7 +304,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that a grant access method rule allows any access operation to be performed on a specified component
      */
-    public void testAuthoriseAccessMethodWhenSpecifiedAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+    public void testAuthoriseAccessMethodWhenSpecifiedAccessOperationsAllowedOnSpecifiedComponent()
     {
         final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
 
@@ -342,7 +341,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that granting of all method rights on a method allows a specified operation to be performed on any component
      */
-    public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnSpecifiedMethodForAllComponents() throws ConfigurationException
+    public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnSpecifiedMethodForAllComponents()
     {
         final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
 
@@ -381,7 +380,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that granting of all method rights allows any operation to be performed on any component
      */
-    public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnAllMethodsInAllComponents() throws ConfigurationException
+    public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnAllMethodsInAllComponents()
     {
         final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
 
@@ -419,7 +418,7 @@ public class DefaultAccessControlTest ex
     /**
      * Tests that granting of access method rights with mask allows matching operations to be performed on the specified component
      */
-    public void testAuthoriseAccessMethodWhenMatchingAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+    public void testAuthoriseAccessMethodWhenMatchingAccessOperationsAllowedOnSpecifiedComponent()
     {
         final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
 

Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java Tue Apr  1 10:35:33 2014
@@ -32,14 +32,13 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.store.AbstractJDBCMessageStore;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.Event;
-import org.apache.qpid.server.store.EventListener;
 import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreConstants;
 import org.apache.qpid.server.store.StoreException;
 import org.apache.qpid.util.FileUtils;
 
@@ -124,19 +123,17 @@ public class DerbyMessageStore extends A
     }
 
     @Override
-    protected void implementationSpecificConfiguration(String name,
-                                                       VirtualHost virtualHost)
+    protected void implementationSpecificConfiguration(String name, Map<String, Object> messageStoreSettings)
             throws ClassNotFoundException
     {
         //Update to pick up QPID_WORK and use that as the default location not just derbyDB
-
         _driverClass = (Class<Driver>) Class.forName(SQL_DRIVER_NAME);
 
-        String defaultPath = System.getProperty("QPID_WORK") + File.separator + "derbyDB";
-        String databasePath = isConfigStoreOnly() ? (String) virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH) : (String) virtualHost.getAttribute(VirtualHost.STORE_PATH);
+        String databasePath =  (String) messageStoreSettings.get(MessageStore.STORE_PATH);;
+
         if(databasePath == null)
         {
-            databasePath = defaultPath;
+            databasePath = System.getProperty("QPID_WORK") + File.separator + "derbyDB";
         }
 
         if(!MEMORY_STORE_LOCATION.equals(databasePath))
@@ -154,8 +151,8 @@ public class DerbyMessageStore extends A
 
         _storeLocation = databasePath;
 
-        Object overfullAttr = virtualHost.getAttribute(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE);
-        Object underfullAttr = virtualHost.getAttribute(MessageStoreConstants.UNDERFULL_SIZE_ATTRIBUTE);
+        Object overfullAttr = messageStoreSettings.get(MessageStore.OVERFULL_SIZE);
+        Object underfullAttr = messageStoreSettings.get(MessageStore.UNDERFULL_SIZE);
 
         _persistentSizeHighThreshold = overfullAttr == null ? -1l :
                                        overfullAttr instanceof Number ? ((Number) overfullAttr).longValue() : Long.parseLong(overfullAttr.toString());
@@ -170,16 +167,7 @@ public class DerbyMessageStore extends A
         //FIXME this the _vhost name should not be added here, but derby wont use an empty directory as was possibly just created.
         _connectionURL = "jdbc:derby" + (databasePath.equals(MEMORY_STORE_LOCATION) ? databasePath: ":" + databasePath+ "/") + name + ";create=true";
 
-
-
-        _eventManager.addEventListener(new EventListener()
-                                        {
-                                            @Override
-                                            public void event(Event event)
-                                            {
-                                                setInitialSize();
-                                            }
-                                        }, Event.BEFORE_ACTIVATE);
+        setInitialSize();
 
     }
 

Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java Tue Apr  1 10:35:33 2014
@@ -20,9 +20,8 @@
  */
 package org.apache.qpid.server.store.derby;
 
-import java.util.Collections;
 import java.util.Map;
-import org.apache.commons.configuration.Configuration;
+
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory;
 import org.apache.qpid.server.plugin.MessageStoreFactory;
@@ -51,31 +50,30 @@ public class DerbyMessageStoreFactory im
     }
 
     @Override
-    public Map<String, Object> convertStoreConfiguration(Configuration configuration)
-    {
-        return Collections.emptyMap();
-    }
-
-
-    @Override
     public void validateAttributes(Map<String, Object> attributes)
     {
-        if(getType().equals(attributes.get(VirtualHost.STORE_TYPE)))
+        @SuppressWarnings("unchecked")
+        Map<String, Object> messageStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.MESSAGE_STORE_SETTINGS);
+
+        if(getType().equals(messageStoreSettings.get(MessageStore.STORE_TYPE)))
         {
-            Object storePath = attributes.get(VirtualHost.STORE_PATH);
+            Object storePath = messageStoreSettings.get(MessageStore.STORE_PATH);
             if(!(storePath instanceof String))
             {
-                throw new IllegalArgumentException("Attribute '"+ VirtualHost.STORE_PATH
+                throw new IllegalArgumentException("Setting '"+ MessageStore.STORE_PATH
                                                                +"' is required and must be of type String.");
 
             }
         }
-        if(getType().equals(attributes.get(VirtualHost.CONFIG_STORE_TYPE)))
+
+        @SuppressWarnings("unchecked")
+        Map<String, Object> configurationStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.CONFIGURATION_STORE_SETTINGS);
+        if(configurationStoreSettings != null && getType().equals(configurationStoreSettings.get(DurableConfigurationStore.STORE_TYPE)))
         {
-            Object storePath = attributes.get(VirtualHost.CONFIG_STORE_PATH);
+            Object storePath = configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH);
             if(!(storePath instanceof String))
             {
-                throw new IllegalArgumentException("Attribute '"+ VirtualHost.CONFIG_STORE_PATH
+                throw new IllegalArgumentException("Setting '"+ DurableConfigurationStore.STORE_PATH
                                                                +"' is required and must be of type String.");
 
             }

Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java Tue Apr  1 10:35:33 2014
@@ -25,48 +25,10 @@ import org.apache.qpid.server.store.Abst
 public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase
 {
 
-    private DerbyMessageStore _derbyMessageStore;
-
-    @Override
-    protected DerbyMessageStore createMessageStore() throws Exception
-    {
-        createStoreIfNecessary();
-        return _derbyMessageStore;
-    }
-
-    @Override
-    protected void closeMessageStore() throws Exception
-    {
-        closeStoreIfNecessary();
-    }
-
-    private void createStoreIfNecessary()
-    {
-        if(_derbyMessageStore == null)
-        {
-            _derbyMessageStore = new DerbyMessageStore();
-        }
-    }
-
     @Override
     protected DerbyMessageStore createConfigStore() throws Exception
     {
-        createStoreIfNecessary();
-        return _derbyMessageStore;
+        return new DerbyMessageStore();
     }
 
-    @Override
-    protected void closeConfigStore() throws Exception
-    {
-        closeStoreIfNecessary();
-    }
-
-    private void closeStoreIfNecessary() throws Exception
-    {
-        if (_derbyMessageStore != null)
-        {
-            _derbyMessageStore.close();
-            _derbyMessageStore = null;
-        }
-    }
 }

Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java Tue Apr  1 10:35:33 2014
@@ -20,15 +20,13 @@
  */
 package org.apache.qpid.server.store.derby;
 
+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.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);
@@ -50,17 +48,21 @@ public class DerbyMessageStoreQuotaEvent
     }
 
     @Override
-    protected void applyStoreSpecificConfiguration(VirtualHost vhost)
+    protected MessageStore createStore() throws Exception
     {
-        _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);
+        return new DerbyMessageStore();
     }
 
     @Override
-    protected MessageStore createStore() throws Exception
+    protected Map<String, Object> createStoreSettings(String storeLocation)
     {
-        return new DerbyMessageStore();
+        _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;
     }
+
 }

Modified: qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java Tue Apr  1 10:35:33 2014
@@ -20,16 +20,15 @@
  */
 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.util.FileUtils;
 
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
 public class DerbyMessageStoreTest extends MessageStoreTestCase
 {
     private String _storeLocation;
@@ -52,7 +51,7 @@ public class DerbyMessageStoreTest exten
         File location = new File(_storeLocation);
         assertTrue("Store does not exist at " + _storeLocation, location.exists());
 
-        getStore().close();
+        getStore().closeMessageStore();
         assertTrue("Store does not exist at " + _storeLocation, location.exists());
 
         getStore().onDelete();
@@ -60,11 +59,13 @@ public class DerbyMessageStoreTest exten
     }
 
     @Override
-    protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
+    protected Map<String, Object> getStoreSettings() throws Exception
     {
         _storeLocation = TMP_FOLDER + File.separator + getTestName();
-        when(virtualHost.getAttribute(eq(VirtualHost.STORE_PATH))).thenReturn(_storeLocation);
         deleteStoreIfExists();
+        Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+        messageStoreSettings.put(MessageStore.STORE_PATH, _storeLocation);
+        return messageStoreSettings;
     }
 
     private void deleteStoreIfExists()

Modified: qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java Tue Apr  1 10:35:33 2014
@@ -20,58 +20,38 @@
  */
 package org.apache.qpid.server.store.jdbc.bonecp;
 
-import com.jolbox.bonecp.BoneCP;
-import com.jolbox.bonecp.BoneCPConfig;
 import java.sql.Connection;
 import java.sql.SQLException;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+
 import org.apache.qpid.server.store.jdbc.ConnectionProvider;
+import org.apache.qpid.server.util.MapValueConverter;
+
+import com.jolbox.bonecp.BoneCP;
+import com.jolbox.bonecp.BoneCPConfig;
 
 public class BoneCPConnectionProvider implements ConnectionProvider
 {
+    public static final String PARTITION_COUNT = "partitionCount";
+    public static final String MAX_CONNECTIONS_PER_PARTITION = "maxConnectionsPerPartition";
+    public static final String MIN_CONNECTIONS_PER_PARTITION = "minConnectionsPerPartition";
+
     public static final int DEFAULT_MIN_CONNECTIONS_PER_PARTITION = 5;
     public static final int DEFAULT_MAX_CONNECTIONS_PER_PARTITION = 10;
     public static final int DEFAULT_PARTITION_COUNT = 4;
+
     private final BoneCP _connectionPool;
 
-    public BoneCPConnectionProvider(String connectionUrl, VirtualHost virtualHost) throws SQLException
+    public BoneCPConnectionProvider(String connectionUrl, Map<String, Object> storeSettings) throws SQLException
     {
         BoneCPConfig config = new BoneCPConfig();
         config.setJdbcUrl(connectionUrl);
-
-
-        config.setMinConnectionsPerPartition(getIntegerAttribute(virtualHost, "minConnectionsPerPartition", DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
-        config.setMaxConnectionsPerPartition(getIntegerAttribute(virtualHost, "maxConnectionsPerPartition", DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
-        config.setPartitionCount(getIntegerAttribute(virtualHost, "partitionCount",DEFAULT_PARTITION_COUNT));
+        config.setMinConnectionsPerPartition(MapValueConverter.getIntegerAttribute(MIN_CONNECTIONS_PER_PARTITION, storeSettings, DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
+        config.setMaxConnectionsPerPartition(MapValueConverter.getIntegerAttribute(MAX_CONNECTIONS_PER_PARTITION, storeSettings, DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
+        config.setPartitionCount(MapValueConverter.getIntegerAttribute(PARTITION_COUNT, storeSettings, DEFAULT_PARTITION_COUNT));
         _connectionPool = new BoneCP(config);
     }
 
-    private int getIntegerAttribute(VirtualHost virtualHost, String attributeName, int defaultVal)
-    {
-        Object attrValue = virtualHost.getAttribute(attributeName);
-        if(attrValue != null)
-        {
-            if(attrValue instanceof Number)
-            {
-                return ((Number) attrValue).intValue();
-            }
-            else if(attrValue instanceof String)
-            {
-                try
-                {
-                    return Integer.parseInt((String)attrValue);
-                }
-                catch (NumberFormatException e)
-                {
-                    return defaultVal;
-                }
-            }
-
-        }
-        return defaultVal;
-    }
-
     @Override
     public Connection getConnection() throws SQLException
     {

Modified: qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java (original)
+++ qpid/trunk/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java Tue Apr  1 10:35:33 2014
@@ -21,8 +21,8 @@
 package org.apache.qpid.server.store.jdbc.bonecp;
 
 import java.sql.SQLException;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+
 import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
 import org.apache.qpid.server.store.jdbc.ConnectionProvider;
 
@@ -35,9 +35,9 @@ public class BoneCPConnectionProviderFac
     }
 
     @Override
-    public ConnectionProvider getConnectionProvider(String connectionUrl, VirtualHost virtualHost)
+    public ConnectionProvider getConnectionProvider(String connectionUrl, Map<String, Object> storeSettings)
             throws SQLException
     {
-        return new BoneCPConnectionProvider(connectionUrl, virtualHost);
+        return new BoneCPConnectionProvider(connectionUrl, storeSettings);
     }
 }



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