diff options
10 files changed, 13 insertions, 707 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigurationPlugin.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigurationPlugin.java deleted file mode 100644 index bfb2de4235..0000000000 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ExchangeConfigurationPlugin.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.configuration; - -import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin; -import org.apache.qpid.server.queue.AMQQueue; - -public interface ExchangeConfigurationPlugin -{ - ConfigurationPlugin getConfiguration(AMQQueue queue); -} diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java index cb7f8b2931..38ec5fe53d 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java @@ -193,43 +193,4 @@ public class QueueConfiguration extends ConfigurationPlugin { return getBooleanValue("deadLetterQueues", _vHostConfig.isDeadLetterQueueEnabled()); } - - public static class QueueConfig extends ConfigurationPlugin - { - @Override - public String[] getElementsProcessed() - { - return new String[]{"name"}; - } - - public String getName() - { - return getStringValue("name"); - } - - - public void validateConfiguration() throws ConfigurationException - { - if (getConfig().isEmpty()) - { - throw new ConfigurationException("Queue section cannot be empty."); - } - - if (getName() == null) - { - throw new ConfigurationException("Queue section must have a 'name' element."); - } - - } - - - @Override - public String formatToString() - { - return "Name:"+getName(); - } - - - } - } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java deleted file mode 100644 index aaa1766489..0000000000 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfig.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.configuration; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; - -import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin; - -public class TopicConfig extends ConfigurationPlugin -{ - public TopicConfig() - { - setConfig(new PropertiesConfiguration()); - } - - @Override - public String[] getElementsProcessed() - { - return new String[]{"name", "subscriptionName"}; - } - - public String getName() - { - // If we don't have a specific topic then this config is for all topics. - return getStringValue("name", "#"); - } - - public String getSubscriptionName() - { - return getStringValue("subscriptionName"); - } - - public void validateConfiguration() throws ConfigurationException - { - if (getConfig().isEmpty()) - { - throw new ConfigurationException("Topic section cannot be empty."); - } - - if (getStringValue("name") == null && getSubscriptionName() == null) - { - throw new ConfigurationException("Topic section must have a 'name' or 'subscriptionName' element."); - } - - } - - - @Override - public String formatToString() - { - String response = "Topic:"+getName(); - if (getSubscriptionName() != null) - { - response += ", SubscriptionName:"+getSubscriptionName(); - } - - return response; - } -}
\ No newline at end of file diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java deleted file mode 100644 index feafd3de1d..0000000000 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/TopicConfiguration.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.configuration; - -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; - -import org.apache.qpid.server.binding.Binding; -import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin; -import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory; -import org.apache.qpid.server.exchange.TopicExchange; -import org.apache.qpid.server.queue.AMQQueue; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class TopicConfiguration extends ConfigurationPlugin implements ExchangeConfigurationPlugin -{ - public static final ConfigurationPluginFactory FACTORY = new TopicConfigurationFactory(); - - private static final String VIRTUALHOSTS_VIRTUALHOST_TOPICS = "virtualhosts.virtualhost.topics"; - - public static class TopicConfigurationFactory implements ConfigurationPluginFactory - { - - public ConfigurationPlugin newInstance(String path, Configuration config) throws ConfigurationException - { - TopicConfiguration topicsConfig = new TopicConfiguration(); - topicsConfig.setConfiguration(path, config); - return topicsConfig; - } - - public List<String> getParentPaths() - { - return Arrays.asList(VIRTUALHOSTS_VIRTUALHOST_TOPICS); - } - } - - private Map<String, TopicConfig> _topics = new HashMap<String, TopicConfig>(); - private Map<String, Map<String, TopicConfig>> _subscriptions = new HashMap<String, Map<String, TopicConfig>>(); - - public String[] getElementsProcessed() - { - return new String[]{"topic"}; - } - - @Override - public void validateConfiguration() throws ConfigurationException - { - if (getConfig().isEmpty()) - { - throw new ConfigurationException("Topics section cannot be empty."); - } - - int topics = getConfig().getList("topic.name").size() + - getConfig().getList("topic.subscriptionName").size(); - - for (int index = 0; index < topics; index++) - { - Configuration topicSubset = getConfig().subset("topic(" + index + ")"); - - // This will occur when we have a subscriptionName that is bound to a - // topic. - if (topicSubset.isEmpty()) - { - break; - } - - TopicConfig topic = new TopicConfig(); - - topic.setConfiguration(VIRTUALHOSTS_VIRTUALHOST_TOPICS + ".topic", topicSubset ); - - String name = getConfig().getString("topic(" + index + ").name"); - String subscriptionName = getConfig().getString("topic(" + index + ").subscriptionName"); - - // Record config if subscriptionName is there - if (subscriptionName != null) - { - processSubscription(subscriptionName, topic); - } - else - { - // Otherwise record config as topic if we have the name - if (name != null) - { - processTopic(name, topic); - } - } - } - } - - /** - * @param name - * @param topic - * - * @throws org.apache.commons.configuration.ConfigurationException - * - */ - private void processTopic(String name, TopicConfig topic) throws ConfigurationException - { - if (_topics.containsKey(name)) - { - throw new ConfigurationException("Topics section cannot contain two entries for the same topic."); - } - else - { - _topics.put(name, topic); - } - } - - - private void processSubscription(String name, TopicConfig topic) throws ConfigurationException - { - Map<String,TopicConfig> topics; - if (_subscriptions.containsKey(name)) - { - topics = _subscriptions.get(name); - - if (topics.containsKey(topic.getName())) - { - throw new ConfigurationException("Subcription cannot contain two entries for the same topic."); - } - } - else - { - topics = new HashMap<String,TopicConfig>(); - } - - topics.put(topic.getName(),topic); - _subscriptions.put(name, topics); - - } - - @Override - public String formatToString() - { - return "Topics:" + _topics + ", Subscriptions:" + _subscriptions; - } - - /** - * This processes the given queue and apply configuration in the following - * order: - * - * Global Topic Values -> Topic Values -> Subscription Values - * - * @param queue - * - * @return - */ - public ConfigurationPlugin getConfiguration(AMQQueue queue) - { - //Create config with global topic configuration - TopicConfig config = new TopicConfig(); - - // Add global topic configuration - config.addConfiguration(this); - - // Process Topic Bindings as these are more generic than subscriptions - List<TopicConfig> boundToTopics = new LinkedList<TopicConfig>(); - - //Merge the configuration in the order that they are bound - for (Binding binding : queue.getBindings()) - { - if (binding.getExchange().getType().equals(TopicExchange.TYPE)) - { - // Identify topic for the binding key - TopicConfig topicConfig = getTopicConfigForRoutingKey(binding.getBindingKey()); - if (topicConfig != null) - { - boundToTopics.add(topicConfig); - } - } - } - - // If the Queue is bound to a number of topics then only use the global - // topic configuration. - // todo - What does it mean in terms of configuration to be bound to a - // number of topics? Do we try and merge? - // YES - right thing to do would be to merge from generic to specific. - // Means we need to be able to get an ordered list of topics for this - // binding. - if (boundToTopics.size() == 1) - { - config.addConfiguration(boundToTopics.get(0)); - } - - // If we have a subscription then attempt to look it up. - String subscriptionName = queue.getName(); - - // Apply subscription configurations - if (_subscriptions.containsKey(subscriptionName)) - { - - //Get all the Configuration that this subscription is bound to. - Map<String, TopicConfig> topics = _subscriptions.get(subscriptionName); - - TopicConfig subscriptionSpecificConfig = null; - - // See if we have a TopicConfig in topics for a topic we are bound to. - for (Binding binding : queue.getBindings()) - { - if (binding.getExchange().getType().equals(TopicExchange.TYPE)) - { - //todo - What does it mean to have multiple matches? - // Take the first match we get - if (subscriptionSpecificConfig == null) - { - // lookup the binding to see if we have a match in the subscription configs - subscriptionSpecificConfig = topics.get(binding.getBindingKey()); - } - } - } - - //todo we don't account for wild cards here. only explicit matching and all subscriptions - if (subscriptionSpecificConfig == null) - { - // lookup the binding to see if we have a match in the subscription configs - subscriptionSpecificConfig = topics.get("#"); - } - - // Apply subscription specific config. - if (subscriptionSpecificConfig != null) - { - config.addConfiguration(subscriptionSpecificConfig); - } - } - return config; - } - - /** - * This method should perform the same heuristics as the TopicExchange - * to attempt to identify a piece of configuration for the give routingKey. - * - * i.e. If we have 'stocks.*' defined in the config - * and we bind 'stocks.appl' then we should return the 'stocks.*' - * configuration. - * - * @param routingkey the key to lookup - * - * @return the TopicConfig if found. - */ - private TopicConfig getTopicConfigForRoutingKey(String routingkey) - { - //todo actually perform TopicExchange style lookup not just straight - // lookup as we are just now. - return _topics.get(routingkey); - } - -} diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java index e557085631..0d59118647 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java @@ -23,18 +23,11 @@ package org.apache.qpid.server.configuration; import org.apache.commons.configuration.CompositeConfiguration; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.server.binding.Binding; import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin; -import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.registry.ApplicationRegistry; import org.apache.qpid.server.store.MemoryMessageStore; -import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -149,105 +142,6 @@ public class VirtualHostConfiguration extends ConfigurationPlugin } } - public ConfigurationPlugin getQueueConfiguration(AMQQueue queue) - { - VirtualHostConfiguration hostConfig = queue.getVirtualHost().getConfiguration(); - - // First check if we have a named queue configuration (the easy case) - if (Arrays.asList(hostConfig.getQueueNames()).contains(queue.getName())) - { - return null; - } - - // We don't have an explicit queue config we must find out what we need. - ArrayList<Binding> bindings = new ArrayList<Binding>(queue.getBindings()); - - List<AMQShortString> exchangeClasses = new ArrayList<AMQShortString>(bindings.size()); - - //Remove default exchange - for (int index = 0; index < bindings.size(); index++) - { - // Ignore the DEFAULT Exchange binding - if (bindings.get(index).getExchange().getNameShortString().equals(ExchangeDefaults.DEFAULT_EXCHANGE_NAME)) - { - bindings.remove(index); - } - else - { - exchangeClasses.add(bindings.get(index).getExchange().getType().getName()); - - if (exchangeClasses.size() > 1) - { - // If we have more than 1 class of exchange then we can only use the global queue configuration. - // and this will be returned from the default getQueueConfiguration - return null; - } - } - } - - // If we are just bound the the default exchange then use the default. - if (bindings.isEmpty()) - { - return null; - } - - // If we are bound to only one type of exchange then we are going - // to have to resolve the configuration for that exchange. - - String exchangeName = bindings.get(0).getExchange().getType().getName().toString(); - - // Lookup a Configuration handler for this Exchange. - - // Build the expected class name. <Exchangename>sConfiguration - // i.e. TopicConfiguration or HeadersConfiguration - String exchangeClass = "org.apache.qpid.server.configuration." - + exchangeName.substring(0, 1).toUpperCase() - + exchangeName.substring(1) + "Configuration"; - - ExchangeConfigurationPlugin exchangeConfiguration - = (ExchangeConfigurationPlugin) queue.getVirtualHost().getConfiguration().getConfiguration(exchangeClass); - - // now need to perform the queue-topic-topics-queues magic. - // So make a new ConfigurationObject that will hold all the configuration for this queue. - ConfigurationPlugin queueConfig = new QueueConfiguration.QueueConfig(); - - // Initialise the queue with any Global values we may have - PropertiesConfiguration newQueueConfig = new PropertiesConfiguration(); - newQueueConfig.setProperty("name", queue.getName()); - - try - { - //Set the queue name - CompositeConfiguration mungedConf = new CompositeConfiguration(); - //Set the queue name - mungedConf.addConfiguration(newQueueConfig); - //Set the global queue configuration - mungedConf.addConfiguration(getConfig().subset("queues")); - - // Set configuration - queueConfig.setConfiguration("virtualhosts.virtualhost.queues", mungedConf); - } - catch (ConfigurationException e) - { - // This will not occur as queues only require a name. - _logger.error("QueueConfiguration requirements have changed."); - } - - // Merge any configuration the Exchange wishes to apply - if (exchangeConfiguration != null) - { - queueConfig.addConfiguration(exchangeConfiguration.getConfiguration(queue)); - } - - //Finally merge in any specific queue configuration we have. - if (_queues.containsKey(queue.getName())) - { - queueConfig.addConfiguration(_queues.get(queue.getName())); - } - - return queueConfig; - } - public int getMaximumMessageAge() { return getIntValue("queues.maximumMessageAge"); diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java index b452504683..2080e44467 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginManager.java @@ -34,7 +34,6 @@ import org.apache.felix.framework.util.StringMap; import org.apache.log4j.Logger; import org.apache.qpid.common.Closeable; import org.apache.qpid.common.QpidProperties; -import org.apache.qpid.server.configuration.TopicConfiguration; import org.apache.qpid.server.configuration.plugins.ConfigurationPluginFactory; import org.apache.qpid.server.exchange.ExchangeType; import org.apache.qpid.server.security.SecurityManager; @@ -148,7 +147,6 @@ public class PluginManager implements Closeable _securityPlugins.put(pluginFactory.getPluginName(), pluginFactory); } for (ConfigurationPluginFactory configFactory : Arrays.asList( - TopicConfiguration.FACTORY, SecurityManager.SecurityConfiguration.FACTORY, LegacyAccess.LegacyAccessConfiguration.FACTORY, PrincipalDatabaseAuthenticationManager.PrincipalDatabaseAuthenticationManagerConfiguration.FACTORY, diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java index 868c803ae7..4f610cc925 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java @@ -23,7 +23,7 @@ package org.apache.qpid.server.queue; import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.server.binding.Binding; -import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin; +import org.apache.qpid.server.configuration.QueueConfiguration; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.exchange.ExchangeReferrer; import org.apache.qpid.server.logging.LogSubject; @@ -277,9 +277,7 @@ public interface AMQQueue extends Comparable<AMQQueue>, ExchangeReferrer, Transa public void doTask(AMQQueue queue) throws AMQException; } - void configure(ConfigurationPlugin config); - - ConfigurationPlugin getConfiguration(); + void configure(QueueConfiguration config); void setExclusive(boolean exclusive); diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java index 3376bfa53f..3c0c8d2029 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java @@ -598,24 +598,6 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener, Mes break; } } - - reconfigure(); - } - - private void reconfigure() - { - //Reconfigure the queue for to reflect this new binding. - ConfigurationPlugin config = getVirtualHost().getConfiguration().getQueueConfiguration(this); - - if (config != null) - { - if (_logger.isDebugEnabled()) - { - _logger.debug("Reconfiguring queue(" + this + ") with config:" + config + " was "+ _queueConfiguration); - } - // Reconfigure with new config. - configure(config); - } } public int getBindingCountHigh() @@ -626,8 +608,6 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener, Mes public void removeBinding(final Binding binding) { _bindings.remove(binding); - - reconfigure(); } public List<Binding> getBindings() @@ -2137,34 +2117,21 @@ public class SimpleAMQQueue implements AMQQueue, Subscription.StateListener, Mes } - public void configure(ConfigurationPlugin config) + public void configure(QueueConfiguration config) { if (config != null) { - if (config instanceof QueueConfiguration) - { - - setMaximumMessageAge(((QueueConfiguration)config).getMaximumMessageAge()); - setMaximumQueueDepth(((QueueConfiguration)config).getMaximumQueueDepth()); - setMaximumMessageSize(((QueueConfiguration)config).getMaximumMessageSize()); - setMaximumMessageCount(((QueueConfiguration)config).getMaximumMessageCount()); - setMinimumAlertRepeatGap(((QueueConfiguration)config).getMinimumAlertRepeatGap()); - setMaximumDeliveryCount(((QueueConfiguration)config).getMaxDeliveryCount()); - _capacity = ((QueueConfiguration)config).getCapacity(); - _flowResumeCapacity = ((QueueConfiguration)config).getFlowResumeCapacity(); - } - - _queueConfiguration = config; - + setMaximumMessageAge(config.getMaximumMessageAge()); + setMaximumQueueDepth(config.getMaximumQueueDepth()); + setMaximumMessageSize(config.getMaximumMessageSize()); + setMaximumMessageCount(config.getMaximumMessageCount()); + setMinimumAlertRepeatGap(config.getMinimumAlertRepeatGap()); + setMaximumDeliveryCount(config.getMaxDeliveryCount()); + _capacity = config.getCapacity(); + _flowResumeCapacity = config.getFlowResumeCapacity(); } } - - public ConfigurationPlugin getConfiguration() - { - return _queueConfiguration; - } - public long getMessageDequeueCount() { return _dequeueCount.get(); diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java deleted file mode 100644 index caf74a89ec..0000000000 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/TopicConfigurationTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.configuration; - -import org.apache.commons.configuration.ConfigurationException; - -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.server.exchange.Exchange; -import org.apache.qpid.server.model.UUIDGenerator; -import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.queue.AMQQueueFactory; -import org.apache.qpid.server.util.InternalBrokerBaseCase; - -/** - * Test of the new Topic configuration processing - */ -public class TopicConfigurationTest extends InternalBrokerBaseCase -{ - - @Override - public void configure() - { - getConfigXml().addProperty("virtualhosts.virtualhost.test.topics.topic.name", "stocks.nyse.appl"); - - getConfigXml().addProperty("virtualhosts.virtualhost.test.topics.topic(1).subscriptionName", getName()+":stockSubscription"); - - getConfigXml().addProperty("virtualhosts.virtualhost.test.topics.topic(2).name", "stocks.nyse.orcl"); - getConfigXml().addProperty("virtualhosts.virtualhost.test.topics.topic(2).subscriptionName", getName()+":stockSubscription"); - } - - /** - * Test that a TopicConfig object is created and attached to the queue when it is bound to the topic exchange. - * - - * @throws ConfigurationException - * @throws AMQSecurityException - */ - public void testTopicCreation() throws ConfigurationException, AMQSecurityException, AMQInternalException - { - Exchange topicExchange = getVirtualHost().getExchangeRegistry().getExchange(ExchangeDefaults.TOPIC_EXCHANGE_NAME); - getVirtualHost().getBindingFactory().addBinding("stocks.nyse.appl", getQueue(), topicExchange, null); - - TopicConfig config = getQueue().getConfiguration().getConfiguration(TopicConfig.class.getName()); - - assertNotNull("Queue should have topic configuration bound to it.", config); - assertEquals("Configuration name not correct", "stocks.nyse.appl", config.getName()); - } - - /** - * Test that a queue created for a subscription correctly has topic - * configuration selected based on the subscription and topic name. - * - * @throws ConfigurationException - * @throws AMQException - */ - public void testSubscriptionWithTopicCreation() throws ConfigurationException, AMQException - { - - AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID(), getName()+":stockSubscription", false, "testowner", - false, false, getVirtualHost(), null); - - getVirtualHost().getQueueRegistry().registerQueue(queue); - Exchange defaultExchange = getVirtualHost().getExchangeRegistry().getDefaultExchange(); - getVirtualHost().getBindingFactory().addBinding(getName(), queue, defaultExchange, null); - - - Exchange topicExchange = getVirtualHost().getExchangeRegistry().getExchange(ExchangeDefaults.TOPIC_EXCHANGE_NAME); - getVirtualHost().getBindingFactory().addBinding("stocks.nyse.orcl", queue, topicExchange, null); - - TopicConfig config = queue.getConfiguration().getConfiguration(TopicConfig.class.getName()); - - assertNotNull("Queue should have topic configuration bound to it.", config); - assertEquals("Configuration subscription name not correct", getName() + ":stockSubscription", config.getSubscriptionName()); - assertEquals("Configuration name not correct", "stocks.nyse.orcl", config.getName()); - - } - - /** - * Test that a queue created for a subscription correctly has topic - * configuration attached here this should be the generic topic section - * with just the subscriptionName - * - * @throws ConfigurationException - * @throws AMQException - */ - public void testSubscriptionCreation() throws ConfigurationException, AMQException - { - - AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateRandomUUID() ,getName()+":stockSubscription", false, "testowner", - false, false, getVirtualHost(), null); - - getVirtualHost().getQueueRegistry().registerQueue(queue); - Exchange defaultExchange = getVirtualHost().getExchangeRegistry().getDefaultExchange(); - getVirtualHost().getBindingFactory().addBinding(getName(), queue, defaultExchange, null); - - - Exchange topicExchange = getVirtualHost().getExchangeRegistry().getExchange(ExchangeDefaults.TOPIC_EXCHANGE_NAME); - getVirtualHost().getBindingFactory().addBinding("stocks.nyse.ibm", queue, topicExchange, null); - - TopicConfig config = queue.getConfiguration().getConfiguration(TopicConfig.class.getName()); - - assertNotNull("Queue should have topic configuration bound to it.", config); - assertEquals("Configuration subscription name not correct", getName() + ":stockSubscription", config.getSubscriptionName()); - assertEquals("Configuration name not correct", "#", config.getName()); - - } - - - -} diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java index c6235f2f45..63d4d196e1 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java @@ -23,6 +23,7 @@ package org.apache.qpid.server.queue; import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.server.binding.Binding; +import org.apache.qpid.server.configuration.QueueConfiguration; import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.logging.LogSubject; @@ -508,16 +509,11 @@ public class MockAMQQueue implements AMQQueue } - public void configure(ConfigurationPlugin config) + public void configure(QueueConfiguration config) { } - public ConfigurationPlugin getConfiguration() - { - return null; - } - public AuthorizationHolder getAuthorizationHolder() { return _authorizationHolder; |