1 18 package org.apache.activemq.broker.policy; 19 20 import java.util.Iterator ; 21 22 import org.apache.activemq.broker.BrokerService; 23 import org.apache.activemq.broker.TopicSubscriptionTest; 24 import org.apache.activemq.broker.region.policy.PolicyEntry; 25 import org.apache.activemq.broker.region.policy.PolicyMap; 26 import org.apache.activemq.broker.region.policy.StrictOrderDispatchPolicy; 27 import org.apache.activemq.util.MessageIdList; 28 29 public class StrictOrderDispatchPolicyTest extends TopicSubscriptionTest { 30 31 protected BrokerService createBroker() throws Exception { 32 BrokerService broker = super.createBroker(); 33 34 PolicyEntry policy = new PolicyEntry(); 35 policy.setDispatchPolicy(new StrictOrderDispatchPolicy()); 36 37 PolicyMap pMap = new PolicyMap(); 38 pMap.setDefaultEntry(policy); 39 40 broker.setDestinationPolicy(pMap); 41 42 return broker; 43 } 44 45 public void testOneProducerTwoConsumersLargeMessagesOnePrefetch() throws Exception { 46 super.testOneProducerTwoConsumersLargeMessagesOnePrefetch(); 47 48 assertReceivedMessagesAreOrdered(); 49 } 50 51 public void testOneProducerTwoConsumersSmallMessagesOnePrefetch() throws Exception { 52 super.testOneProducerTwoConsumersSmallMessagesOnePrefetch(); 53 54 assertReceivedMessagesAreOrdered(); 55 } 56 57 public void testOneProducerTwoConsumersSmallMessagesLargePrefetch() throws Exception { 58 super.testOneProducerTwoConsumersSmallMessagesLargePrefetch(); 59 60 assertReceivedMessagesAreOrdered(); 61 } 62 63 public void testOneProducerTwoConsumersLargeMessagesLargePrefetch() throws Exception { 64 super.testOneProducerTwoConsumersLargeMessagesLargePrefetch(); 65 66 assertReceivedMessagesAreOrdered(); 67 } 68 69 public void testOneProducerManyConsumersFewMessages() throws Exception { 70 super.testOneProducerManyConsumersFewMessages(); 71 72 assertReceivedMessagesAreOrdered(); 73 } 74 75 public void testOneProducerManyConsumersManyMessages() throws Exception { 76 super.testOneProducerManyConsumersManyMessages(); 77 78 assertReceivedMessagesAreOrdered(); 79 } 80 81 public void testManyProducersOneConsumer() throws Exception { 82 super.testManyProducersOneConsumer(); 83 84 assertReceivedMessagesAreOrdered(); 85 } 86 87 public void testManyProducersManyConsumers() throws Exception { 88 super.testManyProducersManyConsumers(); 89 90 assertReceivedMessagesAreOrdered(); 91 } 92 93 public void assertReceivedMessagesAreOrdered() throws Exception { 94 if (consumers.size() <= 1) { 96 return; 97 } 98 99 Iterator i = consumers.keySet().iterator(); 101 MessageIdList messageOrder = (MessageIdList)consumers.get(i.next()); 102 103 for (;i.hasNext();) { 104 MessageIdList messageIdList = (MessageIdList)consumers.get(i.next()); 105 assertTrue("Messages are not ordered.", messageOrder.equals(messageIdList)); 106 } 107 } 108 } 109 | Popular Tags |