Author: rgodfrey
Date: Thu Apr 24 17:25:16 2014
New Revision: 1589801
URL: http://svn.apache.org/r1589801
Log:
QPID-5710 : Address review comments from Keith Wall and remove unnecessary
classes
Removed:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectFinder.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/MBeanUtils.java
Modified:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java
Modified:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
(original)
+++
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
Thu Apr 24 17:25:16 2014
@@ -121,7 +121,7 @@ public class VirtualHostTest extends Qpi
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);
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBean.java
Thu Apr 24 17:25:16 2014
@@ -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.Simple
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 AMQMa
}
}
- 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())
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/QueueMBean.java
Thu Apr 24 17:25:16 2014
@@ -170,23 +170,23 @@ public class QueueMBean extends AMQManag
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 AMQManag
public Long getCapacity()
{
- return (Long) _queue.getQueueFlowControlSizeBytes();
+ return _queue.getQueueFlowControlSizeBytes();
}
public void setCapacity(Long value)
@@ -261,12 +261,12 @@ public class QueueMBean extends AMQManag
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 AMQManag
{
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 AMQManag
}
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 AMQManag
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 AMQManag
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 AMQManag
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 AMQManag
if ((messageId >= fromMessageId)
&& (messageId <= toMessageId))
{
- txn.copy(entry, destinationQueue);
+ txn.copy(entry, queue);
}
}
@@ -673,7 +680,7 @@ public class QueueMBean extends AMQManag
@Override
public String getDescription()
{
- return (String) _queue.getAttribute(Queue.DESCRIPTION);
+ return _queue.getDescription();
}
@Override
@@ -685,13 +692,12 @@ public class QueueMBean extends AMQManag
@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();
}
}
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBean.java
Thu Apr 24 17:25:16 2014
@@ -181,10 +181,17 @@ public class VirtualHostManagerMBean ext
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 ext
@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
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/ExchangeMBeanTest.java
Thu Apr 24 17:25:16 2014
@@ -21,6 +21,7 @@ package org.apache.qpid.server.jmx.mbean
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 T
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);
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/QueueMBeanTest.java
Thu Apr 24 17:25:16 2014
@@ -122,18 +122,22 @@ public class QueueMBeanTest extends Qpid
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 Qpid
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 Qpid
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 Qpid
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 Qpid
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 Qpid
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());
}
}
Modified:
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java?rev=1589801&r1=1589800&r2=1589801&view=diff
==============================================================================
---
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java
(original)
+++
qpid/trunk/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/mbeans/VirtualHostManagerMBeanTest.java
Thu Apr 24 17:25:16 2014
@@ -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
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
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
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
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]