qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1515079 [3/4] - in /qpid/trunk/qpid/java: bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/ bdbstore/src/test/java/org/apache/qpid/server/store/berkeleyd...
Date Sun, 18 Aug 2013 09:13:03 GMT
Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQPriorityQueueTest.java Sun Aug 18 09:13:02 2013
@@ -20,15 +20,15 @@
  */
 package org.apache.qpid.server.queue;
 
+import java.util.Collections;
 import junit.framework.AssertionFailedError;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.message.ServerMessage;
 
 import java.util.ArrayList;
+import org.apache.qpid.server.model.Queue;
 
 import static org.mockito.Mockito.when;
 
@@ -38,9 +38,7 @@ public class AMQPriorityQueueTest extend
     @Override
     public void setUp() throws Exception
     {
-        FieldTable arguments = new FieldTable();
-        arguments.put(new AMQShortString(AMQQueueFactory.X_QPID_PRIORITIES), 3);
-        setArguments(arguments);
+        setArguments(Collections.singletonMap(Queue.PRIORITIES,(Object)3));
         super.setUp();
     }
 

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueFactoryTest.java Sun Aug 18 09:13:02 2013
@@ -20,91 +20,213 @@
  */
 package org.apache.qpid.server.queue;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyMap;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.apache.commons.configuration.CompositeConfiguration;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.XMLConfiguration;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 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.Exchange;
-import org.apache.qpid.server.exchange.ExchangeRegistry;
-import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.store.TestableMemoryMessageStore;
-import org.apache.qpid.server.util.BrokerTestHelper;
+import org.apache.qpid.server.plugin.ExchangeType;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.test.utils.QpidTestCase;
+import org.mockito.ArgumentCaptor;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 
 public class AMQQueueFactoryTest extends QpidTestCase
 {
     private QueueRegistry _queueRegistry;
     private VirtualHost _virtualHost;
-    private Broker _broker;
+    private AMQQueueFactory _queueFactory;
+    private List<AMQQueue> _queues;
+    private QueueConfiguration _queueConfiguration;
 
     @Override
     public void setUp() throws Exception
     {
         super.setUp();
 
-        BrokerTestHelper.setUp();
-        XMLConfiguration configXml = new XMLConfiguration();
-        configXml.addProperty("store.class", TestableMemoryMessageStore.class.getName());
+        _queues = new ArrayList<AMQQueue>();
 
+        _virtualHost = mock(VirtualHost.class);
 
-        _broker = BrokerTestHelper.createBrokerMock();
-        if (getName().equals("testDeadLetterQueueDoesNotInheritDLQorMDCSettings"))
-        {
-            when(_broker.getAttribute(Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(5);
-            when(_broker.getAttribute(Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED)).thenReturn(true);
-        }
+        VirtualHostConfiguration vhostConfig = mock(VirtualHostConfiguration.class);
+        when(_virtualHost.getConfiguration()).thenReturn(vhostConfig);
+        _queueConfiguration = mock(QueueConfiguration.class);
+        when(vhostConfig.getQueueConfiguration(anyString())).thenReturn(_queueConfiguration);
+        LogActor logActor = mock(LogActor.class);
+        CurrentActor.set(logActor);
+        RootMessageLogger rootLogger = mock(RootMessageLogger.class);
+        when(logActor.getRootMessageLogger()).thenReturn(rootLogger);
+        DurableConfigurationStore store = mock(DurableConfigurationStore.class);
+        when(_virtualHost.getDurableConfigurationStore()).thenReturn(store);
+
+        mockExchangeCreation();
+        mockQueueRegistry();
+        delegateVhostQueueCreation();
+
+        when(_virtualHost.getQueues()).thenReturn(_queues);
+
+
+        _queueFactory = new AMQQueueFactory(_virtualHost, _queueRegistry);
 
-        _virtualHost = BrokerTestHelper.createVirtualHost(new VirtualHostConfiguration(getName(), configXml, _broker));
 
-        _queueRegistry = _virtualHost.getQueueRegistry();
 
     }
 
+    private void delegateVhostQueueCreation() throws AMQException
+    {
+        final ArgumentCaptor<UUID> id = ArgumentCaptor.forClass(UUID.class);
+        final ArgumentCaptor<String> queueName = ArgumentCaptor.forClass(String.class);
+        final ArgumentCaptor<Boolean> durable = ArgumentCaptor.forClass(Boolean.class);
+        final ArgumentCaptor<String> owner = ArgumentCaptor.forClass(String.class);
+        final ArgumentCaptor<Boolean> autoDelete = ArgumentCaptor.forClass(Boolean.class);
+        final ArgumentCaptor<Boolean> exclusive = ArgumentCaptor.forClass(Boolean.class);
+        final ArgumentCaptor<Boolean> deleteOnNoConsumer = ArgumentCaptor.forClass(Boolean.class);
+        final ArgumentCaptor<Map> arguments = ArgumentCaptor.forClass(Map.class);
+
+        when(_virtualHost.createQueue(id.capture(), queueName.capture(), durable.capture(), owner.capture(),
+                autoDelete.capture(), exclusive.capture(), deleteOnNoConsumer.capture(), arguments.capture())).then(
+                new Answer<AMQQueue>()
+                {
+                    @Override
+                    public AMQQueue answer(InvocationOnMock invocation) throws Throwable
+                    {
+                        return _queueFactory.createAMQQueueImpl(id.getValue(),
+                                queueName.getValue(),
+                                durable.getValue(),
+                                owner.getValue(),
+                                autoDelete.getValue(),
+                                exclusive.getValue(),
+                                deleteOnNoConsumer.getValue(),
+                                arguments.getValue());
+                    }
+                }
+        );
+    }
+
+    private void mockQueueRegistry()
+    {
+        _queueRegistry = mock(QueueRegistry.class);
+
+        final ArgumentCaptor<AMQQueue> capturedQueue = ArgumentCaptor.forClass(AMQQueue.class);
+        doAnswer(new Answer()
+        {
+
+            @Override
+            public Object answer(final InvocationOnMock invocation) throws Throwable
+            {
+                AMQQueue queue = capturedQueue.getValue();
+                when(_queueRegistry.getQueue(eq(queue.getId()))).thenReturn(queue);
+                when(_queueRegistry.getQueue(eq(queue.getName()))).thenReturn(queue);
+                when(_virtualHost.getQueue(eq(queue.getId()))).thenReturn(queue);
+                when(_virtualHost.getQueue(eq(queue.getName()))).thenReturn(queue);
+                _queues.add(queue);
+
+                return null;
+            }
+        }).when(_queueRegistry).registerQueue(capturedQueue.capture());
+    }
+
+    private void mockExchangeCreation() throws AMQException
+    {
+        final ArgumentCaptor<UUID> idCapture = ArgumentCaptor.forClass(UUID.class);
+        final ArgumentCaptor<String> exchangeNameCapture = ArgumentCaptor.forClass(String.class);
+        final ArgumentCaptor<String> type = ArgumentCaptor.forClass(String.class);
+
+        when(_virtualHost.createExchange(idCapture.capture(), exchangeNameCapture.capture(), type.capture(),
+                anyBoolean(), anyBoolean(), anyString())).then(
+                new Answer<Exchange>()
+                {
+                    @Override
+                    public Exchange answer(InvocationOnMock invocation) throws Throwable
+                    {
+                        final String name = exchangeNameCapture.getValue();
+                        final UUID id = idCapture.getValue();
+
+                        final Exchange exchange = mock(Exchange.class);
+                        ExchangeType exType = mock(ExchangeType.class);
+
+                        when(exchange.getName()).thenReturn(name);
+                        when(exchange.getId()).thenReturn(id);
+                        when(exchange.getType()).thenReturn(exType);
+                        final String typeName = type.getValue();
+                        when(exType.getType()).thenReturn(typeName);
+                        when(exType.getName()).thenReturn(new AMQShortString(typeName));
+
+                        when(_virtualHost.getExchange(eq(name))).thenReturn(exchange);
+                        when(_virtualHost.getExchange(eq(id))).thenReturn(exchange);
+
+                        final ArgumentCaptor<AMQQueue> queue = ArgumentCaptor.forClass(AMQQueue.class);
+
+                        when(exchange.addBinding(anyString(),queue.capture(),anyMap())).then(new Answer<Boolean>() {
+
+                            @Override
+                            public Boolean answer(InvocationOnMock invocation) throws Throwable
+                            {
+                                when(exchange.isBound(eq(queue.getValue()))).thenReturn(true);
+                                return true;
+                            }
+                        });
+
+                        return exchange;
+                    }
+                }
+        );
+    }
+
     @Override
     public void tearDown() throws Exception
     {
-        try
-        {
-            _virtualHost.close();
-        }
-        finally
-        {
-            BrokerTestHelper.tearDown();
-            super.tearDown();
-        }
+        super.tearDown();
     }
 
     private void verifyRegisteredQueueCount(int count)
     {
-        assertEquals("Queue was not registered in virtualhost", count, _queueRegistry.getQueues().size());
+        assertEquals("Queue was not registered in virtualhost", count, _virtualHost.getQueues().size());
     }
 
 
     private void verifyQueueRegistered(String queueName)
     {
-        assertNotNull("Queue " + queueName + " was not created", _queueRegistry.getQueue(queueName));
+        assertNotNull("Queue " + queueName + " was not created", _virtualHost.getQueue(queueName));
     }
 
     public void testPriorityQueueRegistration() throws Exception
     {
-        FieldTable fieldTable = new FieldTable();
-        fieldTable.put(new AMQShortString(AMQQueueFactory.X_QPID_PRIORITIES), 5);
+        Map<String,Object> attributes = Collections.singletonMap(Queue.PRIORITIES, (Object) 5);
 
 
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "testPriorityQueue", false, "owner", false,
-                                           false, _virtualHost, FieldTable.convertToMap(fieldTable));
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "testPriorityQueue", false, "owner", false,
+                                           false,
+                false,
+                attributes);
 
         assertEquals("Queue not a priorty queue", AMQPriorityQueue.class, queue.getClass());
         verifyQueueRegistered("testPriorityQueue");
@@ -115,43 +237,42 @@ public class AMQQueueFactoryTest extends
     public void testSimpleQueueRegistration() throws Exception
     {
         String queueName = getName();
-        AMQShortString dlQueueName = new AMQShortString(queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX);
+        String dlQueueName = queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX;
 
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false,
-                                           false, _virtualHost, null);
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false,
+                                           false,
+                false,
+                null);
         assertEquals("Queue not a simple queue", SimpleAMQQueue.class, queue.getClass());
         verifyQueueRegistered(queueName);
 
         //verify that no alternate exchange or DLQ were produced
-        QueueRegistry qReg = _virtualHost.getQueueRegistry();
 
         assertNull("Queue should not have an alternate exchange as DLQ wasnt enabled", queue.getAlternateExchange());
-        assertNull("The DLQ should not exist", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should not exist", _virtualHost.getQueue(dlQueueName));
 
         verifyRegisteredQueueCount(1);
     }
 
     /**
-     * Tests that setting the {@link AMQQueueFactory#X_QPID_DLQ_ENABLED} argument true does
+     * Tests that setting the {@link QueueArgumentsConverter#X_QPID_DLQ_ENABLED} argument true does
      * cause the alternate exchange to be set and DLQ to be produced.
      * @throws AMQException
      */
     public void testDeadLetterQueueEnabled() throws AMQException
     {
-        FieldTable fieldTable = new FieldTable();
-        fieldTable.setBoolean(AMQQueueFactory.X_QPID_DLQ_ENABLED, true);
+        Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
 
         String queueName = "testDeadLetterQueueEnabled";
         String dlExchangeName = queueName + DefaultExchangeFactory.DEFAULT_DLE_NAME_SUFFIX;
         String dlQueueName = queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX;
 
-        QueueRegistry qReg = _virtualHost.getQueueRegistry();
-
-        assertNull("The DLQ should not yet exist", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should not yet exist", _virtualHost.getQueue(dlQueueName));
         assertNull("The alternate exchange should not yet exist", _virtualHost.getExchange(dlExchangeName));
 
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false, false,
-                                           _virtualHost, FieldTable.convertToMap(fieldTable));
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false, false,
+                false,
+                attributes);
 
         Exchange altExchange = queue.getAlternateExchange();
         assertNotNull("Queue should have an alternate exchange as DLQ is enabled", altExchange);
@@ -161,7 +282,7 @@ public class AMQQueueFactoryTest extends
         assertNotNull("The alternate exchange was not registered as expected", _virtualHost.getExchange(dlExchangeName));
         assertEquals("The registered exchange was not the expected exchange instance", altExchange, _virtualHost.getExchange(dlExchangeName));
 
-        AMQQueue dlQueue = qReg.getQueue(dlQueueName);
+        AMQQueue dlQueue = _virtualHost.getQueue(dlQueueName);
         assertNotNull("The DLQ was not registered as expected", dlQueue);
         assertTrue("DLQ should have been bound to the alternate exchange", altExchange.isBound(dlQueue));
         assertNull("DLQ should have no alternate exchange", dlQueue.getAlternateExchange());
@@ -178,17 +299,20 @@ public class AMQQueueFactoryTest extends
      */
     public void testDeadLetterQueueDoesNotInheritDLQorMDCSettings() throws Exception
     {
+
         String queueName = "testDeadLetterQueueEnabled";
         String dlExchangeName = queueName + DefaultExchangeFactory.DEFAULT_DLE_NAME_SUFFIX;
         String dlQueueName = queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX;
 
-        QueueRegistry qReg = _virtualHost.getQueueRegistry();
+        when(_queueConfiguration.getMaxDeliveryCount()).thenReturn(5);
+        when(_queueConfiguration.isDeadLetterQueueEnabled()).thenReturn(true);
 
-        assertNull("The DLQ should not yet exist", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should not yet exist", _virtualHost.getQueue(dlQueueName));
         assertNull("The alternate exchange should not yet exist", _virtualHost.getExchange(dlExchangeName));
 
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false, false,
-                                           _virtualHost, null);
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false, false,
+                false,
+                null);
 
         assertEquals("Unexpected maximum delivery count", 5, queue.getMaximumDeliveryCount());
         Exchange altExchange = queue.getAlternateExchange();
@@ -199,7 +323,7 @@ public class AMQQueueFactoryTest extends
         assertNotNull("The alternate exchange was not registered as expected", _virtualHost.getExchange(dlExchangeName));
         assertEquals("The registered exchange was not the expected exchange instance", altExchange, _virtualHost.getExchange(dlExchangeName));
 
-        AMQQueue dlQueue = qReg.getQueue(dlQueueName);
+        AMQQueue dlQueue = _virtualHost.getQueue(dlQueueName);
         assertNotNull("The DLQ was not registered as expected", dlQueue);
         assertTrue("DLQ should have been bound to the alternate exchange", altExchange.isBound(dlQueue));
         assertNull("DLQ should have no alternate exchange", dlQueue.getAlternateExchange());
@@ -210,81 +334,77 @@ public class AMQQueueFactoryTest extends
     }
 
     /**
-     * Tests that setting the {@link AMQQueueFactory#X_QPID_DLQ_ENABLED} argument false does not
+     * Tests that setting the {@link QueueArgumentsConverter#X_QPID_DLQ_ENABLED} argument false does not
      * result in the alternate exchange being set and DLQ being created.
      * @throws AMQException
      */
     public void testDeadLetterQueueDisabled() throws AMQException
     {
-        FieldTable fieldTable = new FieldTable();
-        fieldTable.setBoolean(AMQQueueFactory.X_QPID_DLQ_ENABLED, false);
+        Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) false);
 
         String queueName = "testDeadLetterQueueDisabled";
         String dlExchangeName = queueName + DefaultExchangeFactory.DEFAULT_DLE_NAME_SUFFIX;
         String dlQueueName = queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX;
 
-        QueueRegistry qReg = _virtualHost.getQueueRegistry();
-
-        assertNull("The DLQ should not yet exist", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should not yet exist", _virtualHost.getQueue(dlQueueName));
         assertNull("The alternate exchange should not exist", _virtualHost.getExchange(dlExchangeName));
 
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false, false,
-                                           _virtualHost, FieldTable.convertToMap(fieldTable));
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", false, false,
+                false,
+                attributes);
 
         assertNull("Queue should not have an alternate exchange as DLQ is disabled", queue.getAlternateExchange());
         assertNull("The alternate exchange should still not exist", _virtualHost.getExchange(dlExchangeName));
 
-        assertNull("The DLQ should still not exist", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should still not exist", _virtualHost.getQueue(dlQueueName));
 
         //only 1 queue should have been registered
         verifyRegisteredQueueCount(1);
     }
 
     /**
-     * Tests that setting the {@link AMQQueueFactory#X_QPID_DLQ_ENABLED} argument true but
+     * Tests that setting the {@link QueueArgumentsConverter#X_QPID_DLQ_ENABLED} argument true but
      * creating an auto-delete queue, does not result in the alternate exchange
      * being set and DLQ being created.
      * @throws AMQException
      */
     public void testDeadLetterQueueNotCreatedForAutodeleteQueues() throws AMQException
     {
-        FieldTable fieldTable = new FieldTable();
-        fieldTable.setBoolean(AMQQueueFactory.X_QPID_DLQ_ENABLED, true);
+        Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
 
         String queueName = "testDeadLetterQueueNotCreatedForAutodeleteQueues";
         String dlExchangeName = queueName + DefaultExchangeFactory.DEFAULT_DLE_NAME_SUFFIX;
         String dlQueueName = queueName + AMQQueueFactory.DEFAULT_DLQ_NAME_SUFFIX;
 
-        QueueRegistry qReg = _virtualHost.getQueueRegistry();
-
-        assertNull("The DLQ should not yet exist", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should not yet exist", _virtualHost.getQueue(dlQueueName));
         assertNull("The alternate exchange should not exist", _virtualHost.getExchange(dlExchangeName));
 
         //create an autodelete queue
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", true, false,
-                                           _virtualHost, FieldTable.convertToMap(fieldTable));
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner", true, false,
+                false,
+                attributes);
         assertTrue("Queue should be autodelete", queue.isAutoDelete());
 
         //ensure that the autodelete property overrides the request to enable DLQ
         assertNull("Queue should not have an alternate exchange as queue is autodelete", queue.getAlternateExchange());
         assertNull("The alternate exchange should not exist as queue is autodelete", _virtualHost.getExchange(dlExchangeName));
-        assertNull("The DLQ should not exist as queue is autodelete", qReg.getQueue(dlQueueName));
+        assertNull("The DLQ should not exist as queue is autodelete", _virtualHost.getQueue(dlQueueName));
 
         //only 1 queue should have been registered
         verifyRegisteredQueueCount(1);
     }
 
     /**
-     * Tests that setting the {@link AMQQueueFactory#X_QPID_MAXIMUM_DELIVERY_COUNT} argument has
+     * Tests that setting the {@link QueueArgumentsConverter#X_QPID_MAXIMUM_DELIVERY_COUNT} argument has
      * the desired effect.
      */
     public void testMaximumDeliveryCount() throws Exception
     {
-        final FieldTable fieldTable = new FieldTable();
-        fieldTable.setInteger(AMQQueueFactory.X_QPID_MAXIMUM_DELIVERY_COUNT, 5);
+        Map<String,Object> attributes = Collections.singletonMap(Queue.MAXIMUM_DELIVERY_ATTEMPTS, (Object) 5);
 
-        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "testMaximumDeliveryCount", false, "owner", false, false,
-                                           _virtualHost, FieldTable.convertToMap(fieldTable));
+        final AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "testMaximumDeliveryCount", false, "owner", false, false,
+                false,
+                attributes);
 
         assertNotNull("The queue was not registered as expected ", queue);
         assertEquals("Maximum delivery count not as expected", 5, queue.getMaximumDeliveryCount());
@@ -293,13 +413,14 @@ public class AMQQueueFactoryTest extends
     }
 
     /**
-     * Tests that omitting the {@link AMQQueueFactory#X_QPID_MAXIMUM_DELIVERY_COUNT} argument means
+     * Tests that omitting the {@link QueueArgumentsConverter#X_QPID_MAXIMUM_DELIVERY_COUNT} argument means
      * that queue is created with a default maximumDeliveryCount of zero (unless set in config).
      */
     public void testMaximumDeliveryCountDefault() throws Exception
     {
-        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "testMaximumDeliveryCount", false, "owner", false, false,
-                                           _virtualHost, null);
+        final AMQQueue queue = _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "testMaximumDeliveryCount", false, "owner", false, false,
+                false,
+                null);
 
         assertNotNull("The queue was not registered as expected ", queue);
         assertEquals("Maximum delivery count not as expected", 0, queue.getMaximumDeliveryCount());
@@ -314,7 +435,9 @@ public class AMQQueueFactoryTest extends
     {
         try
         {
-            AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), null, false, "owner", true, false, _virtualHost, null);
+            _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), null, false, "owner", true, false,
+                    false,
+                    null);
             fail("queue with null name can not be created!");
         }
         catch (Exception e)
@@ -336,10 +459,9 @@ public class AMQQueueFactoryTest extends
             // change DLQ name to make its length bigger than exchange name
             setTestSystemProperty(BrokerProperties.PROPERTY_DEAD_LETTER_EXCHANGE_SUFFIX, "_DLE");
             setTestSystemProperty(BrokerProperties.PROPERTY_DEAD_LETTER_QUEUE_SUFFIX, "_DLQUEUE");
-            FieldTable fieldTable = new FieldTable();
-            fieldTable.setBoolean(AMQQueueFactory.X_QPID_DLQ_ENABLED, true);
-            AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner",
-                    false, false, _virtualHost, FieldTable.convertToMap(fieldTable));
+            Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
+            _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner",
+                    false, false, false, attributes);
             fail("queue with DLQ name having more than 255 characters can not be created!");
         }
         catch (Exception e)
@@ -362,10 +484,9 @@ public class AMQQueueFactoryTest extends
             // change DLQ name to make its length bigger than exchange name
             setTestSystemProperty(BrokerProperties.PROPERTY_DEAD_LETTER_EXCHANGE_SUFFIX, "_DLEXCHANGE");
             setTestSystemProperty(BrokerProperties.PROPERTY_DEAD_LETTER_QUEUE_SUFFIX, "_DLQ");
-            FieldTable fieldTable = new FieldTable();
-            fieldTable.setBoolean(AMQQueueFactory.X_QPID_DLQ_ENABLED, true);
-            AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner",
-                    false, false, _virtualHost, FieldTable.convertToMap(fieldTable));
+            Map<String,Object> attributes = Collections.singletonMap(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
+            _queueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, "owner",
+                    false, false, false, attributes);
             fail("queue with DLE name having more than 255 characters can not be created!");
         }
         catch (Exception e)
@@ -379,16 +500,17 @@ public class AMQQueueFactoryTest extends
     public void testMessageGroupFromConfig() throws Exception
     {
 
-        PropertiesConfiguration queueConfig = new PropertiesConfiguration();
-        queueConfig.addProperty("queues.queue.test.argument", "qpid.group_header_key=mykey");
-        queueConfig.addProperty("queues.queue.test.argument", "qpid.shared_msg_group=1");
-
-
-        final VirtualHostConfiguration vhostConfig = new VirtualHostConfiguration("test", queueConfig, _broker);;
-        QueueConfiguration qConf = new QueueConfiguration("test", vhostConfig);
-        AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(qConf, _virtualHost);
-        assertEquals("mykey", queue.getArguments().get(SimpleAMQQueue.QPID_GROUP_HEADER_KEY));
-        assertEquals("1", queue.getArguments().get(SimpleAMQQueue.QPID_SHARED_MSG_GROUP));
+        Map<String,String> arguments = new HashMap<String, String>();
+        arguments.put("qpid.group_header_key","mykey");
+        arguments.put("qpid.shared_msg_group","1");
+
+        QueueConfiguration qConf = mock(QueueConfiguration.class);
+        when(qConf.getArguments()).thenReturn(arguments);
+        when(qConf.getName()).thenReturn("test");
+
+        AMQQueue queue = _queueFactory.createAMQQueueImpl(qConf);
+        assertEquals("mykey", queue.getAttribute(Queue.MESSAGE_GROUP_KEY));
+        assertEquals(Boolean.TRUE, queue.getAttribute(Queue.MESSAGE_GROUP_SHARED_GROUPS));
     }
 
     private String generateStringWithLength(char ch, int length)

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java Sun Aug 18 09:13:02 2013
@@ -469,7 +469,14 @@ public class MockAMQQueue implements AMQ
 
     }
 
-    public Map<String, Object> getArguments()
+    @Override
+    public Collection<String> getAvailableAttributes()
+    {
+        return null;
+    }
+
+    @Override
+    public Object getAttribute(String attrName)
     {
         return null;
     }

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java Sun Aug 18 09:13:02 2013
@@ -29,12 +29,12 @@ import static org.mockito.Matchers.conta
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.when;
 
+import java.util.Map;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.message.AMQMessageHeader;
@@ -65,7 +65,7 @@ public class SimpleAMQQueueTest extends 
     private AMQShortString _routingKey = new AMQShortString("routing key");
     private DirectExchange _exchange;
     private MockSubscription _subscription = new MockSubscription();
-    private FieldTable _arguments = null;
+    private Map<String,Object> _arguments = null;
 
     private MessagePublishInfo info = new MessagePublishInfo()
     {
@@ -103,8 +103,8 @@ public class SimpleAMQQueueTest extends 
 
         _virtualHost = BrokerTestHelper.createVirtualHost(getClass().getName());
 
-        _queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), _qname.asString(), false, _owner.asString(),
-                false, false, _virtualHost, FieldTable.convertToMap(_arguments));
+        _queue = (SimpleAMQQueue) _virtualHost.createQueue(UUIDGenerator.generateRandomUUID(), _qname.asString(), false, _owner.asString(),
+                false, false, false, _arguments);
 
         _exchange = (DirectExchange) _virtualHost.getExchange(ExchangeDefaults.DIRECT_EXCHANGE_NAME.toString());
     }
@@ -127,8 +127,11 @@ public class SimpleAMQQueueTest extends 
     public void testCreateQueue() throws AMQException
     {
         _queue.stop();
-        try {
-            _queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), null, false, _owner.asString(), false, false, _virtualHost, FieldTable.convertToMap(_arguments));
+        try
+        {
+            _queue = (SimpleAMQQueue) _virtualHost.createQueue(UUIDGenerator.generateRandomUUID(), null,
+                                                                         false, _owner.asString(), false,
+                                                                         false, false, _arguments);
             assertNull("Queue was created", _queue);
         }
         catch (IllegalArgumentException e)
@@ -137,7 +140,8 @@ public class SimpleAMQQueueTest extends 
                             e.getMessage().contains("name"));
         }
 
-        try {
+        try
+        {
             _queue = new SimpleAMQQueue(UUIDGenerator.generateRandomUUID(), _qname, false, _owner, false,false, null, Collections.EMPTY_MAP);
             assertNull("Queue was created", _queue);
         }
@@ -147,8 +151,10 @@ public class SimpleAMQQueueTest extends 
                     e.getMessage().contains("Host"));
         }
 
-        _queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), _qname.asString(), false, _owner.asString(), false,
-                                                                false, _virtualHost, FieldTable.convertToMap(_arguments));
+        _queue = (SimpleAMQQueue) _virtualHost.createQueue(UUIDGenerator.generateRandomUUID(),
+                                                                     "differentName", false,
+                                                                     _owner.asString(), false,
+                                                                     false, false, _arguments);
         assertNotNull("Queue was not created", _queue);
     }
 
@@ -1225,12 +1231,12 @@ public class SimpleAMQQueueTest extends 
         return _subscription;
     }
 
-    public FieldTable getArguments()
+    public Map<String,Object> getArguments()
     {
         return _arguments;
     }
 
-    public void setArguments(FieldTable arguments)
+    public void setArguments(Map<String,Object> arguments)
     {
         _arguments = arguments;
     }

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java Sun Aug 18 09:13:02 2013
@@ -50,8 +50,8 @@ public class SimpleAMQQueueThreadPoolTes
 
         try
         {
-            SimpleAMQQueue queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), "test", false,
-                                                                                       "owner", false, false, test, null);
+            SimpleAMQQueue queue = (SimpleAMQQueue)
+                    test.createQueue(UUIDGenerator.generateRandomUUID(), "test", false, "owner", false, false, false, null);
 
             assertFalse("Creation did not start Pool.", ReferenceCountingExecutorService.getInstance().getPool().isShutdown());
 

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Sun Aug 18 09:13:02 2013
@@ -52,6 +52,9 @@ import org.apache.qpid.server.store.Mess
 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;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 
 public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTestCase
 {
@@ -178,7 +181,7 @@ public abstract class AbstractDurableCon
 
     public void testBindQueue() throws Exception
     {
-        AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false);
+        AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false, null);
         Binding binding = new Binding(UUIDGenerator.generateRandomUUID(), ROUTING_KEY, queue,
                 _exchange, FieldTable.convertToMap(_bindingArgs));
         DurableConfigurationStoreHelper.createBinding(_configStore, binding);
@@ -197,7 +200,7 @@ public abstract class AbstractDurableCon
 
     public void testUnbindQueue() throws Exception
     {
-        AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false);
+        AMQQueue queue = createTestQueue(QUEUE_NAME, "queueOwner", false, null);
         Binding binding = new Binding(UUIDGenerator.generateRandomUUID(), ROUTING_KEY, queue,
                 _exchange, FieldTable.convertToMap(_bindingArgs));
         DurableConfigurationStoreHelper.createBinding(_configStore, binding);
@@ -212,8 +215,8 @@ public abstract class AbstractDurableCon
 
     public void testCreateQueueAMQQueue() throws Exception
     {
-        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
-        DurableConfigurationStoreHelper.createQueue(_configStore, queue, null);
+        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, null);
+        DurableConfigurationStoreHelper.createQueue(_configStore, queue);
 
         reopenStore();
         Map<String, Object> queueAttributes = new HashMap<String, Object>();
@@ -225,13 +228,12 @@ public abstract class AbstractDurableCon
 
     public void testCreateQueueAMQQueueFieldTable() throws Exception
     {
-        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
-        attributes.put("x-qpid-maximum-delivery-count", new Integer(10));
+        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
+        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
 
-        FieldTable arguments = FieldTable.convertToFieldTable(attributes);
-        DurableConfigurationStoreHelper.createQueue(_configStore, queue, arguments);
+        DurableConfigurationStoreHelper.createQueue(_configStore, queue);
 
         reopenStore();
 
@@ -241,7 +243,7 @@ public abstract class AbstractDurableCon
         queueAttributes.put(Queue.NAME, getName());
         queueAttributes.put(Queue.OWNER, getName()+"Owner");
         queueAttributes.put(Queue.EXCLUSIVE, Boolean.TRUE);
-        queueAttributes.put(Queue.ARGUMENTS, attributes);
+        queueAttributes.putAll(attributes);
 
         verify(_recoveryHandler).configuredObject(eq(_queueId), eq(QUEUE), eq(queueAttributes));
     }
@@ -250,8 +252,8 @@ public abstract class AbstractDurableCon
     {
         Exchange alternateExchange = createTestAlternateExchange();
 
-        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, alternateExchange);
-        DurableConfigurationStoreHelper.createQueue(_configStore, queue, null);
+        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, alternateExchange, null);
+        DurableConfigurationStoreHelper.createQueue(_configStore, queue);
 
         reopenStore();
 
@@ -275,16 +277,15 @@ public abstract class AbstractDurableCon
     public void testUpdateQueueExclusivity() throws Exception
     {
         // create queue
-        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
-        attributes.put("x-qpid-maximum-delivery-count", new Integer(10));
-        FieldTable arguments = FieldTable.convertToFieldTable(attributes);
-        DurableConfigurationStoreHelper.createQueue(_configStore, queue, arguments);
+        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
+        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
+
+        DurableConfigurationStoreHelper.createQueue(_configStore, queue);
 
         // update the queue to have exclusive=false
-        queue = createTestQueue(getName(), getName() + "Owner", false);
-        when(queue.getArguments()).thenReturn(attributes);
+        queue = createTestQueue(getName(), getName() + "Owner", false, attributes);
 
         DurableConfigurationStoreHelper.updateQueue(_configStore, queue);
 
@@ -295,7 +296,7 @@ public abstract class AbstractDurableCon
         queueAttributes.put(Queue.NAME, getName());
         queueAttributes.put(Queue.OWNER, getName()+"Owner");
         queueAttributes.put(Queue.EXCLUSIVE, Boolean.FALSE);
-        queueAttributes.put(Queue.ARGUMENTS, attributes);
+        queueAttributes.putAll(attributes);
 
         verify(_recoveryHandler).configuredObject(eq(_queueId), eq(QUEUE), eq(queueAttributes));
 
@@ -304,17 +305,15 @@ public abstract class AbstractDurableCon
     public void testUpdateQueueAlternateExchange() throws Exception
     {
         // create queue
-        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
-        attributes.put("x-qpid-maximum-delivery-count", new Integer(10));
-        FieldTable arguments = FieldTable.convertToFieldTable(attributes);
-        DurableConfigurationStoreHelper.createQueue(_configStore, queue, arguments);
+        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
+        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
+        DurableConfigurationStoreHelper.createQueue(_configStore, queue);
 
         // update the queue to have exclusive=false
         Exchange alternateExchange = createTestAlternateExchange();
-        queue = createTestQueue(getName(), getName() + "Owner", false, alternateExchange);
-        when(queue.getArguments()).thenReturn(attributes);
+        queue = createTestQueue(getName(), getName() + "Owner", false, alternateExchange, attributes);
 
         DurableConfigurationStoreHelper.updateQueue(_configStore, queue);
 
@@ -325,7 +324,7 @@ public abstract class AbstractDurableCon
         queueAttributes.put(Queue.NAME, getName());
         queueAttributes.put(Queue.OWNER, getName()+"Owner");
         queueAttributes.put(Queue.EXCLUSIVE, Boolean.FALSE);
-        queueAttributes.put(Queue.ARGUMENTS, attributes);
+        queueAttributes.putAll(attributes);
         queueAttributes.put(Queue.ALTERNATE_EXCHANGE, alternateExchange.getId().toString());
 
         verify(_recoveryHandler).configuredObject(eq(_queueId), eq(QUEUE), eq(queueAttributes));
@@ -334,12 +333,11 @@ public abstract class AbstractDurableCon
     public void testRemoveQueue() throws Exception
     {
         // create queue
-        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true);
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put("x-qpid-dlq-enabled", Boolean.TRUE);
-        attributes.put("x-qpid-maximum-delivery-count", new Integer(10));
-        FieldTable arguments = FieldTable.convertToFieldTable(attributes);
-        DurableConfigurationStoreHelper.createQueue(_configStore, queue, arguments);
+        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
+        AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
+        DurableConfigurationStoreHelper.createQueue(_configStore, queue);
 
         // remove queue
         DurableConfigurationStoreHelper.removeQueue(_configStore,queue);
@@ -349,12 +347,19 @@ public abstract class AbstractDurableCon
                 anyMap());
     }
 
-    private AMQQueue createTestQueue(String queueName, String queueOwner, boolean exclusive) throws AMQStoreException
-    {
-        return createTestQueue(queueName, queueOwner, exclusive, null);
+    private AMQQueue createTestQueue(String queueName,
+                                     String queueOwner,
+                                     boolean exclusive,
+                                     final Map<String, Object> arguments) throws AMQStoreException
+    {
+        return createTestQueue(queueName, queueOwner, exclusive, null, arguments);
     }
 
-    private AMQQueue createTestQueue(String queueName, String queueOwner, boolean exclusive, Exchange alternateExchange) throws AMQStoreException
+    private AMQQueue createTestQueue(String queueName,
+                                     String queueOwner,
+                                     boolean exclusive,
+                                     Exchange alternateExchange,
+                                     final Map<String, Object> arguments) throws AMQStoreException
     {
         AMQQueue queue = mock(AMQQueue.class);
         when(queue.getName()).thenReturn(queueName);
@@ -363,6 +368,23 @@ public abstract class AbstractDurableCon
         when(queue.isExclusive()).thenReturn(exclusive);
         when(queue.getId()).thenReturn(_queueId);
         when(queue.getAlternateExchange()).thenReturn(alternateExchange);
+        if(arguments != null && !arguments.isEmpty())
+        {
+            when(queue.getAvailableAttributes()).thenReturn(arguments.keySet());
+            final ArgumentCaptor<String> requestedAttribute = ArgumentCaptor.forClass(String.class);
+            when(queue.getAttribute(requestedAttribute.capture())).then(
+                    new Answer()
+                    {
+
+                        @Override
+                        public Object answer(final InvocationOnMock invocation) throws Throwable
+                        {
+                            String attrName = requestedAttribute.getValue();
+                            return arguments.get(attrName);
+                        }
+                    });
+        }
+
         return queue;
     }
 

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java Sun Aug 18 09:13:02 2013
@@ -181,9 +181,8 @@ public class BrokerTestHelper
 
     public static SimpleAMQQueue createQueue(String queueName, VirtualHost virtualHost) throws AMQException
     {
-        SimpleAMQQueue queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName, false, null,
-                false, false, virtualHost, Collections.<String, Object>emptyMap());
-        virtualHost.getQueueRegistry().registerQueue(queue);
+        SimpleAMQQueue queue = (SimpleAMQQueue) virtualHost.createQueue(UUIDGenerator.generateRandomUUID(), queueName, false, null,
+                false, false, false, Collections.<String, Object>emptyMap());
         return queue;
     }
 

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java Sun Aug 18 09:13:02 2013
@@ -45,6 +45,8 @@ import org.apache.qpid.server.model.Bind
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.plugin.ExchangeType;
 import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.queue.QueueFactory;
 import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.security.*;
 import org.apache.qpid.server.security.SecurityManager;
@@ -82,7 +84,7 @@ public class DurableConfigurationRecover
     private DurableConfigurationStore _store;
     private ExchangeFactory _exchangeFactory;
     private ExchangeRegistry _exchangeRegistry;
-    private QueueRegistry _queueRegistry;
+    private QueueFactory _queueFactory;
 
     @Override
     public void setUp() throws Exception
@@ -105,6 +107,7 @@ public class DurableConfigurationRecover
         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);
 
         final ArgumentCaptor<Exchange> registeredExchange = ArgumentCaptor.forClass(Exchange.class);
         doAnswer(new Answer()
@@ -114,37 +117,68 @@ public class DurableConfigurationRecover
             public Object answer(final InvocationOnMock invocation) throws Throwable
             {
                 Exchange exchange = registeredExchange.getValue();
-                when(_exchangeRegistry.getExchange(exchange.getId())).thenReturn(exchange);
-                when(_exchangeRegistry.getExchange(exchange.getName())).thenReturn(exchange);
+                when(_exchangeRegistry.getExchange(eq(exchange.getId()))).thenReturn(exchange);
+                when(_exchangeRegistry.getExchange(eq(exchange.getName()))).thenReturn(exchange);
                 return null;
             }
         }).when(_exchangeRegistry).registerExchange(registeredExchange.capture());
 
 
 
-        _queueRegistry = mock(QueueRegistry.class);
-        when(_vhost.getQueueRegistry()).thenReturn(_queueRegistry);
-
-        when(_queueRegistry.getQueue(eq(QUEUE_ID))).thenReturn(queue);
+        final ArgumentCaptor<UUID> idArg = ArgumentCaptor.forClass(UUID.class);
+        final ArgumentCaptor<String> queueArg = ArgumentCaptor.forClass(String.class);
+        final ArgumentCaptor<Map> argsArg = ArgumentCaptor.forClass(Map.class);
+
+        _queueFactory = mock(QueueFactory.class);
+
+        when(_queueFactory.createAMQQueueImpl(idArg.capture(), queueArg.capture(),
+                anyBoolean(), anyString(), anyBoolean(), anyBoolean(), anyBoolean(), argsArg.capture())).then(
+                new Answer()
+                {
 
-        final ArgumentCaptor<AMQQueue> registeredQueue = ArgumentCaptor.forClass(AMQQueue.class);
-        doAnswer(new Answer()
-        {
-
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable
-            {
-                AMQQueue queue = registeredQueue.getValue();
-                when(_queueRegistry.getQueue(queue.getId())).thenReturn(queue);
-                when(_queueRegistry.getQueue(queue.getName())).thenReturn(queue);
-                return null;
-            }
-        }).when(_queueRegistry).registerQueue(registeredQueue.capture());
+                    @Override
+                    public Object answer(final InvocationOnMock invocation) throws Throwable
+                    {
+                        final AMQQueue queue = mock(AMQQueue.class);
+
+                        final String queueName = queueArg.getValue();
+                        final UUID queueId = idArg.getValue();
+
+                        when(queue.getName()).thenReturn(queueName);
+                        when(queue.getId()).thenReturn(queueId);
+                        when(_vhost.getQueue(eq(queueName))).thenReturn(queue);
+                        when(_vhost.getQueue(eq(queueId))).thenReturn(queue);
+
+                        final ArgumentCaptor<Exchange> altExchangeArg = ArgumentCaptor.forClass(Exchange.class);
+                        doAnswer(
+                                new Answer()
+                                {
+                                    @Override
+                                    public Object answer(InvocationOnMock invocation) throws Throwable
+                                    {
+                                        final Exchange value = altExchangeArg.getValue();
+                                        when(queue.getAlternateExchange()).thenReturn(value);
+                                        return null;
+                                    }
+                                }
+                        ).when(queue).setAlternateExchange(altExchangeArg.capture());
+
+                        Map args = argsArg.getValue();
+                        if(args.containsKey(Queue.ALTERNATE_EXCHANGE))
+                        {
+                            final UUID exchangeId = UUID.fromString(args.get(Queue.ALTERNATE_EXCHANGE).toString());
+                            final Exchange exchange = _exchangeRegistry.getExchange(exchangeId);
+                            queue.setAlternateExchange(exchange);
+                        }
+                        return queue;
+                    }
+                });
 
         _exchangeFactory = mock(ExchangeFactory.class);
 
+
         DurableConfiguredObjectRecoverer[] recoverers = {
-                new QueueRecoverer(_vhost, _exchangeRegistry),
+                new QueueRecoverer(_vhost, _exchangeRegistry, _queueFactory),
                 new ExchangeRecoverer(_exchangeRegistry, _exchangeFactory),
                 new BindingRecoverer(_vhost, _exchangeRegistry)
         };
@@ -356,24 +390,11 @@ public class DurableConfigurationRecover
         final UUID queueId = new UUID(1, 0);
         final UUID exchangeId = new UUID(2, 0);
 
-        /* These lines necessary to get queue creation to work because AMQQueueFactory is called directly rather than
-           queue creation being on vhost - yuck! */
-        SecurityManager securityManager = mock(SecurityManager.class);
-        when(_vhost.getSecurityManager()).thenReturn(securityManager);
-        when(securityManager.authoriseCreateQueue(anyBoolean(),anyBoolean(),anyBoolean(),anyBoolean(),anyBoolean(),
-                                                  any(AMQShortString.class),anyString())).thenReturn(true);
-        VirtualHostConfiguration configuration = mock(VirtualHostConfiguration.class);
-        when(_vhost.getConfiguration()).thenReturn(configuration);
-        QueueConfiguration queueConfiguration = mock(QueueConfiguration.class);
-        when(configuration.getQueueConfiguration(anyString())).thenReturn(queueConfiguration);
-        LogActor logActor = mock(LogActor.class);
-        CurrentActor.set(logActor);
-        RootMessageLogger rootLogger = mock(RootMessageLogger.class);
-        when(logActor.getRootMessageLogger()).thenReturn(rootLogger);
-        /* end of queue creation mock hackery */
-
         final Exchange customExchange = mock(Exchange.class);
 
+        when(customExchange.getId()).thenReturn(exchangeId);
+        when(customExchange.getName()).thenReturn(CUSTOM_EXCHANGE_NAME);
+
         when(_exchangeFactory.createExchange(eq(exchangeId),
                                              eq(CUSTOM_EXCHANGE_NAME),
                                              eq(HeadersExchange.TYPE.getType()),
@@ -390,7 +411,7 @@ public class DurableConfigurationRecover
 
         _durableConfigurationRecoverer.completeConfigurationRecovery();
 
-        assertEquals(_queueRegistry.getQueue(queueId).getAlternateExchange(), customExchange);
+        assertEquals(customExchange, _vhost.getQueue(queueId).getAlternateExchange());
     }
 
     private void verifyCorrectUpdates(final ConfiguredObjectRecord[] expected) throws AMQStoreException

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java Sun Aug 18 09:13:02 2013
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.virtualhost;
 
 import java.util.Collection;
+import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
@@ -28,6 +29,7 @@ import org.apache.qpid.server.connection
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.plugin.ExchangeType;
 import org.apache.qpid.server.protocol.LinkRegistry;
+import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.QueueRegistry;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
@@ -119,6 +121,43 @@ public class MockVirtualHost implements 
     }
 
     @Override
+    public AMQQueue getQueue(String name)
+    {
+        return null;
+    }
+
+    @Override
+    public AMQQueue getQueue(UUID id)
+    {
+        return null;
+    }
+
+    @Override
+    public Collection<AMQQueue> getQueues()
+    {
+        return null;
+    }
+
+    @Override
+    public int removeQueue(AMQQueue queue) throws AMQException
+    {
+        return 0;
+    }
+
+    @Override
+    public AMQQueue createQueue(UUID id,
+                                String queueName,
+                                boolean durable,
+                                String owner,
+                                boolean autoDelete,
+                                boolean exclusive,
+                                boolean deleteOnNoConsumer,
+                                Map<String, Object> arguments) throws AMQException
+    {
+        return null;
+    }
+
+    @Override
     public Exchange createExchange(UUID id,
                                    String exchange,
                                    String type,
@@ -141,6 +180,12 @@ public class MockVirtualHost implements 
     }
 
     @Override
+    public Exchange getExchange(UUID id)
+    {
+        return null;
+    }
+
+    @Override
     public Exchange getDefaultExchange()
     {
         return null;

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/virtualhost/StandardVirtualHostTest.java Sun Aug 18 09:13:02 2013
@@ -244,7 +244,7 @@ public class StandardVirtualHostTest ext
         VirtualHost vhost = createVirtualHost(vhostName, config);
         assertNotNull("virtualhost should exist", vhost);
 
-        AMQQueue queue = vhost.getQueueRegistry().getQueue(queueName);
+        AMQQueue queue = vhost.getQueue(queueName);
         assertNotNull("queue should exist", queue);
 
         Exchange defaultExch = vhost.getDefaultExchange();

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java Sun Aug 18 09:13:02 2013
@@ -97,7 +97,7 @@ public class DurableQueueLoggingTest ext
 
         String clientID = _connection.getClientID();
         assertNotNull("clientID should not be null", clientID);
-        
+
         validateQueueProperties(results, false, false, clientID);
     }
 
@@ -256,7 +256,7 @@ public class DurableQueueLoggingTest ext
 
         validateQueueProperties(results, true, true, null);
     }
-    
+
     private List<String> waitForMesssage() throws IOException
     {
         // Validation
@@ -267,14 +267,14 @@ public class DurableQueueLoggingTest ext
 
         // Only 1 Queue message should hav been logged
         assertEquals("Result set size not as expected", 1, results.size());
-        
+
         return results;
     }
 
     public void validateQueueProperties(List<String> results, boolean hasPriority, boolean hasAutodelete, String clientID)
     {
         String log = getLogMessage(results, 0);
-        
+
         // Message Should be a QUE-1001
         validateMessageID("QUE-1001", log);
 
@@ -290,7 +290,7 @@ public class DurableQueueLoggingTest ext
                 fromMessage(log).contains("Priority: " + PRIORITIES));
 
         // Queue is AutoDelete
-        assertEquals("Unexpected AutoDelete status:" + fromMessage(log), hasAutodelete, 
+        assertEquals("Unexpected AutoDelete status:" + fromMessage(log), hasAutodelete,
                 fromMessage(log).contains("AutoDelete"));
 
         if(clientID != null)

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/SortedQueueTest.java Sun Aug 18 09:13:02 2013
@@ -336,7 +336,7 @@ public class SortedQueueTest extends Qpi
     private Queue createQueue() throws AMQException, JMSException
     {
         final Map<String, Object> arguments = new HashMap<String, Object>();
-        arguments.put(AMQQueueFactory.QPID_QUEUE_SORT_KEY, TEST_SORT_KEY);
+        arguments.put(QueueArgumentsConverter.QPID_QUEUE_SORT_KEY, TEST_SORT_KEY);
         ((AMQSession<?,?>) _producerSession).createQueue(new AMQShortString(getTestQueueName()), false, true, false, arguments);
         final Queue queue = new AMQQueue("amq.direct", getTestQueueName());
         ((AMQSession<?,?>) _producerSession).declareAndBind((AMQDestination) queue);

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java?rev=1515079&r1=1515078&r2=1515079&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/MessageStoreTest.java Sun Aug 18 09:13:02 2013
@@ -23,6 +23,7 @@ package org.apache.qpid.server.store;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import org.apache.commons.configuration.PropertiesConfiguration;
 
 import org.apache.qpid.AMQException;
@@ -38,6 +39,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.exchange.TopicExchange;
+import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.protocol.v0_8.AMQMessage;
 import org.apache.qpid.server.protocol.v0_8.MessageMetaData;
 import org.apache.qpid.server.model.Broker;
@@ -49,7 +51,7 @@ import org.apache.qpid.server.queue.AMQQ
 import org.apache.qpid.server.queue.BaseQueue;
 import org.apache.qpid.server.queue.ConflationQueue;
 import org.apache.qpid.server.protocol.v0_8.IncomingMessage;
-import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.queue.QueueArgumentsConverter;
 import org.apache.qpid.server.queue.SimpleAMQQueue;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
@@ -83,17 +85,17 @@ public class MessageStoreTest extends Qp
     private String directExchangeName = "MST-DirectExchange";
     private String topicExchangeName = "MST-TopicExchange";
 
-    private AMQShortString durablePriorityTopicQueueName = new AMQShortString("MST-PriorityTopicQueue-Durable");
-    private AMQShortString durableTopicQueueName = new AMQShortString("MST-TopicQueue-Durable");
-    private AMQShortString priorityTopicQueueName = new AMQShortString("MST-PriorityTopicQueue");
-    private AMQShortString topicQueueName = new AMQShortString("MST-TopicQueue");
-
-    private AMQShortString durableExclusiveQueueName = new AMQShortString("MST-Queue-Durable-Exclusive");
-    private AMQShortString durablePriorityQueueName = new AMQShortString("MST-PriorityQueue-Durable");
-    private AMQShortString durableLastValueQueueName = new AMQShortString("MST-LastValueQueue-Durable");
-    private AMQShortString durableQueueName = new AMQShortString("MST-Queue-Durable");
-    private AMQShortString priorityQueueName = new AMQShortString("MST-PriorityQueue");
-    private AMQShortString queueName = new AMQShortString("MST-Queue");
+    private String durablePriorityTopicQueueName = "MST-PriorityTopicQueue-Durable";
+    private String durableTopicQueueName = "MST-TopicQueue-Durable";
+    private String priorityTopicQueueName = "MST-PriorityTopicQueue";
+    private String topicQueueName = "MST-TopicQueue";
+
+    private String durableExclusiveQueueName = "MST-Queue-Durable-Exclusive";
+    private String durablePriorityQueueName = "MST-PriorityQueue-Durable";
+    private String durableLastValueQueueName = "MST-LastValueQueue-Durable";
+    private String durableQueueName = "MST-Queue-Durable";
+    private String priorityQueueName = "MST-PriorityQueue";
+    private String queueName = "MST-Queue";
 
     private AMQShortString directRouting = new AMQShortString("MST-direct");
     private AMQShortString topicRouting = new AMQShortString("MST-topic");
@@ -202,7 +204,7 @@ public class MessageStoreTest extends Qp
      */
     public void testQueueExchangeAndBindingCreation() throws Exception
     {
-        assertEquals("Should not be any existing queues", 0,  getVirtualHost().getQueueRegistry().getQueues().size());
+        assertEquals("Should not be any existing queues", 0,  getVirtualHost().getQueues().size());
 
         createAllQueues();
         createAllTopicQueues();
@@ -240,7 +242,7 @@ public class MessageStoreTest extends Qp
         validateMessageOnTopics(2, true);
 
         assertEquals("Not all queues correctly registered",
-                10, getVirtualHost().getQueueRegistry().getQueues().size());
+                10, getVirtualHost().getQueues().size());
     }
 
     /**
@@ -269,13 +271,11 @@ public class MessageStoreTest extends Qp
     {
         testMessagePersistence();
 
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
         assertEquals("Incorrect number of queues registered after recovery",
-                6,  queueRegistry.getQueues().size());
+                6,  getVirtualHost().getQueues().size());
 
         //clear the queue
-        queueRegistry.getQueue(durableQueueName).clearQueue();
+        _virtualHost.getQueue(durableQueueName).clearQueue();
 
         //check the messages are gone
         validateMessageOnQueue(durableQueueName, 0);
@@ -294,7 +294,7 @@ public class MessageStoreTest extends Qp
     public void testQueuePersistence() throws Exception
     {
         assertEquals("Should not be any existing queues",
-                0, getVirtualHost().getQueueRegistry().getQueues().size());
+                0, getVirtualHost().getQueues().size());
 
         //create durable and non durable queues/topics
         createAllQueues();
@@ -303,20 +303,18 @@ public class MessageStoreTest extends Qp
         //reload the virtual host, prompting recovery of the queues/topics
         reloadVirtualHost();
 
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
         assertEquals("Incorrect number of queues registered after recovery",
-                6,  queueRegistry.getQueues().size());
+                6,  getVirtualHost().getQueues().size());
 
         //Validate the non-Durable Queues were not recovered.
         assertNull("Non-Durable queue still registered:" + priorityQueueName,
-                queueRegistry.getQueue(priorityQueueName));
+                getVirtualHost().getQueue(priorityQueueName));
         assertNull("Non-Durable queue still registered:" + queueName,
-                queueRegistry.getQueue(queueName));
+                getVirtualHost().getQueue(queueName));
         assertNull("Non-Durable queue still registered:" + priorityTopicQueueName,
-                queueRegistry.getQueue(priorityTopicQueueName));
+                getVirtualHost().getQueue(priorityTopicQueueName));
         assertNull("Non-Durable queue still registered:" + topicQueueName,
-                queueRegistry.getQueue(topicQueueName));
+                getVirtualHost().getQueue(topicQueueName));
 
         //Validate normally expected properties of Queues/Topics
         validateDurableQueueProperties();
@@ -336,27 +334,24 @@ public class MessageStoreTest extends Qp
         //Register Durable Queue
         createQueue(durableQueueName, false, true, false, false);
 
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
         assertEquals("Incorrect number of queues registered before recovery",
-                1,  queueRegistry.getQueues().size());
+                1,  getVirtualHost().getQueues().size());
 
         reloadVirtualHost();
 
-        queueRegistry = getVirtualHost().getQueueRegistry();
         assertEquals("Incorrect number of queues registered after first recovery",
-                1,  queueRegistry.getQueues().size());
+                1,  getVirtualHost().getQueues().size());
 
         //test that removing the queue means it is not recovered next time
-        final AMQQueue queue = queueRegistry.getQueue(durableQueueName);
+        final AMQQueue queue = getVirtualHost().getQueue(durableQueueName);
         DurableConfigurationStoreHelper.removeQueue(getVirtualHost().getDurableConfigurationStore(),queue);
 
         reloadVirtualHost();
 
-        queueRegistry = getVirtualHost().getQueueRegistry();
         assertEquals("Incorrect number of queues registered after second recovery",
-                0,  queueRegistry.getQueues().size());
+                0,  getVirtualHost().getQueues().size());
         assertNull("Durable queue was not removed:" + durableQueueName,
-                queueRegistry.getQueue(durableQueueName));
+                getVirtualHost().getQueue(durableQueueName));
     }
 
     /**
@@ -450,34 +445,30 @@ public class MessageStoreTest extends Qp
      */
     public void testDurableBindingRemoval() throws Exception
     {
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
         //create durable queue and exchange, bind them
         Exchange exch = createExchange(DirectExchange.TYPE, directExchangeName, true);
         createQueue(durableQueueName, false, true, false, false);
-        bindQueueToExchange(exch, directRouting, queueRegistry.getQueue(durableQueueName), false, null);
+        bindQueueToExchange(exch, directRouting, getVirtualHost().getQueue(durableQueueName), false, null);
 
         assertEquals("Incorrect number of bindings registered before recovery",
-                1, queueRegistry.getQueue(durableQueueName).getBindings().size());
+                1, getVirtualHost().getQueue(durableQueueName).getBindings().size());
 
         //verify binding is actually normally recovered
         reloadVirtualHost();
 
-        queueRegistry = getVirtualHost().getQueueRegistry();
         assertEquals("Incorrect number of bindings registered after first recovery",
-                1, queueRegistry.getQueue(durableQueueName).getBindings().size());
+                1, getVirtualHost().getQueue(durableQueueName).getBindings().size());
 
         exch = getVirtualHost().getExchange(directExchangeName);
         assertNotNull("Exchange was not recovered", exch);
 
         //remove the binding and verify result after recovery
-        unbindQueueFromExchange(exch, directRouting, queueRegistry.getQueue(durableQueueName), false, null);
+        unbindQueueFromExchange(exch, directRouting, getVirtualHost().getQueue(durableQueueName), false, null);
 
         reloadVirtualHost();
 
-        queueRegistry = getVirtualHost().getQueueRegistry();
         assertEquals("Incorrect number of bindings registered after second recovery",
-                0, queueRegistry.getQueue(durableQueueName).getBindings().size());
+                0, getVirtualHost().getQueue(durableQueueName).getBindings().size());
     }
 
     /**
@@ -514,15 +505,14 @@ public class MessageStoreTest extends Qp
     /** Validates the Durable queues and their properties are as expected following recovery */
     private void validateBindingProperties()
     {
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
 
-        assertEquals("Incorrect number of (durable) queues following recovery", 6, queueRegistry.getQueues().size());
+        assertEquals("Incorrect number of (durable) queues following recovery", 6, getVirtualHost().getQueues().size());
 
-        validateBindingProperties(queueRegistry.getQueue(durablePriorityQueueName).getBindings(), false);
-        validateBindingProperties(queueRegistry.getQueue(durablePriorityTopicQueueName).getBindings(), true);
-        validateBindingProperties(queueRegistry.getQueue(durableQueueName).getBindings(), false);
-        validateBindingProperties(queueRegistry.getQueue(durableTopicQueueName).getBindings(), true);
-        validateBindingProperties(queueRegistry.getQueue(durableExclusiveQueueName).getBindings(), false);
+        validateBindingProperties(getVirtualHost().getQueue(durablePriorityQueueName).getBindings(), false);
+        validateBindingProperties(getVirtualHost().getQueue(durablePriorityTopicQueueName).getBindings(), true);
+        validateBindingProperties(getVirtualHost().getQueue(durableQueueName).getBindings(), false);
+        validateBindingProperties(getVirtualHost().getQueue(durableTopicQueueName).getBindings(), true);
+        validateBindingProperties(getVirtualHost().getQueue(durableExclusiveQueueName).getBindings(), false);
     }
 
     /**
@@ -550,18 +540,14 @@ public class MessageStoreTest extends Qp
 
     private void setQueueExclusivity(boolean exclusive) throws AMQException
     {
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
-        AMQQueue queue = queueRegistry.getQueue(durableExclusiveQueueName);
+        AMQQueue queue = getVirtualHost().getQueue(durableExclusiveQueueName);
 
         queue.setExclusive(exclusive);
     }
 
     private void validateQueueExclusivityProperty(boolean expected)
     {
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
-        AMQQueue queue = queueRegistry.getQueue(durableExclusiveQueueName);
+        AMQQueue queue = getVirtualHost().getQueue(durableExclusiveQueueName);
 
         assertEquals("Queue exclusivity was incorrect", queue.isExclusive(), expected);
     }
@@ -569,14 +555,12 @@ public class MessageStoreTest extends Qp
 
     private void validateDurableQueueProperties()
     {
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
-        validateQueueProperties(queueRegistry.getQueue(durablePriorityQueueName), true, true, false, false);
-        validateQueueProperties(queueRegistry.getQueue(durablePriorityTopicQueueName), true, true, false, false);
-        validateQueueProperties(queueRegistry.getQueue(durableQueueName), false, true, false, false);
-        validateQueueProperties(queueRegistry.getQueue(durableTopicQueueName), false, true, false, false);
-        validateQueueProperties(queueRegistry.getQueue(durableExclusiveQueueName), false, true, true, false);
-        validateQueueProperties(queueRegistry.getQueue(durableLastValueQueueName), false, true, true, true);
+        validateQueueProperties(getVirtualHost().getQueue(durablePriorityQueueName), true, true, false, false);
+        validateQueueProperties(getVirtualHost().getQueue(durablePriorityTopicQueueName), true, true, false, false);
+        validateQueueProperties(getVirtualHost().getQueue(durableQueueName), false, true, false, false);
+        validateQueueProperties(getVirtualHost().getQueue(durableTopicQueueName), false, true, false, false);
+        validateQueueProperties(getVirtualHost().getQueue(durableExclusiveQueueName), false, true, true, false);
+        validateQueueProperties(getVirtualHost().getQueue(durableLastValueQueueName), false, true, true, true);
     }
 
     private void validateQueueProperties(AMQQueue queue, boolean usePriority, boolean durable, boolean exclusive, boolean lastValueQueue)
@@ -724,10 +708,10 @@ public class MessageStoreTest extends Qp
         createQueue(topicQueueName, false, false, false, false);
     }
 
-    private void createQueue(AMQShortString queueName, boolean usePriority, boolean durable, boolean exclusive, boolean lastValueQueue)
+    private void createQueue(String queueName, boolean usePriority, boolean durable, boolean exclusive, boolean lastValueQueue)
     {
 
-        FieldTable queueArguments = null;
+        Map<String,Object> queueArguments = null;
 
         if(usePriority || lastValueQueue)
         {
@@ -736,14 +720,12 @@ public class MessageStoreTest extends Qp
 
         if (usePriority)
         {
-            queueArguments = new FieldTable();
-            queueArguments.put(new AMQShortString(AMQQueueFactory.X_QPID_PRIORITIES), DEFAULT_PRIORTY_LEVEL);
+            queueArguments = Collections.singletonMap(Queue.PRIORITIES, (Object) DEFAULT_PRIORTY_LEVEL);
         }
 
         if (lastValueQueue)
         {
-            queueArguments = new FieldTable();
-            queueArguments.put(new AMQShortString(AMQQueueFactory.QPID_LAST_VALUE_QUEUE_KEY), LVQ_KEY);
+            queueArguments = Collections.singletonMap(Queue.LVQ_KEY, (Object) LVQ_KEY);
         }
 
         AMQQueue queue = null;
@@ -751,25 +733,17 @@ public class MessageStoreTest extends Qp
         //Ideally we would be able to use the QueueDeclareHandler here.
         try
         {
-            queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), queueName.asString(), durable, queueOwner.asString(), false, exclusive,
-                    getVirtualHost(), FieldTable.convertToMap(queueArguments));
+            queue = getVirtualHost().createQueue(UUIDGenerator.generateRandomUUID(), queueName, durable, queueOwner.asString(), false, exclusive,
+                    false, queueArguments);
 
             validateQueueProperties(queue, usePriority, durable, exclusive, lastValueQueue);
 
-            if (queue.isDurable() && !queue.isAutoDelete())
-            {
-                DurableConfigurationStoreHelper.createQueue(getVirtualHost().getDurableConfigurationStore(),
-                        queue,
-                        queueArguments);
-            }
         }
         catch (AMQException e)
         {
             fail(e.getMessage());
         }
 
-        getVirtualHost().getQueueRegistry().registerQueue(queue);
-
     }
 
     private Map<String, Exchange> createExchanges()
@@ -805,28 +779,24 @@ public class MessageStoreTest extends Qp
     private void bindAllQueuesToExchange(Exchange exchange, AMQShortString routingKey)
     {
         FieldTable queueArguments = new FieldTable();
-        queueArguments.put(new AMQShortString(AMQQueueFactory.X_QPID_PRIORITIES), DEFAULT_PRIORTY_LEVEL);
+        queueArguments.put(new AMQShortString(QueueArgumentsConverter.X_QPID_PRIORITIES), DEFAULT_PRIORTY_LEVEL);
 
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
-
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(durablePriorityQueueName), false, queueArguments);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(durableQueueName), false, null);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(priorityQueueName), false, queueArguments);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(queueName), false, null);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(durableExclusiveQueueName), false, null);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(durablePriorityQueueName), false, queueArguments);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(durableQueueName), false, null);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(priorityQueueName), false, queueArguments);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(queueName), false, null);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(durableExclusiveQueueName), false, null);
     }
 
     private void bindAllTopicQueuesToExchange(Exchange exchange, AMQShortString routingKey)
     {
         FieldTable queueArguments = new FieldTable();
-        queueArguments.put(new AMQShortString(AMQQueueFactory.X_QPID_PRIORITIES), DEFAULT_PRIORTY_LEVEL);
-
-        QueueRegistry queueRegistry = getVirtualHost().getQueueRegistry();
+        queueArguments.put(new AMQShortString(QueueArgumentsConverter.X_QPID_PRIORITIES), DEFAULT_PRIORTY_LEVEL);
 
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(durablePriorityTopicQueueName), true, queueArguments);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(durableTopicQueueName), true, null);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(priorityTopicQueueName), true, queueArguments);
-        bindQueueToExchange(exchange, routingKey, queueRegistry.getQueue(topicQueueName), true, null);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(durablePriorityTopicQueueName), true, queueArguments);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(durableTopicQueueName), true, null);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(priorityTopicQueueName), true, queueArguments);
+        bindQueueToExchange(exchange, routingKey, getVirtualHost().getQueue(topicQueueName), true, null);
     }
 
 
@@ -894,9 +864,9 @@ public class MessageStoreTest extends Qp
         }
     }
 
-    private void validateMessageOnQueue(AMQShortString queueName, long messageCount)
+    private void validateMessageOnQueue(String queueName, long messageCount)
     {
-        AMQQueue queue = getVirtualHost().getQueueRegistry().getQueue(queueName);
+        AMQQueue queue = getVirtualHost().getQueue(queueName);
 
         assertNotNull("Queue(" + queueName + ") not correctly registered:", queue);
 



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


Mime
View raw message