diff options
| author | Keith Wall <kwall@apache.org> | 2014-11-04 17:17:33 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2014-11-04 17:17:33 +0000 |
| commit | a98acc0623cba6643e94c3e7bbaee67a955e7b98 (patch) | |
| tree | 99bcf6daa460fe75f8e3f5f63c08a7f55dbb6946 /qpid/java | |
| parent | 3cf16baf5d75441f6dd02aeda5ff793de6b27c93 (diff) | |
| download | qpid-python-a98acc0623cba6643e94c3e7bbaee67a955e7b98.tar.gz | |
QPID-6210: [Java Broker] VHMBean#createNewQueue revert to throwing IllegalArgumentException if the queue does not exist
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1636648 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
2 files changed, 28 insertions, 1 deletions
diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java index e0c871c283..3b3d6b9cd2 100644 --- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java +++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java @@ -50,6 +50,7 @@ import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.queue.QueueArgumentsConverter; import org.apache.qpid.server.virtualhost.ExchangeExistsException; +import org.apache.qpid.server.virtualhost.QueueExistsException; import org.apache.qpid.server.virtualhost.RequiredExchangeException; import org.apache.qpid.server.virtualhost.ReservedExchangeNameException; @@ -246,7 +247,14 @@ public class VirtualHostManagerMBean extends AbstractStatisticsGatheringMBean<Vi attributes.put(Queue.DURABLE, durable); attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT); - getConfiguredObject().createQueue(attributes); + try + { + getConfiguredObject().createQueue(attributes); + } + catch (QueueExistsException qee) + { + throw new IllegalArgumentException("Queue with name '" + queueName + "' already exists"); + } } diff --git a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java index dc3bf2d9f1..5a804e7605 100644 --- a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java +++ b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java @@ -25,6 +25,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doThrow; import java.util.Collections; import java.util.Map; @@ -41,6 +43,7 @@ import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Queue; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.queue.QueueArgumentsConverter; +import org.apache.qpid.server.virtualhost.QueueExistsException; public class VirtualHostManagerMBeanTest extends TestCase { @@ -117,6 +120,22 @@ public class VirtualHostManagerMBeanTest extends TestCase assertEquals(TEST_DESCRIPTION, actualAttributes.get(Queue.DESCRIPTION)); } + public void testCreateQueueThatAlreadyExists() throws Exception + { + doThrow(new QueueExistsException("mocked exception", null)).when(_mockVirtualHost).createQueue(any(Map.class)); + + try + { + _virtualHostManagerMBean.createNewQueue(TEST_QUEUE_NAME, TEST_OWNER, true); + fail("Exception not thrown"); + } + catch (IllegalArgumentException iae) + { + // PASS + } + + } + public void testDeleteQueue() throws Exception { Queue mockQueue = mock(Queue.class); |
