summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-04-24 17:25:16 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-04-24 17:25:16 +0000
commit67f29e0685b4bfaa0721a25ae901c3b5e18c0db3 (patch)
tree2c835283e855883f2675624288adc6039dea6e21 /qpid/java
parent05473bc92dedd111455f4238a65943951ca6d5ab (diff)
downloadqpid-python-67f29e0685b4bfaa0721a25ae901c3b5e18c0db3.tar.gz
QPID-5710 : Address review comments from Keith Wall and remove unnecessary classes
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1589801 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFinder.java38
-rw-r--r--qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java2
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java51
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/MBeanUtils.java57
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java46
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java20
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java4
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java35
-rw-r--r--qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java20
9 files changed, 105 insertions, 168 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFinder.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFinder.java
deleted file mode 100644
index 6a7d6f8f7b..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFinder.java
+++ /dev/null
@@ -1,38 +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.model;
-
-import java.util.Collection;
-
-public class ConfiguredObjectFinder
-{
- public static <C extends ConfiguredObject> C findConfiguredObjectByName(Collection<C> configuredObjects, String name)
- {
- for (C configuredObject : configuredObjects)
- {
- if (name.equals(configuredObject.getName()))
- {
- return configuredObject;
- }
- }
- return null;
- }
-}
diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
index 26d54761cc..3f4c3e9842 100644
--- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
+++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
@@ -121,7 +121,7 @@ public class VirtualHostTest extends QpidTestCase
host.createChild(Queue.class, arguments);
- Queue<?> queue = (Queue<?>) ConfiguredObjectFinder.findConfiguredObjectByName(host.getQueues(), queueName);
+ Queue<?> queue = host.getChildByName(Queue.class, queueName);
Object messageGroupKey = queue.getAttribute(Queue.MESSAGE_GROUP_KEY);
assertEquals("Unexpected message group key attribute", "mykey", messageGroupKey);
diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
index 8b247ef5fa..982b771a32 100644
--- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
+++ b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
@@ -21,17 +21,13 @@
package org.apache.qpid.server.jmx.mbeans;
-import org.apache.qpid.management.common.mbeans.ManagedExchange;
-import org.apache.qpid.server.binding.BindingImpl;
-import org.apache.qpid.server.exchange.HeadersExchange;
-import org.apache.qpid.server.jmx.AMQManagedObject;
-import org.apache.qpid.server.jmx.ManagedObject;
-import org.apache.qpid.server.model.Binding;
-import org.apache.qpid.server.model.Exchange;
-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.util.ServerScopedRuntimeException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.management.JMException;
import javax.management.MalformedObjectNameException;
@@ -47,13 +43,16 @@ import javax.management.openmbean.SimpleType;
import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+
+import org.apache.qpid.management.common.mbeans.ManagedExchange;
+import org.apache.qpid.server.jmx.AMQManagedObject;
+import org.apache.qpid.server.jmx.ManagedObject;
+import org.apache.qpid.server.model.Binding;
+import org.apache.qpid.server.model.Exchange;
+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.util.ServerScopedRuntimeException;
public class ExchangeMBean extends AMQManagedObject implements ManagedExchange
{
@@ -294,16 +293,24 @@ public class ExchangeMBean extends AMQManagedObject implements ManagedExchange
}
}
- VirtualHost virtualHost = _exchange.getParent(VirtualHost.class);
- Queue queue = MBeanUtils.findQueueFromQueueName(virtualHost, queueName);
+ VirtualHost<?,?,?> virtualHost = _exchange.getParent(VirtualHost.class);
+ Queue<?> queue = virtualHost.getChildByName(Queue.class, queueName);
+ if (queue == null)
+ {
+ throw new OperationsException("No such queue \""+ queueName +"\"");
+ }
_exchange.createBinding(binding, queue, arguments, Collections.EMPTY_MAP);
}
public void removeBinding(String queueName, String bindingKey)
throws IOException, JMException
{
- VirtualHost virtualHost = _exchange.getParent(VirtualHost.class);
- Queue queue = MBeanUtils.findQueueFromQueueName(virtualHost, queueName);;
+ VirtualHost<?,?,?> virtualHost = _exchange.getParent(VirtualHost.class);
+ Queue<?> queue = virtualHost.getChildByName(Queue.class, queueName);
+ if (queue == null)
+ {
+ throw new OperationsException("No such queue \""+ queueName +"\"");
+ }
boolean deleted = false;
for(Binding binding : _exchange.getBindings())
diff --git a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/MBeanUtils.java b/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/MBeanUtils.java
deleted file mode 100644
index 30d85df947..0000000000
--- a/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/MBeanUtils.java
+++ /dev/null
@@ -1,57 +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.jmx.mbeans;
-
-import javax.management.OperationsException;
-
-import org.apache.qpid.server.model.ConfiguredObjectFinder;
-import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.VirtualHost;
-
-public class MBeanUtils
-{
- public static Queue findQueueFromQueueName(VirtualHost<?,?,?> virtualHost, String queueName) throws OperationsException
- {
- Queue queue = ConfiguredObjectFinder.findConfiguredObjectByName(virtualHost.getQueues(), queueName);
- if (queue == null)
- {
- throw new OperationsException("No such queue \""+queueName+"\"");
- }
- else
- {
- return queue;
- }
- }
-
- public static Exchange findExchangeFromExchangeName(VirtualHost<?,?,?> virtualHost, String exchangeName) throws OperationsException
- {
- Exchange exchange = ConfiguredObjectFinder.findConfiguredObjectByName(virtualHost.getExchanges(), exchangeName);
- if (exchange == null)
- {
- throw new OperationsException("No such exchange \""+exchangeName+"\"");
- }
- else
- {
- return exchange;
- }
- }
-}
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 a9fc160618..a1fec6f69e 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
@@ -170,23 +170,23 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
public Integer getActiveConsumerCount()
{
- return (int) _queue.getConsumerCountWithCredit();
+ return _queue.getConsumerCountWithCredit();
}
public Integer getConsumerCount()
{
- return (int) _queue.getConsumerCount();
+ return _queue.getConsumerCount();
}
public String getOwner()
{
- return (String) _queue.getAttribute(Queue.OWNER);
+ return _queue.getOwner();
}
@Override
public String getQueueType()
{
- return (String) _queue.getAttribute(Queue.TYPE);
+ return _queue.getType();
}
public boolean isDurable()
@@ -241,7 +241,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
public Long getCapacity()
{
- return (Long) _queue.getQueueFlowControlSizeBytes();
+ return _queue.getQueueFlowControlSizeBytes();
}
public void setCapacity(Long value)
@@ -261,12 +261,12 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
public boolean isFlowOverfull()
{
- return (Boolean)_queue.getAttribute(Queue.QUEUE_FLOW_STOPPED);
+ return _queue.isQueueFlowStopped();
}
public boolean isExclusive()
{
- final Object attribute = _queue.getAttribute(Queue.EXCLUSIVE);
+ final ExclusivityPolicy attribute = _queue.getExclusive();
return attribute != null && attribute != ExclusivityPolicy.NONE;
}
@@ -274,7 +274,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
{
if(exclusive)
{
- Object currentValue = _queue.getAttribute(Queue.EXCLUSIVE);
+ ExclusivityPolicy currentValue = _queue.getExclusive();
if(currentValue == null || currentValue == ExclusivityPolicy.NONE)
{
_queue.setAttribute(Queue.EXCLUSIVE, currentValue, ExclusivityPolicy.CONTAINER);
@@ -282,7 +282,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
}
else
{
- Object currentValue = _queue.getAttribute(Queue.EXCLUSIVE);
+ ExclusivityPolicy currentValue = _queue.getExclusive();
if(currentValue != null && currentValue != ExclusivityPolicy.NONE)
{
_queue.setAttribute(Queue.EXCLUSIVE, currentValue, ExclusivityPolicy.NONE);
@@ -313,7 +313,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
public String getAlternateExchange()
{
- Exchange alternateExchange = (Exchange) _queue.getAttribute(Queue.ALTERNATE_EXCHANGE);
+ Exchange alternateExchange = _queue.getAlternateExchange();
return alternateExchange == null ? null : alternateExchange.getName();
}
@@ -497,8 +497,12 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
}
- VirtualHost vhost = _queue.getParent(VirtualHost.class);
- final Queue destinationQueue = MBeanUtils.findQueueFromQueueName(vhost, toQueue);
+ VirtualHost<?,?,?> vhost = _queue.getParent(VirtualHost.class);
+ final Queue<?> destinationQueue = vhost.getChildByName(Queue.class, toQueue);
+ if (destinationQueue == null)
+ {
+ throw new OperationsException("No such queue \""+ toQueue +"\"");
+ }
vhost.executeTransaction(new VirtualHost.TransactionalOperation()
{
@@ -566,9 +570,12 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
throw new OperationsException("\"From MessageId\" should be greater than 0 and less than \"To MessageId\"");
}
- VirtualHost vhost = _queue.getParent(VirtualHost.class);
- final Queue destinationQueue = MBeanUtils.findQueueFromQueueName(vhost, toQueue);
-
+ VirtualHost<?,?,?> vhost = _queue.getParent(VirtualHost.class);
+ final Queue<?> queue = vhost.getChildByName(Queue.class, toQueue);
+ if (queue == null)
+ {
+ throw new OperationsException("No such queue \""+ toQueue +"\"");
+ }
vhost.executeTransaction(new VirtualHost.TransactionalOperation()
{
public void withinTransaction(final VirtualHost.Transaction txn)
@@ -586,7 +593,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
if ((messageId >= fromMessageId)
&& (messageId <= toMessageId))
{
- txn.copy(entry, destinationQueue);
+ txn.copy(entry, queue);
}
}
@@ -673,7 +680,7 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
@Override
public String getDescription()
{
- return (String) _queue.getAttribute(Queue.DESCRIPTION);
+ return _queue.getDescription();
}
@Override
@@ -685,13 +692,12 @@ public class QueueMBean extends AMQManagedObject implements ManagedQueue, QueueN
@Override
public String getMessageGroupKey()
{
- return (String) _queue.getAttribute(Queue.MESSAGE_GROUP_KEY);
+ return _queue.getMessageGroupKey();
}
@Override
public boolean isMessageGroupSharedGroups()
{
- Boolean value = (Boolean) _queue.getAttribute(Queue.MESSAGE_GROUP_SHARED_GROUPS);
- return value == null ? false : value.booleanValue();
+ return _queue.isMessageGroupSharedGroups();
}
}
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 0f19b097e7..a7f2ec3257 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
@@ -181,10 +181,17 @@ public class VirtualHostManagerMBean extends AbstractStatisticsGatheringMBean<Vi
public void unregisterExchange(String exchangeName)
throws IOException, JMException, MBeanException
{
- Exchange theExchange = MBeanUtils.findExchangeFromExchangeName(_virtualHostMBean.getVirtualHost(), exchangeName);
+ VirtualHost<?,?,?> virtualHost = _virtualHostMBean.getVirtualHost();
+ Exchange<?> exchange = virtualHost.getChildByName(Exchange.class, exchangeName);
+
+ if (exchange == null)
+ {
+ throw new OperationsException("No such exchange \""+ exchangeName +"\"");
+ }
+
try
{
- theExchange.delete();
+ exchange.delete();
}
catch(RequiredExchangeException e)
{
@@ -254,8 +261,13 @@ public class VirtualHostManagerMBean extends AbstractStatisticsGatheringMBean<Vi
@MBeanOperationParameter(name = ManagedQueue.TYPE, description = "Queue Name") String queueName)
throws IOException, JMException, MBeanException
{
- Queue theQueue = MBeanUtils.findQueueFromQueueName(_virtualHostMBean.getVirtualHost(), queueName);
- theQueue.delete();
+ VirtualHost<?,?,?> virtualHost = _virtualHostMBean.getVirtualHost();
+ Queue<?> queue = virtualHost.getChildByName(Queue.class, queueName);
+ if (queue == null)
+ {
+ throw new OperationsException("No such queue \""+ queueName +"\"");
+ }
+ queue.delete();
}
@Override
diff --git a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
index 746dc0e63f..9dc19c3290 100644
--- a/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
+++ b/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
@@ -21,6 +21,7 @@ package org.apache.qpid.server.jmx.mbeans;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -75,6 +76,9 @@ public class ExchangeMBeanTest extends TestCase
VirtualHost mockVirtualHost = mock(VirtualHost.class);
when(mockVirtualHost.getQueues()).thenReturn(Arrays.asList(new Queue[] {_mockQueue1, _mockQueue2}));
+ when(mockVirtualHost.getChildByName(eq(Queue.class), eq(QUEUE1_NAME))).thenReturn(_mockQueue1);
+ when(mockVirtualHost.getChildByName(eq(Queue.class), eq(QUEUE2_NAME))).thenReturn(_mockQueue2);
+
when(_mockExchange.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);
_exchangeMBean = new ExchangeMBean(_mockExchange, _mockVirtualHostMBean);
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 6a49b7c4ed..6f31dc6d04 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
@@ -122,18 +122,22 @@ public class QueueMBeanTest extends QpidTestCase
public void testGetQueueDescription() throws Exception
{
- when(_mockQueue.getAttribute(Queue.DESCRIPTION)).thenReturn(QUEUE_DESCRIPTION);
+ when(_mockQueue.getDescription()).thenReturn(QUEUE_DESCRIPTION);
MBeanTestUtils.assertMBeanAttribute(_queueMBean, "description", QUEUE_DESCRIPTION);
}
public void testSetQueueDescription() throws Exception
{
- testSetAttribute("description", Queue.DESCRIPTION, "descriptionold", "descriptionnew");
+ when(_mockQueue.getDescription()).thenReturn("descriptionold");
+
+ MBeanTestUtils.setMBeanAttribute(_queueMBean, "description", "descriptionnew");
+
+ verify(_mockQueue).setAttribute(Queue.DESCRIPTION, "descriptionold", "descriptionnew");
}
public void testQueueType() throws Exception
{
- when(_mockQueue.getAttribute(Queue.TYPE)).thenReturn(QUEUE_TYPE);
+ when(_mockQueue.getType()).thenReturn(QUEUE_TYPE);
MBeanTestUtils.assertMBeanAttribute(_queueMBean, "queueType", QUEUE_TYPE);
}
@@ -145,7 +149,7 @@ public class QueueMBeanTest extends QpidTestCase
public void testOwner() throws Exception
{
- when(_mockQueue.getAttribute(Queue.OWNER)).thenReturn("testOwner");
+ when(_mockQueue.getOwner()).thenReturn("testOwner");
MBeanTestUtils.assertMBeanAttribute(_queueMBean, "owner", "testOwner");
}
@@ -269,19 +273,19 @@ public class QueueMBeanTest extends QpidTestCase
public void testIsExclusive() throws Exception
{
- when(_mockQueue.getAttribute(Queue.EXCLUSIVE)).thenReturn(ExclusivityPolicy.CONTAINER);
+ when(_mockQueue.getExclusive()).thenReturn(ExclusivityPolicy.CONTAINER);
MBeanTestUtils.assertMBeanAttribute(_queueMBean, "exclusive", true);
}
public void testIsNotExclusive() throws Exception
{
- when(_mockQueue.getAttribute(Queue.EXCLUSIVE)).thenReturn(ExclusivityPolicy.NONE);
+ when(_mockQueue.getExclusive()).thenReturn(ExclusivityPolicy.NONE);
MBeanTestUtils.assertMBeanAttribute(_queueMBean, "exclusive", false);
}
public void testSetExclusive() throws Exception
{
- when(_mockQueue.getAttribute(Queue.EXCLUSIVE)).thenReturn(ExclusivityPolicy.NONE);
+ when(_mockQueue.getExclusive()).thenReturn(ExclusivityPolicy.NONE);
MBeanTestUtils.setMBeanAttribute(_queueMBean, "exclusive", Boolean.TRUE);
@@ -294,14 +298,14 @@ public class QueueMBeanTest extends QpidTestCase
Exchange mockAlternateExchange = mock(Exchange.class);
when(mockAlternateExchange.getName()).thenReturn(QUEUE_ALTERNATE_EXCHANGE);
- when(_mockQueue.getAttribute(Queue.ALTERNATE_EXCHANGE)).thenReturn(mockAlternateExchange);
+ when(_mockQueue.getAlternateExchange()).thenReturn(mockAlternateExchange);
assertEquals(QUEUE_ALTERNATE_EXCHANGE, _queueMBean.getAlternateExchange());
}
public void testGetAlternateExchangeWhenQueueHasNone()
{
- when(_mockQueue.getAttribute(Queue.ALTERNATE_EXCHANGE)).thenReturn(null);
+ when(_mockQueue.getAlternateExchange()).thenReturn(null);
assertNull(_queueMBean.getAlternateExchange());
}
@@ -408,15 +412,6 @@ public class QueueMBeanTest extends QpidTestCase
MBeanTestUtils.assertMBeanAttribute(_queueMBean, jmxAttributeName, expectedValue);
}
- private void testSetAttribute(String jmxAttributeName, String underlyingAttributeName, Object originalAttributeValue, Object newAttributeValue) throws Exception
- {
- when(_mockQueue.getAttribute(underlyingAttributeName)).thenReturn(originalAttributeValue);
-
- MBeanTestUtils.setMBeanAttribute(_queueMBean, jmxAttributeName, newAttributeValue);
-
- verify(_mockQueue).setAttribute(underlyingAttributeName, originalAttributeValue, newAttributeValue);
- }
-
public void testViewMessageContent() throws Exception
{
viewMessageContentTestImpl(16L, 1000, 1000);
@@ -481,13 +476,13 @@ public class QueueMBeanTest extends QpidTestCase
public void testGetMessageGroupKey()
{
- when(_mockQueue.getAttribute(Queue.MESSAGE_GROUP_KEY)).thenReturn(getTestName());
+ when(_mockQueue.getMessageGroupKey()).thenReturn(getTestName());
assertEquals("Unexpected message group key", getTestName(), _queueMBean.getMessageGroupKey());
}
public void testIsSharedMessageGroup()
{
- when(_mockQueue.getAttribute(Queue.MESSAGE_GROUP_SHARED_GROUPS)).thenReturn(true);
+ when(_mockQueue.isMessageGroupSharedGroups()).thenReturn(true);
assertEquals("Unexpected message group sharing", true, _queueMBean.isMessageGroupSharedGroups());
}
}
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 b8a432bc4b..d63a3983f5 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
@@ -19,6 +19,7 @@
*/
package org.apache.qpid.server.jmx.mbeans;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -49,6 +50,8 @@ public class VirtualHostManagerMBeanTest extends TestCase
private static final String TEST_EXCHANGE_TYPE = "EXCHANGE_TYPE";
private static final Map<String, Object> EMPTY_ARGUMENT_MAP = Collections.emptyMap();
+ public static final String QUEUE_1_NAME = "queue1";
+ public static final String EXCHANGE_1_NAME = "exchange1";
private VirtualHost _mockVirtualHost;
private ManagedObjectRegistry _mockManagedObjectRegistry;
@@ -116,18 +119,20 @@ public class VirtualHostManagerMBeanTest extends TestCase
public void testDeleteQueue() throws Exception
{
Queue mockQueue = mock(Queue.class);
- when(mockQueue.getName()).thenReturn("queue1");
+ when(mockQueue.getName()).thenReturn(QUEUE_1_NAME);
when(_mockVirtualHost.getQueues()).thenReturn(Collections.singletonList(mockQueue));
+ when(_mockVirtualHost.getChildByName(eq(Queue.class), eq(QUEUE_1_NAME))).thenReturn(mockQueue);
- _virtualHostManagerMBean.deleteQueue("queue1");
+ _virtualHostManagerMBean.deleteQueue(QUEUE_1_NAME);
verify(mockQueue).delete();
}
public void testDeleteQueueWhenQueueDoesNotExist() throws Exception
{
Queue mockQueue = mock(Queue.class);
- when(mockQueue.getName()).thenReturn("queue1");
+ when(mockQueue.getName()).thenReturn(QUEUE_1_NAME);
when(_mockVirtualHost.getQueues()).thenReturn(Collections.singletonList(mockQueue));
+ when(_mockVirtualHost.getChildByName(eq(Queue.class), eq(QUEUE_1_NAME))).thenReturn(mockQueue);
try
{
@@ -166,18 +171,21 @@ public class VirtualHostManagerMBeanTest extends TestCase
public void testUnregisterExchange() throws Exception
{
Exchange mockExchange = mock(Exchange.class);
- when(mockExchange.getName()).thenReturn("exchange1");
+ when(mockExchange.getName()).thenReturn(EXCHANGE_1_NAME);
when(_mockVirtualHost.getExchanges()).thenReturn(Collections.singletonList(mockExchange));
+ when(_mockVirtualHost.getChildByName(eq(Exchange.class), eq(EXCHANGE_1_NAME))).thenReturn(mockExchange);
- _virtualHostManagerMBean.unregisterExchange("exchange1");
+
+ _virtualHostManagerMBean.unregisterExchange(EXCHANGE_1_NAME);
verify(mockExchange).delete();
}
public void testUnregisterExchangeWhenExchangeDoesNotExist() throws Exception
{
Exchange mockExchange = mock(Exchange.class);
- when(mockExchange.getName()).thenReturn("exchange1");
+ when(mockExchange.getName()).thenReturn(EXCHANGE_1_NAME);
when(_mockVirtualHost.getExchanges()).thenReturn(Collections.singletonList(mockExchange));
+ when(_mockVirtualHost.getChildByName(eq(Exchange.class), eq(EXCHANGE_1_NAME))).thenReturn(mockExchange);
try
{