summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/management-jmx/src
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-04-18 13:37:32 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-04-18 13:37:32 +0000
commitef4adc559cc4b81a0c681807986c62fc0b9a13e4 (patch)
treea66bb7845d9074bb79253f11bd5636c9a30e5324 /qpid/java/broker-plugins/management-jmx/src
parent36c6512134a729f2f7abb1fa6469a63b743dad1b (diff)
downloadqpid-python-ef4adc559cc4b81a0c681807986c62fc0b9a13e4.tar.gz
QPID-5710 : [Java Broker] Use common creation/recovery mechanism for Queues
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1588468 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/management-jmx/src')
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java14
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java9
2 files changed, 16 insertions, 7 deletions
diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
index e95ed9a383..a9fc160618 100644
--- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
+++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
@@ -24,6 +24,7 @@ package org.apache.qpid.server.jmx.mbeans;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import javax.management.JMException;
@@ -294,14 +295,19 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
{
if (exchangeName == null || "".equals(exchangeName))
{
- _queue.setAttribute(Queue.ALTERNATE_EXCHANGE, getAlternateExchange(), null);
+ _queue.setAttributes(Collections.singletonMap(Queue.ALTERNATE_EXCHANGE, null));
}
else
{
- VirtualHost<?,?,?> virtualHost = _queue.getParent(VirtualHost.class);
- Exchange exchange = MBeanUtils.findExchangeFromExchangeName(virtualHost, exchangeName);
+ try
+ {
- _queue.setAttribute(Queue.ALTERNATE_EXCHANGE, getAlternateExchange(), exchange);
+ _queue.setAttributes(Collections.<String,Object>singletonMap(Queue.ALTERNATE_EXCHANGE, exchangeName));
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new OperationsException("No such exchange \""+exchangeName+"\"");
+ }
}
}
diff --git a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
index a81de49fb9..6a49b7c4ed 100644
--- a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
+++ b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
@@ -19,8 +19,10 @@
package org.apache.qpid.server.jmx.mbeans;
import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -320,7 +322,7 @@ public class QueueMBeanTest extends QpidTestCase
when(_mockQueue.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);
_queueMBean.setAlternateExchange("exchange2");
- verify(_mockQueue).setAttribute(Queue.ALTERNATE_EXCHANGE, null, mockExchange2);
+ verify(_mockQueue).setAttributes(Collections.<String,Object>singletonMap(Queue.ALTERNATE_EXCHANGE, "exchange2"));
}
public void testSetAlternateExchangeWithUnknownExchangeName() throws Exception
@@ -331,7 +333,8 @@ public class QueueMBeanTest extends QpidTestCase
VirtualHost mockVirtualHost = mock(VirtualHost.class);
when(mockVirtualHost.getExchanges()).thenReturn(Collections.singletonList(mockExchange));
when(_mockQueue.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);
-
+ doThrow(new IllegalArgumentException()).when(_mockQueue).setAttributes(
+ eq(Collections.<String, Object>singletonMap(Queue.ALTERNATE_EXCHANGE, "notknown")));
try
{
_queueMBean.setAlternateExchange("notknown");
@@ -346,7 +349,7 @@ public class QueueMBeanTest extends QpidTestCase
public void testRemoveAlternateExchange() throws Exception
{
_queueMBean.setAlternateExchange("");
- verify(_mockQueue).setAttribute(Queue.ALTERNATE_EXCHANGE, null, null);
+ verify(_mockQueue).setAttributes(Collections.singletonMap(Queue.ALTERNATE_EXCHANGE, null));
}
/********** Operations **********/