1 17 package org.apache.activemq.broker.policy; 18 19 import org.apache.activemq.TestSupport; 20 import org.apache.activemq.broker.BrokerService; 21 import org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy; 22 import org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy; 23 import org.apache.activemq.broker.region.policy.PolicyEntry; 24 import org.apache.activemq.broker.region.policy.VMPendingQueueMessageStoragePolicy; 25 import org.apache.activemq.broker.region.policy.VMPendingSubscriberMessageStoragePolicy; 26 import org.apache.activemq.command.ActiveMQDestination; 27 import org.apache.activemq.xbean.BrokerFactoryBean; 28 import org.springframework.core.io.ClassPathResource; 29 30 33 public class DestinationCursorConfigTest extends TestSupport { 34 protected BrokerService broker; 35 36 @Override 37 protected void setUp() throws Exception { 38 broker = createBroker(); 39 super.setUp(); 40 } 41 42 @Override 43 protected void tearDown() throws Exception { 44 broker.stop(); 45 super.tearDown(); 46 } 47 48 protected BrokerService createBroker() throws Exception { 49 BrokerFactoryBean factory = new BrokerFactoryBean(new ClassPathResource("org/apache/activemq/broker/policy/cursor.xml")); 50 factory.afterPropertiesSet(); 51 BrokerService answer = factory.getBroker(); 52 return answer; 53 } 54 55 public void testQueueConfiguration() throws Exception { 56 super.topic = false; 57 ActiveMQDestination destination = (ActiveMQDestination) createDestination("org.apache.foo"); 58 PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination); 59 PendingQueueMessageStoragePolicy policy = entry.getPendingQueuePolicy(); 60 assertNotNull(policy); 61 assertTrue("Policy is: " + policy, policy instanceof VMPendingQueueMessageStoragePolicy); 62 } 63 64 public void testTopicConfiguration() throws Exception { 65 super.topic = true; 66 ActiveMQDestination destination = (ActiveMQDestination) createDestination("org.apache.foo"); 67 PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination); 68 PendingSubscriberMessageStoragePolicy policy = entry.getPendingSubscriberPolicy(); 69 assertNotNull(policy); 70 assertTrue("subscriberPolicy is: " + policy, policy instanceof VMPendingSubscriberMessageStoragePolicy); 71 } 72 } 73 | Popular Tags |