diff options
author | Alex Rudyy <orudyy@apache.org> | 2012-12-12 17:41:59 +0000 |
---|---|---|
committer | Alex Rudyy <orudyy@apache.org> | 2012-12-12 17:41:59 +0000 |
commit | 5f0181ccd077960610d85081fe044a1418e86829 (patch) | |
tree | 03b240b8a44c779b13be24ffc0df5d9c5cb408a1 | |
parent | 2d2afa4e53cd03b50a0dfd7344bc8f50886ca98a (diff) | |
download | qpid-python-5f0181ccd077960610d85081fe044a1418e86829.tar.gz |
Improve queue configuration tests
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-config-qpid-4390@1420871 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 34 insertions, 62 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AbstractBrokerChildRecoverer.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AbstractBrokerChildRecoverer.java deleted file mode 100644 index 8cce34fbc4..0000000000 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AbstractBrokerChildRecoverer.java +++ /dev/null @@ -1,53 +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.startup; - -import org.apache.qpid.server.configuration.ConfigurationEntry; -import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; -import org.apache.qpid.server.configuration.RecovererProvider; -import org.apache.qpid.server.model.Broker; -import org.apache.qpid.server.model.ConfiguredObject; - -public abstract class AbstractBrokerChildRecoverer<T extends ConfiguredObject> implements ConfiguredObjectRecoverer<T> -{ - - @Override - public T create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents) - { - if (parents == null || parents.length == 0) - { - throw new IllegalArgumentException("Broker parent is not passed!"); - } - if (parents.length != 1) - { - throw new IllegalArgumentException("Only one parent is expected!"); - } - if (!(parents[0] instanceof Broker)) - { - throw new IllegalArgumentException("Parent is not a broker"); - } - Broker broker = (Broker)parents[0]; - return createBrokerChild(recovererProvider, entry, broker); - } - - abstract T createBrokerChild(RecovererProvider recovererProvider, ConfigurationEntry entry, Broker broker); - -} diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java index 3f4357ecde..eb407d35b3 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/QueueConfigurationTest.java @@ -20,17 +20,18 @@ */ package org.apache.qpid.server.configuration; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import junit.framework.TestCase; import org.apache.commons.configuration.CompositeConfiguration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.qpid.server.model.Broker; -import org.mockito.Mockito; public class QueueConfigurationTest extends TestCase { - private VirtualHostConfiguration _emptyConf; private PropertiesConfiguration _env; private VirtualHostConfiguration _fullHostConf; @@ -38,7 +39,7 @@ public class QueueConfigurationTest extends TestCase public void setUp() throws Exception { - _broker = Mockito.mock(Broker.class); + _broker = mock(Broker.class); _env = new PropertiesConfiguration(); _emptyConf = new VirtualHostConfiguration("test", _env, _broker); @@ -57,12 +58,20 @@ public class QueueConfigurationTest extends TestCase public void testMaxDeliveryCount() throws Exception { - Mockito.when(_broker.getAttribute(Broker.MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(0); + // broker MAXIMUM_DELIVERY_ATTEMPTS attribute is not set + when(_broker.getAttribute(Broker.MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(null); // Check default value QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf); assertEquals("Unexpected default server configuration for max delivery count ", 0, qConf.getMaxDeliveryCount()); + // set broker MAXIMUM_DELIVERY_ATTEMPTS attribute to 2 + when(_broker.getAttribute(Broker.MAXIMUM_DELIVERY_ATTEMPTS)).thenReturn(2); + + // Check that queue inherits the MAXIMUM_DELIVERY_ATTEMPTS value from broker + qConf = new QueueConfiguration("test", _emptyConf); + assertEquals("Unexpected default server configuration for max delivery count ", 2, qConf.getMaxDeliveryCount()); + // Check explicit value VirtualHostConfiguration vhostConfig = overrideConfiguration("maximumDeliveryCount", 7); qConf = new QueueConfiguration("test", vhostConfig); @@ -80,10 +89,18 @@ public class QueueConfigurationTest extends TestCase */ public void testIsDeadLetterQueueEnabled() throws Exception { - Mockito.when(_broker.getAttribute(Broker.DEAD_LETTER_QUEUE_ENABLED)).thenReturn(false); + // enable dead letter queues broker wide + when(_broker.getAttribute(Broker.DEAD_LETTER_QUEUE_ENABLED)).thenReturn(true); - // Check default value + // Check that queue inherits the broker setting QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf); + assertTrue("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled()); + + // broker DEAD_LETTER_QUEUE_ENABLED is not set + when(_broker.getAttribute(Broker.DEAD_LETTER_QUEUE_ENABLED)).thenReturn(null); + + // Check that queue dead letter queue is not enabled + qConf = new QueueConfiguration("test", _emptyConf); assertFalse("Unexpected queue configuration for dead letter enabled attribute", qConf.isDeadLetterQueueEnabled()); // Check explicit value @@ -163,11 +180,19 @@ public class QueueConfigurationTest extends TestCase public void testGetMinimumAlertRepeatGap() throws Exception { - Mockito.when(_broker.getAttribute(Broker.ALERT_REPEAT_GAP)).thenReturn(ServerConfiguration.DEFAULT_MINIMUM_ALERT_REPEAT_GAP); + // set broker attribute ALERT_REPEAT_GAP to 10 + when(_broker.getAttribute(Broker.ALERT_REPEAT_GAP)).thenReturn(10); - // Check default value + // check that broker level setting is available on queue configuration QueueConfiguration qConf = new QueueConfiguration("test", _emptyConf); - assertEquals(ServerConfiguration.DEFAULT_MINIMUM_ALERT_REPEAT_GAP, qConf.getMinimumAlertRepeatGap()); + assertEquals(10, qConf.getMinimumAlertRepeatGap()); + + // remove configuration for ALERT_REPEAT_GAP on broker level + when(_broker.getAttribute(Broker.ALERT_REPEAT_GAP)).thenReturn(null); + + // Check default value + qConf = new QueueConfiguration("test", _emptyConf); + assertEquals(0, qConf.getMinimumAlertRepeatGap()); // Check explicit value VirtualHostConfiguration vhostConfig = overrideConfiguration("minimumAlertRepeatGap", 2); |