From 90dbe89d34d8e29086ffff20223994dbc53d9ffd Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Tue, 8 Dec 2009 11:43:53 +0000 Subject: QPID-2177: rework noddy unit test git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@888348 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/queue/AMQQueueMBeanTest.java | 25 ++++++++-------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java index d6bdacee86..4e5ba0213a 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java @@ -337,12 +337,16 @@ public class AMQQueueMBeanTest extends TestCase assertTrue(_queueMBean.getFlowResumeCapacity() == 0); } - //(FlowResume)Capacity currently 0, set both to 2 then try setting Capacity below this + //add a message to the queue + sendMessages(1, true); + + //(FlowResume)Capacity currently 0, set both to 2 _queueMBean.setCapacity(2L); assertTrue(_queueMBean.getCapacity() == 2L); _queueMBean.setFlowResumeCapacity(2L); assertTrue(_queueMBean.getFlowResumeCapacity() == 2L); + //Try setting Capacity below FlowResumeCapacity try { _queueMBean.setCapacity(1L); @@ -354,27 +358,16 @@ public class AMQQueueMBeanTest extends TestCase assertTrue(_queueMBean.getCapacity() == 2); } - //set (FlowResume)Capacity to MESSAGE_SIZE +1 then add a message to the queue - _queueMBean.setCapacity(MESSAGE_SIZE + 1); - _queueMBean.setFlowResumeCapacity(MESSAGE_SIZE + 1); - + //create a channel and use it to exercise the capacity check mechanism AMQChannel channel = new AMQChannel(_protocolSession, 1, _messageStore); - sendMessages(1, true); - _queue.checkCapacity(channel); - - assertFalse(_queueMBean.isFlowOverfull()); - assertFalse(channel.getBlocking()); - - //add another message then check queue is now overfull and channel blocked - sendMessages(1, true); _queue.checkCapacity(channel); assertTrue(_queueMBean.isFlowOverfull()); assertTrue(channel.getBlocking()); - //set FlowResumeCapacity to 2x MESSAGE_SIZE and check queue is now underfull and channel unblocked - _queueMBean.setCapacity(2 * MESSAGE_SIZE);//must increase capacity too - _queueMBean.setFlowResumeCapacity(2 * MESSAGE_SIZE); + //set FlowResumeCapacity to MESSAGE_SIZE and check queue is now underfull and channel unblocked + _queueMBean.setCapacity(MESSAGE_SIZE);//must increase capacity too + _queueMBean.setFlowResumeCapacity(MESSAGE_SIZE); assertFalse(_queueMBean.isFlowOverfull()); assertFalse(channel.getBlocking()); -- cgit v1.2.1