qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1584365 [11/15] - in /qpid/branches/java-broker-config-store-changes/qpid/java: ./ bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/ja...
Date Thu, 03 Apr 2014 19:59:01 GMT
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactoryTest.java Thu Apr  3 19:58:53 2014
@@ -32,6 +32,7 @@ import java.util.UUID;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.PreferencesProvider;
 import org.apache.qpid.server.util.BrokerTestHelper;
 import org.apache.qpid.test.utils.QpidTestCase;
@@ -80,7 +81,8 @@ public class FileSystemPreferencesProvid
         try
         {
             attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath());
-            PreferencesProvider provider = _factory.createInstance(id, attributes, _authenticationProvider);
+            attributes.put(ConfiguredObject.ID, id);
+            PreferencesProvider provider = _factory.create(attributes, _authenticationProvider);
             assertNotNull("Preferences provider was not instantiated", provider);
             assertEquals("Unexpected name", "test-provider", provider.getName());
             assertEquals("Unexpected id", id, provider.getId());
@@ -104,7 +106,8 @@ public class FileSystemPreferencesProvid
         try
         {
             attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath());
-            _factory.createInstance(id, attributes, _authenticationProvider);
+            attributes.put(ConfiguredObject.ID, id);
+            _factory.create(attributes, _authenticationProvider);
         }
         catch (IllegalConfigurationException e)
         {
@@ -123,7 +126,8 @@ public class FileSystemPreferencesProvid
         try
         {
             attributes.put(FileSystemPreferencesProvider.PATH, file.getAbsolutePath());
-            PreferencesProvider provider = _factory.createInstance(id, attributes, _authenticationProvider);
+            attributes.put(ConfiguredObject.ID, id);
+            PreferencesProvider provider = _factory.create(attributes, _authenticationProvider);
             assertNotNull("Preferences provider was not recovered", provider);
             assertEquals("Unexpected name", "test-provider", provider.getName());
             assertEquals("Unexpected id", id, provider.getId());

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java Thu Apr  3 19:58:53 2014
@@ -97,7 +97,7 @@ public class FileSystemPreferencesProvid
             Map<String, Object> attributes = new HashMap<String, Object>();
             attributes.put(FileSystemPreferencesProvider.PATH, nonExistingFile.getAbsolutePath());
             attributes.put(FileSystemPreferencesProvider.NAME, getTestName());
-            _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider, _broker.getTaskExecutor());
+            _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider);
             _preferencesProvider.createStoreIfNotExist();
             assertEquals(State.INITIALISING, _preferencesProvider.getState());
             assertTrue("Preferences file was not created", nonExistingFile.exists());
@@ -118,7 +118,7 @@ public class FileSystemPreferencesProvid
             Map<String, Object> attributes = new HashMap<String, Object>();
             attributes.put(FileSystemPreferencesProvider.NAME, getTestName());
             attributes.put(FileSystemPreferencesProvider.PATH, emptyPrefsFile.getAbsolutePath());
-            _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider, _broker.getTaskExecutor());
+            _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider);
             assertEquals(State.INITIALISING, _preferencesProvider.getState());
         }
         finally
@@ -278,7 +278,7 @@ public class FileSystemPreferencesProvid
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(FileSystemPreferencesProvider.PATH, _preferencesFile.getAbsolutePath());
         attributes.put(FileSystemPreferencesProvider.NAME, "test");
-        return _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider, _broker.getTaskExecutor());
+        return _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes, _authenticationProvider);
     }
 
     private void assertUser1Preferences(Map<String, Object> preferences1)

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/PortFactoryTest.java Thu Apr  3 19:58:53 2014
@@ -43,6 +43,8 @@ import org.apache.qpid.server.model.Port
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.Transport;
 import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.model.port.AmqpPort;
+import org.apache.qpid.server.model.port.PortFactory;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class PortFactoryTest extends QpidTestCase
@@ -63,6 +65,7 @@ public class PortFactoryTest extends Qpi
     private AuthenticationProvider _authProvider = mock(AuthenticationProvider.class);
     private PortFactory _portFactory;
 
+
     @Override
     protected void setUp() throws Exception
     {
@@ -83,7 +86,13 @@ public class PortFactoryTest extends Qpi
 
     public void testDefaultProtocols()
     {
-        Collection<Protocol> protocols = _portFactory.getDefaultProtocols();
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(Port.PORT, 1);
+        attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName);
+        Port port = _portFactory.createPort(_portId, _broker, attributes);
+
+        Collection<Protocol> protocols = port.getProtocols();
+
         EnumSet<Protocol> expected = EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1, Protocol.AMQP_0_10,
                 Protocol.AMQP_1_0);
         assertEquals("Unexpected protocols", new HashSet<Protocol>(expected), new HashSet<Protocol>(protocols));
@@ -93,8 +102,14 @@ public class PortFactoryTest extends Qpi
     {
         setTestSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES, Protocol.AMQP_1_0.name() + ","
                 + Protocol.AMQP_0_10.name());
-        _portFactory = new PortFactory();
-        Collection<Protocol> protocols = _portFactory.getDefaultProtocols();
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(Port.PORT, 1);
+        attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName);
+        Port port = _portFactory.createPort(_portId, _broker, attributes);
+
+        Collection<Protocol> protocols = port.getProtocols();
+
         EnumSet<Protocol> expected = EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1);
         assertEquals("Unexpected protocols", new HashSet<Protocol>(expected), new HashSet<Protocol>(protocols));
     }
@@ -105,8 +120,14 @@ public class PortFactoryTest extends Qpi
                 + Protocol.AMQP_0_10.name() + "," + Protocol.AMQP_0_9_1.name());
         setTestSystemProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES, Protocol.AMQP_0_10.name() + ","
                 + Protocol.AMQP_0_9_1.name());
-        _portFactory = new PortFactory();
-        Collection<Protocol> protocols = _portFactory.getDefaultProtocols();
+
+        Map<String, Object> attributes = new HashMap<String, Object>();
+        attributes.put(Port.PORT, 1);
+        attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName);
+        Port port = _portFactory.createPort(_portId, _broker, attributes);
+
+        Collection<Protocol> protocols = port.getProtocols();
+
         EnumSet<Protocol> expected = EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1, Protocol.AMQP_0_10);
         assertEquals("Unexpected protocols", new HashSet<Protocol>(expected), new HashSet<Protocol>(protocols));
     }
@@ -119,10 +140,11 @@ public class PortFactoryTest extends Qpi
         Port port = _portFactory.createPort(_portId, _broker, attributes);
 
         assertNotNull(port);
-        assertTrue(port instanceof AmqpPortAdapter);
+        assertTrue(port instanceof AmqpPort);
         assertEquals("Unexpected port", 1, port.getPort());
         assertEquals("Unexpected transports", Collections.singleton(PortFactory.DEFAULT_TRANSPORT), port.getTransports());
-        assertEquals("Unexpected protocols", _portFactory.getDefaultProtocols(), port.getProtocols());
+        assertEquals("Unexpected protocols", EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1, Protocol.AMQP_0_10,
+                                                        Protocol.AMQP_1_0), port.getProtocols());
         assertEquals("Unexpected send buffer size", PortFactory.DEFAULT_AMQP_SEND_BUFFER_SIZE,
                 port.getAttribute(Port.SEND_BUFFER_SIZE));
         assertEquals("Unexpected receive buffer size", PortFactory.DEFAULT_AMQP_RECEIVE_BUFFER_SIZE,
@@ -252,7 +274,7 @@ public class PortFactoryTest extends Qpi
         Port port = _portFactory.createPort(_portId, _broker, _attributes);
 
         assertNotNull(port);
-        assertTrue(port instanceof AmqpPortAdapter);
+        assertTrue(port instanceof AmqpPort);
         assertEquals(_portId, port.getId());
         assertEquals(_portNumber, port.getPort());
         if(useSslTransport)
@@ -285,7 +307,7 @@ public class PortFactoryTest extends Qpi
         Port port = _portFactory.createPort(_portId, _broker, _attributes);
 
         assertNotNull(port);
-        assertFalse("Port should be a PortAdapter, not its AMQP-specific subclass", port instanceof AmqpPortAdapter);
+        assertFalse("Port should be a PortAdapter, not its AMQP-specific subclass", port instanceof AmqpPort);
         assertEquals(_portId, port.getId());
         assertEquals(_portNumber, port.getPort());
         assertEquals(_tcpTransportSet, port.getTransports());
@@ -310,7 +332,7 @@ public class PortFactoryTest extends Qpi
         Port port = _portFactory.createPort(_portId, _broker, _attributes);
 
         assertNotNull(port);
-        assertFalse("Port should be a PortAdapter, not its AMQP-specific subclass", port instanceof AmqpPortAdapter);
+        assertFalse("Port should be a PortAdapter, not its AMQP-specific subclass", port instanceof AmqpPort);
         assertEquals(_portId, port.getId());
         assertEquals(_portNumber, port.getPort());
         assertEquals(Collections.singleton(PortFactory.DEFAULT_TRANSPORT), port.getTransports());

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/configuration/ConfigurationEntryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/configuration/ConfigurationEntryTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/configuration/ConfigurationEntryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/configuration/ConfigurationEntryTest.java Thu Apr  3 19:58:53 2014
@@ -35,6 +35,7 @@ import java.util.UUID;
 import junit.framework.TestCase;
 
 import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryImpl;
 import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Port;
@@ -46,11 +47,11 @@ public class ConfigurationEntryTest exte
     {
         ConfigurationEntryStore store = mock(ConfigurationEntryStore.class);
 
-        ConfigurationEntry virtualHostEntry1 = new ConfigurationEntry(UUID.randomUUID(), VirtualHost.class.getSimpleName(),
+        ConfigurationEntry virtualHostEntry1 = new ConfigurationEntryImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(),
                 Collections.<String, Object> emptyMap(), Collections.<UUID> emptySet(), store);
-        ConfigurationEntry virtualHostEntry2 = new ConfigurationEntry(UUID.randomUUID(), VirtualHost.class.getSimpleName(),
+        ConfigurationEntry virtualHostEntry2 = new ConfigurationEntryImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(),
                 Collections.<String, Object> emptyMap(), Collections.<UUID> emptySet(), store);
-        ConfigurationEntry portEntry = new ConfigurationEntry(UUID.randomUUID(), Port.class.getSimpleName(),
+        ConfigurationEntry portEntry = new ConfigurationEntryImpl(UUID.randomUUID(), Port.class.getSimpleName(),
                 Collections.<String, Object> emptyMap(), Collections.<UUID> emptySet(), store);
 
         when(store.getEntry(virtualHostEntry1.getId())).thenReturn(virtualHostEntry1);
@@ -61,7 +62,7 @@ public class ConfigurationEntryTest exte
         childrenIds.add(virtualHostEntry1.getId());
         childrenIds.add(virtualHostEntry2.getId());
         childrenIds.add(portEntry.getId());
-        ConfigurationEntry parentEntry = new ConfigurationEntry(UUID.randomUUID(), Broker.class.getSimpleName(),
+        ConfigurationEntry parentEntry = new ConfigurationEntryImpl(UUID.randomUUID(), Broker.class.getSimpleName(),
                 Collections.<String, Object> emptyMap(), childrenIds, store);
 
         Map<String, Collection<ConfigurationEntry>> children = parentEntry.getChildren();
@@ -81,11 +82,11 @@ public class ConfigurationEntryTest exte
         ConfigurationEntryStore store = mock(ConfigurationEntryStore.class);
 
         UUID id = UUID.randomUUID();
-        ConfigurationEntry entry1 = new ConfigurationEntry(id, VirtualHost.class.getSimpleName(),
+        ConfigurationEntry entry1 = new ConfigurationEntryImpl(id, VirtualHost.class.getSimpleName(),
                 Collections.<String, Object> emptyMap(), Collections.singleton(UUID.randomUUID()), store);
-        ConfigurationEntry entry2 = new ConfigurationEntry(id, VirtualHost.class.getSimpleName(),
+        ConfigurationEntry entry2 = new ConfigurationEntryImpl(id, VirtualHost.class.getSimpleName(),
                 Collections.<String, Object> emptyMap(), Collections.singleton(UUID.randomUUID()), store);
-        ConfigurationEntry entryWithDifferentId = new ConfigurationEntry(UUID.randomUUID(),
+        ConfigurationEntry entryWithDifferentId = new ConfigurationEntryImpl(UUID.randomUUID(),
                 VirtualHost.class.getSimpleName(), Collections.<String, Object> emptyMap(), Collections.singleton(UUID.randomUUID()), store);
 
         assertTrue(entry1.hashCode() == entry2.hashCode());
@@ -100,29 +101,29 @@ public class ConfigurationEntryTest exte
         Map<String, Object> attributes1 = new HashMap<String, Object>();
         attributes1.put(VirtualHost.NAME, "name1");
         Set<UUID> childrenIds = Collections.singleton(UUID.randomUUID());
-        ConfigurationEntry entry1 = new ConfigurationEntry(id, VirtualHost.class.getSimpleName(), attributes1,
+        ConfigurationEntry entry1 = new ConfigurationEntryImpl(id, VirtualHost.class.getSimpleName(), attributes1,
                 childrenIds, store);
 
         Map<String, Object> attributes2 = new HashMap<String, Object>();
         attributes2.put(VirtualHost.NAME, "name2");
 
-        ConfigurationEntry entry2 = new ConfigurationEntry(id, VirtualHost.class.getSimpleName(), attributes1,
+        ConfigurationEntry entry2 = new ConfigurationEntryImpl(id, VirtualHost.class.getSimpleName(), attributes1,
                 childrenIds, store);
-        ConfigurationEntry entryWithDifferentId = new ConfigurationEntry(UUID.randomUUID(),
+        ConfigurationEntry entryWithDifferentId = new ConfigurationEntryImpl(UUID.randomUUID(),
                 VirtualHost.class.getSimpleName(), attributes1, childrenIds, store);
 
         assertTrue(entry1.equals(entry2));
         assertFalse("Entries should be different because of different IDs", entry1.equals(entryWithDifferentId));
 
-        ConfigurationEntry entryWithDifferentChildId = new ConfigurationEntry(id,
+        ConfigurationEntry entryWithDifferentChildId = new ConfigurationEntryImpl(id,
                 VirtualHost.class.getSimpleName(), attributes1, Collections.singleton(UUID.randomUUID()), store);
         assertFalse("Entries should be different because of different children", entry1.equals(entryWithDifferentChildId));
 
-        ConfigurationEntry entryWithDifferentName = new ConfigurationEntry(id,
+        ConfigurationEntry entryWithDifferentName = new ConfigurationEntryImpl(id,
                 VirtualHost.class.getSimpleName(), attributes2, childrenIds, store);
         assertFalse("Entries should be different because of different attributes", entry1.equals(entryWithDifferentName));
 
-        ConfigurationEntry entryWithDifferentType = new ConfigurationEntry(id,
+        ConfigurationEntry entryWithDifferentType = new ConfigurationEntryImpl(id,
                 Broker.class.getSimpleName(), attributes1, childrenIds, store);
         assertFalse("Entries should be different because of different types", entry1.equals(entryWithDifferentType));
     }

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java Thu Apr  3 19:58:53 2014
@@ -33,8 +33,6 @@ import java.util.UUID;
 
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.server.configuration.QueueConfiguration;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.exchange.DefaultExchangeFactory;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.logging.EventLogger;
@@ -56,7 +54,6 @@ public class AMQQueueFactoryTest extends
     private VirtualHost _virtualHost;
     private AMQQueueFactory _queueFactory;
     private List<AMQQueue> _queues;
-    private QueueConfiguration _queueConfiguration;
 
     @Override
     public void setUp() throws Exception
@@ -67,12 +64,8 @@ public class AMQQueueFactoryTest extends
 
         _virtualHost = mock(VirtualHost.class);
         when(_virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class));
-
-        VirtualHostConfiguration vhostConfig = mock(VirtualHostConfiguration.class);
-        when(_virtualHost.getConfiguration()).thenReturn(vhostConfig);
         when(_virtualHost.getEventLogger()).thenReturn(new EventLogger());
-        _queueConfiguration = mock(QueueConfiguration.class);
-        when(vhostConfig.getQueueConfiguration(anyString())).thenReturn(_queueConfiguration);
+
         DurableConfigurationStore store = mock(DurableConfigurationStore.class);
         when(_virtualHost.getDurableConfigurationStore()).thenReturn(store);
 
@@ -284,15 +277,14 @@ public class AMQQueueFactoryTest extends
         String dlExchangeName = queueName + DefaultExchangeFactory.DEFAULT_DLE_NAME_SUFFIX;
         String dlQueueName = queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX;
 
-        when(_queueConfiguration.getMaxDeliveryCount()).thenReturn(5);
-        when(_queueConfiguration.isDeadLetterQueueEnabled()).thenReturn(true);
-
         assertNull("The DLQ should not yet exist", _virtualHost.getQueue(dlQueueName));
         assertNull("The alternate exchange should not yet exist", _virtualHost.getExchange(dlExchangeName));
 
         Map<String,Object> attributes = new HashMap<String, Object>();
         attributes.put(Queue.ID, UUID.randomUUID());
         attributes.put(Queue.NAME, queueName);
+        attributes.put(Queue.CREATE_DLQ_ON_CREATION, true);
+        attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 5);
 
         AMQQueue queue = _queueFactory.createQueue(attributes);
 
@@ -501,19 +493,16 @@ public class AMQQueueFactoryTest extends
         }
     }
 
-    public void testMessageGroupFromConfig() throws Exception
+    public void testMessageGroupQueue() throws Exception
     {
 
-        Map<String,String> arguments = new HashMap<String, String>();
-
-        arguments.put(QueueArgumentsConverter.QPID_GROUP_HEADER_KEY,"mykey");
-        arguments.put(QueueArgumentsConverter.QPID_SHARED_MSG_GROUP,"1");
-
-        QueueConfiguration qConf = mock(QueueConfiguration.class);
-        when(qConf.getArguments()).thenReturn(arguments);
-        when(qConf.getName()).thenReturn("test");
+        Map<String,Object> attributes = new HashMap<String, Object>();
+        attributes.put(Queue.ID, UUID.randomUUID());
+        attributes.put(Queue.NAME, getTestName());
+        attributes.put(Queue.MESSAGE_GROUP_KEY,"mykey");
+        attributes.put(Queue.MESSAGE_GROUP_SHARED_GROUPS, true);
 
-        AMQQueue queue = _queueFactory.createAMQQueueImpl(qConf);
+        AMQQueue queue = _queueFactory.createQueue(attributes);
         assertEquals("mykey", queue.getAttribute(Queue.MESSAGE_GROUP_KEY));
         assertEquals(Boolean.TRUE, queue.getAttribute(Queue.MESSAGE_GROUP_SHARED_GROUPS));
     }

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java Thu Apr  3 19:58:53 2014
@@ -28,8 +28,8 @@ import org.apache.qpid.server.message.AM
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.model.Queue;
-
 import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.util.BrokerTestHelper;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.test.utils.QpidTestCase;
 
@@ -49,6 +49,7 @@ public class PriorityQueueListTest exten
 
     protected void setUp()
     {
+        BrokerTestHelper.setUp();
         QueueEntry[] entries = new QueueEntry[PRIORITIES.length];
         Map<String,Object> queueAttributes = new HashMap<String, Object>();
         queueAttributes.put(Queue.ID, UUID.randomUUID());
@@ -81,6 +82,19 @@ public class PriorityQueueListTest exten
         _priority5message2 = entries[2];
     }
 
+    @Override
+    public void tearDown() throws Exception
+    {
+        try
+        {
+            super.tearDown();
+        }
+        finally
+        {
+            BrokerTestHelper.tearDown();
+        }
+    }
+
     public void testPriorityQueueEntryCompareToItself()
     {
         //check messages compare to themselves properly

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/PlainPasswordFileAuthenticationManagerFactoryTest.java Thu Apr  3 19:58:53 2014
@@ -35,7 +35,8 @@ import org.apache.qpid.server.security.a
 
 public class PlainPasswordFileAuthenticationManagerFactoryTest extends  TestCase
 {
-    AuthenticationManagerFactory _factory = new PlainPasswordFileAuthenticationManagerFactory();
+
+    PlainPasswordFileAuthenticationManagerFactory _factory = new PlainPasswordFileAuthenticationManagerFactory();
     private Map<String, Object> _configuration = new HashMap<String, Object>();
     private File _emptyPasswordFile;
     private Broker _broker = mock(Broker.class);
@@ -55,7 +56,7 @@ public class PlainPasswordFileAuthentica
         _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE);
         _configuration.put("path", _emptyPasswordFile.getAbsolutePath());
 
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
+        AuthenticationManager manager = _factory.create(_configuration, _broker);
         assertNotNull(manager);
         assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
         assertTrue(((PrincipalDatabaseAuthenticationManager)manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
@@ -70,33 +71,20 @@ public class PlainPasswordFileAuthentica
         _configuration.put("path", _emptyPasswordFile.getAbsolutePath());
 
 
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
+        AuthenticationManager manager = _factory.create(_configuration, _broker);
 
         assertNotNull(manager);
         assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
         assertTrue(((PrincipalDatabaseAuthenticationManager)manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
     }
 
-    public void testReturnsNullWhenNoConfig() throws Exception
-    {
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
-        assertNull(manager);
-    }
-
-    public void testReturnsNullWhenConfigForOtherAuthManagerType() throws Exception
-    {
-        _configuration.put(AuthenticationProvider.TYPE, "other-auth-manager");
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
-        assertNull(manager);
-    }
-
     public void testThrowsExceptionWhenConfigForPlainPDImplementationNoPasswordFileValueSpecified() throws Exception
     {
         _configuration.put(AuthenticationProvider.TYPE, PlainPasswordFileAuthenticationManagerFactory.PROVIDER_TYPE);
 
         try
         {
-            AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
+            AuthenticationManager manager = _factory.create(_configuration, _broker);
             fail("No authentication manager should be created");
         }
         catch (IllegalArgumentException e)

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/ScramSHA1AuthenticationManagerTest.java Thu Apr  3 19:58:53 2014
@@ -58,7 +58,7 @@ public class ScramSHA1AuthenticationMana
         final Map<String, Object> attributesMap = new HashMap<String, Object>();
         attributesMap.put(AuthenticationProvider.NAME, getTestName());
         attributesMap.put(AuthenticationProvider.ID, UUID.randomUUID());
-        _authManager = new ScramSHA1AuthenticationManager(_broker, Collections.<String,Object>emptyMap(),attributesMap,false);
+        _authManager = new ScramSHA1AuthenticationManager(_broker, Collections.<String,Object>emptyMap(),attributesMap);
     }
 
     @Override

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java Thu Apr  3 19:58:53 2014
@@ -29,9 +29,9 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.SystemContext;
 import org.apache.qpid.server.model.TrustStore;
 
 
@@ -42,6 +42,8 @@ public class SimpleLDAPAuthenticationMan
     private SimpleLDAPAuthenticationManagerFactory _factory = new SimpleLDAPAuthenticationManagerFactory();
     private Map<String, Object> _configuration = new HashMap<String, Object>();
     private Broker _broker = mock(Broker.class);
+    private SystemContext _systemContext = mock(SystemContext.class);
+
     private TrustStore _trustStore = mock(TrustStore.class);
 
     public void setUp() throws Exception
@@ -51,6 +53,9 @@ public class SimpleLDAPAuthenticationMan
         when(_trustStore.getName()).thenReturn("mytruststore");
         when(_trustStore.getId()).thenReturn(UUID.randomUUID());
 
+        when(_broker.getParent(eq(SystemContext.class))).thenReturn(_systemContext);
+        when(_systemContext.getChildren(eq(Broker.class))).thenReturn(Collections.singleton(_broker));
+
         _configuration.put(AuthenticationProvider.ID, UUID.randomUUID());
         _configuration.put(AuthenticationProvider.NAME, getName());
     }
@@ -61,7 +66,7 @@ public class SimpleLDAPAuthenticationMan
         _configuration.put("providerUrl", "ldap://example.com:389/");
         _configuration.put("searchContext", "dc=example");
 
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
+        AuthenticationManager manager = _factory.create(_configuration, _broker);
         assertNotNull(manager);
 
     }
@@ -72,7 +77,7 @@ public class SimpleLDAPAuthenticationMan
         _configuration.put("providerUrl", "ldaps://example.com:636/");
         _configuration.put("searchContext", "dc=example");
 
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
+        AuthenticationManager manager = _factory.create(_configuration, _broker);
         assertNotNull(manager);
 
     }
@@ -87,7 +92,7 @@ public class SimpleLDAPAuthenticationMan
         _configuration.put("searchContext", "dc=example");
         _configuration.put("trustStore", "mytruststore");
 
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
+        AuthenticationManager manager = _factory.create(_configuration, _broker);
         assertNotNull(manager);
     }
 
@@ -102,7 +107,7 @@ public class SimpleLDAPAuthenticationMan
 
         try
         {
-            _factory.createInstance(_broker, _configuration, false);
+            _factory.create(_configuration, _broker);
             fail("Exception not thrown");
         }
         catch(IllegalArgumentException e)
@@ -111,9 +116,4 @@ public class SimpleLDAPAuthenticationMan
         }
     }
 
-    public void testReturnsNullWhenNoConfig() throws Exception
-    {
-        AuthenticationManager manager = _factory.createInstance(_broker, _configuration, false);
-        assertNull(manager);
-    }
 }

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/TestableMemoryMessageStore.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java Thu Apr  3 19:58:53 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;
     }
 
-
 }



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


Mime
View raw message