Author: ataylor
Date: 2009-11-12 09:36:45 -0500 (Thu, 12 Nov 2009)
New Revision: 8272
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java
Log:
added test for iterator when first message handled is busy and that the order is still
correct
Modified: trunk/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java 2009-11-12
13:31:32 UTC (rev 8271)
+++ trunk/tests/src/org/hornetq/tests/unit/core/server/impl/QueueImplTest.java 2009-11-12
14:36:45 UTC (rev 8272)
@@ -906,6 +906,47 @@
assertRefListsIdenticalRefs(refs, consumer.getReferences());
}
+ public void testBusyConsumerWithFilterFirstCallBusy() throws Exception
+ {
+ Queue queue = new QueueImpl(1, address1, queue1, null, false, true,
scheduledExecutor, null, null, null);
+
+ FakeConsumer consumer = new FakeConsumer(FilterImpl.createFilter("color =
'green'"));
+
+ consumer.setStatusImmediate(HandleStatus.BUSY);
+
+ queue.addConsumer(consumer);
+
+ final int numMessages = 10;
+
+ List<MessageReference> refs = new ArrayList<MessageReference>();
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ MessageReference ref = generateReference(queue, i);
+ ref.getMessage().putStringProperty("color", "green");
+ refs.add(ref);
+
+ queue.addLast(ref);
+ }
+
+ assertEquals(10, queue.getMessageCount());
+ assertEquals(0, queue.getScheduledCount());
+ assertEquals(0, queue.getDeliveringCount());
+
+ queue.deliverNow();
+
+ consumer.setStatusImmediate(null);
+
+ queue.deliverNow();
+
+ List<MessageReference> receeivedRefs = consumer.getReferences();
+ int currId = 0;
+ for (MessageReference receeivedRef : receeivedRefs)
+ {
+ assertEquals("messages received out of order",
receeivedRef.getMessage().getMessageID() , currId++);
+ }
+ }
+
public void testBusyConsumerWithFilterThenAddMoreMessages() throws Exception
{
Queue queue = new QueueImpl(1, address1, queue1, null, false, true,
scheduledExecutor, null, null, null);
@@ -971,6 +1012,13 @@
assertEquals(30, queue.getMessageCount());
assertEquals(0, queue.getScheduledCount());
assertEquals(10, queue.getDeliveringCount());
+
+ List<MessageReference> receeivedRefs = consumer.getReferences();
+ int currId = 10;
+ for (MessageReference receeivedRef : receeivedRefs)
+ {
+ assertEquals("messages received out of order",
receeivedRef.getMessage().getMessageID() , currId++);
+ }
}
public void testConsumerWithFilterThenAddMoreMessages() throws Exception